MovePandaAction.java

1
package com.takenoko.actions.actors;
2
3
import com.takenoko.actions.ActionResult;
4
import com.takenoko.actions.DefaultAction;
5
import com.takenoko.actions.annotations.ActionAnnotation;
6
import com.takenoko.actions.annotations.ActionType;
7
import com.takenoko.engine.Board;
8
import com.takenoko.engine.BotManager;
9
import com.takenoko.layers.bamboo.LayerBambooStack;
10
import com.takenoko.vector.PositionVector;
11
import java.util.Map;
12
import java.util.Objects;
13
14
/** This class represents the action of moving the panda. */
15
@ActionAnnotation(ActionType.DEFAULT)
16
public class MovePandaAction implements DefaultAction {
17
    private final PositionVector relativePositionVector;
18
19
    /**
20
     * Constructor for the MovePandaAction class.
21
     *
22
     * @param relativePositionVector the position vector to move the panda
23
     */
24
    public MovePandaAction(PositionVector relativePositionVector) {
25
        this.relativePositionVector = relativePositionVector;
26
    }
27
28
    public static boolean canBePlayed(Board board) {
29 2 1. canBePlayed : negated conditional → KILLED
2. canBePlayed : replaced boolean return with true for com/takenoko/actions/actors/MovePandaAction::canBePlayed → KILLED
        return !board.getTilesWithoutPond().isEmpty();
30
    }
31
32
    /**
33
     * Move the panda with a vector on the board and display a message.
34
     *
35
     * @param board the board
36
     * @param botManager the bot manager
37
     * @return the action result
38
     */
39
    @Override
40
    public ActionResult execute(Board board, BotManager botManager) {
41
        // move the panda
42
        Map<PositionVector, LayerBambooStack> bambooStack = board.movePanda(relativePositionVector);
43 1 1. execute : removed call to com/takenoko/engine/BotManager::displayMessage → TIMED_OUT
        botManager.displayMessage(
44
                botManager.getName()
45
                        + " moved the panda with "
46
                        + relativePositionVector
47
                        + " to position "
48
                        + board.getPandaPosition());
49
50 1 1. execute : negated conditional → KILLED
        if (!bambooStack.isEmpty()) {
51
            // eat bamboo
52
            botManager
53
                    .getInventory()
54 1 1. execute : removed call to com/takenoko/inventory/Inventory::collectBamboo → KILLED
                    .collectBamboo(board.getTileAt(board.getPandaPosition()).getColor());
55
            botManager
56
                    .getSingleBotStatistics()
57 1 1. execute : removed call to com/takenoko/stats/SingleBotStatistics::updateEatenBambooCounter → KILLED
                    .updateEatenBambooCounter(board.getTileAt(board.getPandaPosition()).getColor());
58 1 1. execute : removed call to com/takenoko/stats/SingleBotStatistics::updateActions → KILLED
            botManager.getSingleBotStatistics().updateActions(getClass().getSimpleName());
59 1 1. execute : removed call to com/takenoko/engine/BotManager::displayMessage → TIMED_OUT
            botManager.displayMessage(
60
                    "Panda ate one "
61
                            + board.getTileAt(board.getPandaPosition()).getColor()
62
                            + " bamboo for "
63
                            + botManager.getName());
64
        } else {
65
            // no bamboo to eat
66 1 1. execute : removed call to com/takenoko/engine/BotManager::displayMessage → TIMED_OUT
            botManager.displayMessage("Panda didn't eat any bamboo");
67
        }
68 1 1. execute : replaced return value with null for com/takenoko/actions/actors/MovePandaAction::execute → KILLED
        return new ActionResult(1);
69
    }
70
71
    @Override
72
    public String toString() {
73 1 1. toString : replaced return value with "" for com/takenoko/actions/actors/MovePandaAction::toString → TIMED_OUT
        return "MovePandaAction {pos_vect=" + relativePositionVector + "}";
74
    }
75
76
    @Override
77
    public boolean equals(Object o) {
78 2 1. equals : replaced boolean return with false for com/takenoko/actions/actors/MovePandaAction::equals → NO_COVERAGE
2. equals : negated conditional → TIMED_OUT
        if (this == o) return true;
79 3 1. equals : negated conditional → TIMED_OUT
2. equals : negated conditional → TIMED_OUT
3. equals : replaced boolean return with true for com/takenoko/actions/actors/MovePandaAction::equals → TIMED_OUT
        if (o == null || getClass() != o.getClass()) return false;
80
        MovePandaAction that = (MovePandaAction) o;
81 2 1. equals : replaced boolean return with false for com/takenoko/actions/actors/MovePandaAction::equals → TIMED_OUT
2. equals : replaced boolean return with true for com/takenoko/actions/actors/MovePandaAction::equals → TIMED_OUT
        return Objects.equals(relativePositionVector, that.relativePositionVector);
82
    }
83
84
    @Override
85
    public int hashCode() {
86 1 1. hashCode : replaced int return with 0 for com/takenoko/actions/actors/MovePandaAction::hashCode → TIMED_OUT
        return Objects.hash(relativePositionVector);
87
    }
88
}

