PandaObjective.java

1
package com.takenoko.objective;
2
3
import com.takenoko.engine.Board;
4
import com.takenoko.engine.BotState;
5
import com.takenoko.layers.tile.TileColor;
6
import com.takenoko.vector.PositionVector;
7
import java.util.EnumMap;
8
import java.util.List;
9
import java.util.Map;
10
import java.util.Objects;
11
12
/** The Panda objective. */
13
public class PandaObjective extends Objective {
14
    private final Map<TileColor, Integer> bambooTarget;
15
16
    public PandaObjective(Map<TileColor, Integer> bambooTarget, int points) {
17
        super(ObjectiveType.PANDA, ObjectiveState.NOT_ACHIEVED, points);
18
        this.bambooTarget = bambooTarget;
19 1 1. <init> : negated conditional → KILLED
        if (bambooTarget.isEmpty()) {
20
            throw new IllegalArgumentException("The bamboo target cannot be empty");
21
        }
22
    }
23
24
    public PandaObjective(PandaObjective pandaObjective) {
25
        super(pandaObjective.getType(), pandaObjective.getState(), pandaObjective.getPoints());
26
        this.bambooTarget = new EnumMap<>(TileColor.class);
27 1 1. <init> : removed call to java/util/Map::putAll → NO_COVERAGE
        this.bambooTarget.putAll(pandaObjective.bambooTarget);
28
    }
29
30
    @Override
31
    public void verify(Board board, BotState botState) {
32
        boolean matched =
33
                bambooTarget.entrySet().stream()
34
                        .allMatch(
35
                                entry ->
36 1 1. lambda$verify$0 : replaced boolean return with true for com/takenoko/objective/PandaObjective::lambda$verify$0 → KILLED
                                        botState.getInventory().getBambooCount(entry.getKey())
37 2 1. lambda$verify$0 : changed conditional boundary → KILLED
2. lambda$verify$0 : negated conditional → KILLED
                                                >= entry.getValue());
38 1 1. verify : negated conditional → KILLED
        if (matched) {
39
            state = ObjectiveState.ACHIEVED;
40
        } else state = ObjectiveState.NOT_ACHIEVED;
41
    }
42
43
    @Override
44
    public void reset() {
45
        state = ObjectiveState.NOT_ACHIEVED;
46
    }
47
48
    @Override
49
    public Objective copy() {
50 1 1. copy : replaced return value with null for com/takenoko/objective/PandaObjective::copy → NO_COVERAGE
        return new PandaObjective(this);
51
    }
52
53
    @Override
54
    public float getCompletion(Board board, BotState botState) {
55 1 1. getCompletion : replaced float return with 0.0f for com/takenoko/objective/PandaObjective::getCompletion → KILLED
        return bambooTarget.entrySet().stream()
56
                        .map(
57
                                entry ->
58 1 1. lambda$getCompletion$1 : replaced Float return value with 0 for com/takenoko/objective/PandaObjective::lambda$getCompletion$1 → KILLED
                                        (float)
59
                                                        botState.getInventory()
60
                                                                .getBambooCount(entry.getKey())
61 1 1. lambda$getCompletion$1 : Replaced float division with multiplication → TIMED_OUT
                                                / entry.getValue())
62
                        .reduce(0f, Float::sum)
63 1 1. getCompletion : Replaced float division with multiplication → KILLED
                / bambooTarget.size();
64
    }
65
66
    public List<PositionVector> getWhereToEatToComplete(Board board, BotState botState) {
67 1 1. getWhereToEatToComplete : replaced return value with Collections.emptyList for com/takenoko/objective/PandaObjective::getWhereToEatToComplete → KILLED
        return board.getTiles().entrySet().stream()
68
                .filter(
69
                        positionVectorTileEntry ->
70 2 1. lambda$getWhereToEatToComplete$3 : replaced boolean return with false for com/takenoko/objective/PandaObjective::lambda$getWhereToEatToComplete$3 → KILLED
2. lambda$getWhereToEatToComplete$3 : replaced boolean return with true for com/takenoko/objective/PandaObjective::lambda$getWhereToEatToComplete$3 → KILLED
                                bambooTarget.entrySet().stream()
71
                                        .anyMatch(
72
                                                entry ->
73 2 1. lambda$getWhereToEatToComplete$2 : negated conditional → KILLED
2. lambda$getWhereToEatToComplete$2 : replaced boolean return with true for com/takenoko/objective/PandaObjective::lambda$getWhereToEatToComplete$2 → KILLED
                                                        board.isBambooEatableAt(
74
                                                                        positionVectorTileEntry
75
                                                                                .getKey())
76
                                                                && positionVectorTileEntry
77
                                                                                .getValue()
78
                                                                                .getColor()
79 1 1. lambda$getWhereToEatToComplete$2 : negated conditional → KILLED
                                                                        == entry.getKey()
80
                                                                && botState.getInventory()
81
                                                                                .getBambooCount(
82
                                                                                        entry
83
                                                                                                .getKey())
84 2 1. lambda$getWhereToEatToComplete$2 : changed conditional boundary → KILLED
2. lambda$getWhereToEatToComplete$2 : negated conditional → KILLED
                                                                        < entry.getValue()))
85
                .map(Map.Entry::getKey)
86
                .toList();
87
    }
88
89
    @Override
90
    public boolean equals(Object o) {
91 2 1. equals : negated conditional → TIMED_OUT
2. equals : replaced boolean return with false for com/takenoko/objective/PandaObjective::equals → KILLED
        if (this == o) return true;
92 3 1. equals : replaced boolean return with true for com/takenoko/objective/PandaObjective::equals → TIMED_OUT
2. equals : negated conditional → KILLED
3. equals : negated conditional → KILLED
        if (o == null || getClass() != o.getClass()) return false;
93
        PandaObjective that = (PandaObjective) o;
94 2 1. equals : replaced boolean return with true for com/takenoko/objective/PandaObjective::equals → TIMED_OUT
2. equals : replaced boolean return with false for com/takenoko/objective/PandaObjective::equals → KILLED
        return Objects.equals(bambooTarget, that.bambooTarget);
95
    }
96
97
    @Override
98
    public int hashCode() {
99 1 1. hashCode : replaced int return with 0 for com/takenoko/objective/PandaObjective::hashCode → TIMED_OUT
        return Objects.hash(bambooTarget);
100
    }
101
102
    @Override
103
    public String toString() {
104 1 1. toString : replaced return value with "" for com/takenoko/objective/PandaObjective::toString → TIMED_OUT
        return "Panda Objective <" + bambooTarget + " high>";
105
    }
106
107
    public Map<TileColor, Integer> getBambooTarget() {
108 1 1. getBambooTarget : replaced return value with Collections.emptyMap for com/takenoko/objective/PandaObjective::getBambooTarget → TIMED_OUT
        return new EnumMap<>(bambooTarget);
109
    }
110
}

