MoveGardenerAction.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
/** Action to move a gardener. */
15
@ActionAnnotation(ActionType.DEFAULT)
16
public class MoveGardenerAction implements DefaultAction {
17
    private final PositionVector relativePositionVector;
18
19
    /**
20
     * Constructor for the MoveGardenerAction class.
21
     *
22
     * @param relativePositionVector the position vector to move the Gardener
23
     */
24
    public MoveGardenerAction(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/MoveGardenerAction::canBePlayed → KILLED
        return !board.getTilesWithoutPond().isEmpty();
30
    }
31
32
    /**
33
     * Move the Gardener 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 Gardener
42
43
        Map<PositionVector, LayerBambooStack> bambooStacks =
44
                board.moveGardener(relativePositionVector);
45 1 1. execute : removed call to com/takenoko/engine/BotManager::displayMessage → TIMED_OUT
        botManager.displayMessage(
46
                botManager.getName()
47
                        + " moved the gardener"
48
                        + " with "
49
                        + relativePositionVector
50
                        + " to position "
51
                        + board.getGardenerPosition());
52
53 1 1. execute : negated conditional → TIMED_OUT
        if (bambooStacks.isEmpty()) {
54 1 1. execute : removed call to com/takenoko/engine/BotManager::displayMessage → TIMED_OUT
            botManager.displayMessage("Gardener didn't plant any bamboo");
55
        }
56
57 1 1. execute : removed call to java/util/Map::forEach → KILLED
        bambooStacks.forEach(
58
                (positionVector, layerBambooStack) -> {
59 1 1. lambda$execute$0 : removed call to com/takenoko/engine/BotManager::displayMessage → TIMED_OUT
                    botManager.displayMessage(
60
                            "Gardener planted bamboo at "
61
                                    + positionVector
62
                                    + ", the stack is now "
63
                                    + layerBambooStack.getBambooCount()
64
                                    + "high");
65
                    botManager
66
                            .getSingleBotStatistics()
67 1 1. lambda$execute$0 : removed call to com/takenoko/stats/SingleBotStatistics::updatePlantedBambooCounter → KILLED
                            .updatePlantedBambooCounter(
68
                                    board.getTileAt(positionVector).getColor(),
69
                                    layerBambooStack.getBambooCount());
70
                });
71 1 1. execute : removed call to com/takenoko/stats/SingleBotStatistics::updateActions → KILLED
        botManager.getSingleBotStatistics().updateActions(this.getClass().getSimpleName());
72
73 1 1. execute : replaced return value with null for com/takenoko/actions/actors/MoveGardenerAction::execute → KILLED
        return new ActionResult(1);
74
    }
75
76
    @Override
77
    public boolean equals(Object o) {
78 2 1. equals : negated conditional → NO_COVERAGE
2. equals : replaced boolean return with false for com/takenoko/actions/actors/MoveGardenerAction::equals → NO_COVERAGE
        if (this == o) return true;
79 3 1. equals : negated conditional → NO_COVERAGE
2. equals : negated conditional → NO_COVERAGE
3. equals : replaced boolean return with true for com/takenoko/actions/actors/MoveGardenerAction::equals → NO_COVERAGE
        if (o == null || getClass() != o.getClass()) return false;
80
        MoveGardenerAction that = (MoveGardenerAction) o;
81 2 1. equals : replaced boolean return with false for com/takenoko/actions/actors/MoveGardenerAction::equals → NO_COVERAGE
2. equals : replaced boolean return with true for com/takenoko/actions/actors/MoveGardenerAction::equals → NO_COVERAGE
        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/MoveGardenerAction::hashCode → SURVIVED
        return Objects.hash(relativePositionVector);
87
    }
88
}

Mutations

29

1.1
Location : canBePlayed
Killed by : com.takenoko.actions.actors.MoveGardenerActionTest.[engine:junit-jupiter]/[class:com.takenoko.actions.actors.MoveGardenerActionTest]/[nested-class:TestCanBePlayed]/[method:shouldReturnTrueIfGardenerCanMove()]
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/MoveGardenerAction::canBePlayed → KILLED

45

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

53

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

54

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

57

1.1
Location : execute
Killed by : com.takenoko.actions.actors.MoveGardenerActionTest.[engine:junit-jupiter]/[class:com.takenoko.actions.actors.MoveGardenerActionTest]/[nested-class:TestExecute]/[method:shouldUpdatePlantedBambooCounterAndActionsInSingleBotStatistics()]
removed call to java/util/Map::forEach → KILLED

59

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

67

1.1
Location : lambda$execute$0
Killed by : com.takenoko.actions.actors.MoveGardenerActionTest.[engine:junit-jupiter]/[class:com.takenoko.actions.actors.MoveGardenerActionTest]/[nested-class:TestExecute]/[method:shouldUpdatePlantedBambooCounterAndActionsInSingleBotStatistics()]
removed call to com/takenoko/stats/SingleBotStatistics::updatePlantedBambooCounter → KILLED

71

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

73

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/MoveGardenerAction::execute → KILLED

78

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

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

79

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

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

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

81

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

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

86

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

Active mutators

Tests examined


Report generated by PIT 1.8.0