Mutations

29

1.1
Location : canBePlayed
Killed by : com.takenoko.engine.BotStateTest.[engine:junit-jupiter]/[class:com.takenoko.engine.BotStateTest]/[nested-class:TestUpdateAvailableActions]/[method:updateAvailableActions_shouldNotRemoveAlreadyExecutedActionsIfWindy()]
negated conditional → KILLED

2.2
Location : canBePlayed
Killed by : com.takenoko.engine.BotStateTest.[engine:junit-jupiter]/[class:com.takenoko.engine.BotStateTest]/[nested-class:TestUpdateAvailableActions]/[method:updateAvailableActions_shouldNotRemoveAlreadyExecutedActionsIfWindy()]
replaced boolean return with true for com/takenoko/actions/actors/MovePandaAction::canBePlayed → KILLED

43

1.1
Location : execute
Killed by : none
removed call to com/takenoko/engine/BotManager::displayMessage → TIMED_OUT

50

1.1
Location : execute
Killed by : com.takenoko.actions.actors.MovePandaActionTest.[engine:junit-jupiter]/[class:com.takenoko.actions.actors.MovePandaActionTest]/[nested-class:TestExecute]/[method:shouldUpdateEatenBambooCounterAndActionsInSingleBotStatistics()]
negated conditional → KILLED

54

1.1
Location : execute
Killed by : com.takenoko.actions.actors.MovePandaActionTest.[engine:junit-jupiter]/[class:com.takenoko.actions.actors.MovePandaActionTest]/[nested-class:TestExecute]/[method:shouldMoveThePandaCollectBambooAndDisplayMessages()]
removed call to com/takenoko/inventory/Inventory::collectBamboo → KILLED

57

1.1
Location : execute
Killed by : com.takenoko.actions.actors.MovePandaActionTest.[engine:junit-jupiter]/[class:com.takenoko.actions.actors.MovePandaActionTest]/[nested-class:TestExecute]/[method:shouldUpdateEatenBambooCounterAndActionsInSingleBotStatistics()]
removed call to com/takenoko/stats/SingleBotStatistics::updateEatenBambooCounter → KILLED

58

1.1
Location : execute
Killed by : com.takenoko.actions.actors.MovePandaActionTest.[engine:junit-jupiter]/[class:com.takenoko.actions.actors.MovePandaActionTest]/[nested-class:TestExecute]/[method:shouldUpdateEatenBambooCounterAndActionsInSingleBotStatistics()]
removed call to com/takenoko/stats/SingleBotStatistics::updateActions → KILLED

59

1.1
Location : execute
Killed by : none
removed call to com/takenoko/engine/BotManager::displayMessage → TIMED_OUT

66

1.1
Location : execute
Killed by : none
removed call to com/takenoko/engine/BotManager::displayMessage → TIMED_OUT

68

1.1
Location : execute
Killed by : com.takenoko.bot.utils.HistoryAnalysisTest.[engine:junit-jupiter]/[class:com.takenoko.bot.utils.HistoryAnalysisTest]/[nested-class:IntegrationTest]/[method:test1()]
replaced return value with null for com/takenoko/actions/actors/MovePandaAction::execute → KILLED

73

1.1
Location : toString
Killed by : none
replaced return value with "" for com/takenoko/actions/actors/MovePandaAction::toString → TIMED_OUT

78

1.1
Location : equals
Killed by : none
negated conditional → TIMED_OUT

2.2
Location : equals
Killed by : none
replaced boolean return with false for com/takenoko/actions/actors/MovePandaAction::equals → NO_COVERAGE

79

1.1
Location : equals
Killed by : none
negated conditional → TIMED_OUT

2.2
Location : equals
Killed by : none
negated conditional → TIMED_OUT

3.3
Location : equals
Killed by : none
replaced boolean return with true for com/takenoko/actions/actors/MovePandaAction::equals → TIMED_OUT

81

1.1
Location : equals
Killed by : none
replaced boolean return with false for com/takenoko/actions/actors/MovePandaAction::equals → TIMED_OUT

2.2
Location : equals
Killed by : none
replaced boolean return with true for com/takenoko/actions/actors/MovePandaAction::equals → TIMED_OUT

86

1.1
Location : hashCode
Killed by : none
replaced int return with 0 for com/takenoko/actions/actors/MovePandaAction::hashCode → TIMED_OUT

Active mutators

Tests examined


Report generated by PIT 1.8.0