Mutations

19

1.1
Location : <init>
Killed by : com.takenoko.objective.PandaObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.PandaObjectiveTest]/[nested-class:TestGetCompletion]/[method:getCompletion_WhenObjectiveIsAchieved_ThenReturns1()]
negated conditional → KILLED

27

1.1
Location : <init>
Killed by : none
removed call to java/util/Map::putAll → NO_COVERAGE

36

1.1
Location : lambda$verify$0
Killed by : com.takenoko.objective.PandaObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.PandaObjectiveTest]/[nested-class:TestVerify]/[method:verify_WhenObjectiveIsNotAchieved_ThenReturnsNOT_ACHIEVED()]
replaced boolean return with true for com/takenoko/objective/PandaObjective::lambda$verify$0 → KILLED

37

1.1
Location : lambda$verify$0
Killed by : com.takenoko.objective.PandaObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.PandaObjectiveTest]/[nested-class:TestVerify]/[method:verify_WhenObjectiveIsAchieved_ThenReturnsACHIEVED()]
changed conditional boundary → KILLED

2.2
Location : lambda$verify$0
Killed by : com.takenoko.objective.PandaObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.PandaObjectiveTest]/[nested-class:TestVerify]/[method:verify_WhenObjectiveIsAchieved_ThenReturnsACHIEVED()]
negated conditional → KILLED

38

1.1
Location : verify
Killed by : com.takenoko.objective.PandaObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.PandaObjectiveTest]/[nested-class:TestVerify]/[method:verify_WhenObjectiveIsAchieved_ThenReturnsACHIEVED()]
negated conditional → KILLED

50

1.1
Location : copy
Killed by : none
replaced return value with null for com/takenoko/objective/PandaObjective::copy → NO_COVERAGE

55

1.1
Location : getCompletion
Killed by : com.takenoko.objective.PandaObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.PandaObjectiveTest]/[nested-class:TestGetCompletion]/[method:getCompletion_WhenObjectiveIsAchieved_ThenReturns1()]
replaced float return with 0.0f for com/takenoko/objective/PandaObjective::getCompletion → KILLED

58

1.1
Location : lambda$getCompletion$1
Killed by : com.takenoko.objective.PandaObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.PandaObjectiveTest]/[nested-class:TestGetCompletion]/[method:getCompletion_WhenObjectiveIsAchieved_ThenReturns1()]
replaced Float return value with 0 for com/takenoko/objective/PandaObjective::lambda$getCompletion$1 → KILLED

61

1.1
Location : lambda$getCompletion$1
Killed by : none
Replaced float division with multiplication → TIMED_OUT

63

1.1
Location : getCompletion
Killed by : com.takenoko.objective.PandaObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.PandaObjectiveTest]/[nested-class:TestGetCompletion]/[method:getCompletion_WhenObjectiveIsAchieved_ThenReturns1()]
Replaced float division with multiplication → KILLED

67

1.1
Location : getWhereToEatToComplete
Killed by : com.takenoko.objective.PandaObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.PandaObjectiveTest]/[nested-class:TestGetWhereToEatToComplete]/[method:getWhereToEatToComplete_WhenObjectiveIsNotAchievedAndThereIsOnlyOneBambooToEat_ThenReturnsCorrectList()]
replaced return value with Collections.emptyList for com/takenoko/objective/PandaObjective::getWhereToEatToComplete → KILLED

70

1.1
Location : lambda$getWhereToEatToComplete$3
Killed by : com.takenoko.objective.PandaObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.PandaObjectiveTest]/[nested-class:TestGetWhereToEatToComplete]/[method:getWhereToEatToComplete_WhenObjectiveIsNotAchievedAndThereIsOnlyOneBambooToEat_ThenReturnsCorrectList()]
replaced boolean return with false for com/takenoko/objective/PandaObjective::lambda$getWhereToEatToComplete$3 → KILLED

2.2
Location : lambda$getWhereToEatToComplete$3
Killed by : com.takenoko.objective.PandaObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.PandaObjectiveTest]/[nested-class:TestGetWhereToEatToComplete]/[method:getWhereToEatToComplete_WhenObjectiveIsAchieved_ThenReturnsEmptyList()]
replaced boolean return with true for com/takenoko/objective/PandaObjective::lambda$getWhereToEatToComplete$3 → KILLED

73

1.1
Location : lambda$getWhereToEatToComplete$2
Killed by : com.takenoko.objective.PandaObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.PandaObjectiveTest]/[nested-class:TestGetWhereToEatToComplete]/[method:getWhereToEatToComplete_WhenObjectiveIsNotAchievedAndThereIsOnlyOneBambooToEat_ThenReturnsCorrectList()]
negated conditional → KILLED

2.2
Location : lambda$getWhereToEatToComplete$2
Killed by : com.takenoko.objective.PandaObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.PandaObjectiveTest]/[nested-class:TestGetWhereToEatToComplete]/[method:getWhereToEatToComplete_WhenObjectiveIsAchieved_ThenReturnsEmptyList()]
replaced boolean return with true for com/takenoko/objective/PandaObjective::lambda$getWhereToEatToComplete$2 → KILLED

79

1.1
Location : lambda$getWhereToEatToComplete$2
Killed by : com.takenoko.objective.PandaObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.PandaObjectiveTest]/[nested-class:TestGetWhereToEatToComplete]/[method:getWhereToEatToComplete_WhenObjectiveIsNotAchieved_ThenReturnsCorrectList()]
negated conditional → KILLED

84

1.1
Location : lambda$getWhereToEatToComplete$2
Killed by : com.takenoko.objective.PandaObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.PandaObjectiveTest]/[nested-class:TestGetWhereToEatToComplete]/[method:getWhereToEatToComplete_WhenObjectiveIsAchieved_ThenReturnsEmptyList()]
changed conditional boundary → KILLED

2.2
Location : lambda$getWhereToEatToComplete$2
Killed by : com.takenoko.objective.PandaObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.PandaObjectiveTest]/[nested-class:TestGetWhereToEatToComplete]/[method:getWhereToEatToComplete_WhenObjectiveIsAchieved_ThenReturnsEmptyList()]
negated conditional → KILLED

91

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

2.2
Location : equals
Killed by : com.takenoko.bot.utils.HistoryAnalysisTest.[engine:junit-jupiter]/[class:com.takenoko.bot.utils.HistoryAnalysisTest]/[nested-class:IntegrationTest]/[method:test1()]
replaced boolean return with false for com/takenoko/objective/PandaObjective::equals → KILLED

92

1.1
Location : equals
Killed by : com.takenoko.bot.utils.pathfinding.panda.PandaPathfindingTest.[engine:junit-jupiter]/[class:com.takenoko.bot.utils.pathfinding.panda.PandaPathfindingTest]/[nested-class:GetPandaMoves]/[method:getPandaMoves()]
negated conditional → KILLED

2.2
Location : equals
Killed by : com.takenoko.bot.utils.pathfinding.panda.PandaPathfindingTest.[engine:junit-jupiter]/[class:com.takenoko.bot.utils.pathfinding.panda.PandaPathfindingTest]/[nested-class:GetPandaMoves]/[method:getPandaMoves()]
negated conditional → KILLED

3.3
Location : equals
Killed by : none
replaced boolean return with true for com/takenoko/objective/PandaObjective::equals → TIMED_OUT

94

1.1
Location : equals
Killed by : com.takenoko.bot.utils.pathfinding.panda.PandaPathfindingTest.[engine:junit-jupiter]/[class:com.takenoko.bot.utils.pathfinding.panda.PandaPathfindingTest]/[nested-class:GetPandaMoves]/[method:getPandaMoves()]
replaced boolean return with false for com/takenoko/objective/PandaObjective::equals → KILLED

2.2
Location : equals
Killed by : none
replaced boolean return with true for com/takenoko/objective/PandaObjective::equals → TIMED_OUT

99

1.1
Location : hashCode
Killed by : none
replaced int return with 0 for com/takenoko/objective/PandaObjective::hashCode → TIMED_OUT

104

1.1
Location : toString
Killed by : none
replaced return value with "" for com/takenoko/objective/PandaObjective::toString → TIMED_OUT

108

1.1
Location : getBambooTarget
Killed by : none
replaced return value with Collections.emptyMap for com/takenoko/objective/PandaObjective::getBambooTarget → TIMED_OUT

Active mutators

Tests examined


Report generated by PIT 1.8.0