|
1
|
|
package com.takenoko.objective; |
|
2
|
|
|
|
3
|
|
import com.takenoko.engine.Board; |
|
4
|
|
import com.takenoko.engine.BotState; |
|
5
|
|
import com.takenoko.vector.PositionVector; |
|
6
|
|
import java.util.*; |
|
7
|
|
import java.util.stream.Stream; |
|
8
|
|
|
|
9
|
|
/** Objective is to complete a certain number of single gardener objectives. */ |
|
10
|
|
public class MultipleGardenerObjective extends Objective { |
|
11
|
|
|
|
12
|
|
final SingleGardenerObjective objective; |
|
13
|
|
private final int numberOfTimes; |
|
14
|
|
|
|
15
|
|
public MultipleGardenerObjective( |
|
16
|
|
SingleGardenerObjective objective, int numberOfTimes, int points) { |
|
17
|
|
super(ObjectiveType.GARDENER, ObjectiveState.NOT_ACHIEVED, points); |
|
18
|
|
this.objective = objective; |
|
19
|
|
this.numberOfTimes = numberOfTimes; |
|
20
|
|
} |
|
21
|
|
|
|
22
|
|
public MultipleGardenerObjective( |
|
23
|
|
MultipleGardenerObjective multipleGardenerObjective, int points) { |
|
24
|
|
this( |
|
25
|
|
multipleGardenerObjective.objective.copy(), |
|
26
|
|
multipleGardenerObjective.numberOfTimes, |
|
27
|
|
points); |
|
28
|
|
} |
|
29
|
|
|
|
30
|
|
@Override |
|
31
|
|
public void verify(Board board, BotState botState) { |
|
32
|
2
1. verify : changed conditional boundary → KILLED
2. verify : negated conditional → KILLED
|
if (this.objective.getMatchingPositions(board).size() >= numberOfTimes) { |
|
33
|
|
this.state = ObjectiveState.ACHIEVED; |
|
34
|
|
} |
|
35
|
|
} |
|
36
|
|
|
|
37
|
|
@Override |
|
38
|
|
public void reset() { |
|
39
|
|
this.state = ObjectiveState.NOT_ACHIEVED; |
|
40
|
|
} |
|
41
|
|
|
|
42
|
|
@Override |
|
43
|
|
public MultipleGardenerObjective copy() { |
|
44
|
1
1. copy : replaced return value with null for com/takenoko/objective/MultipleGardenerObjective::copy → KILLED
|
return new MultipleGardenerObjective(this, 0); |
|
45
|
|
} |
|
46
|
|
|
|
47
|
|
@Override |
|
48
|
|
public float getCompletion(Board board, BotState botState) { |
|
49
|
|
// spotless:off |
|
50
|
|
List<Integer> bambooCounts = |
|
51
|
|
objective.getEligiblePositions(board).stream() |
|
52
|
1
1. lambda$getCompletion$0 : replaced int return with 0 for com/takenoko/objective/MultipleGardenerObjective::lambda$getCompletion$0 → SURVIVED
|
.sorted(Comparator.comparingInt(v -> board.getBambooAt((PositionVector) v).getBambooCount()) |
|
53
|
|
.reversed()) |
|
54
|
|
.limit(numberOfTimes) |
|
55
|
1
1. lambda$getCompletion$1 : replaced Integer return value with 0 for com/takenoko/objective/MultipleGardenerObjective::lambda$getCompletion$1 → KILLED
|
.map(v -> board.getBambooAt(v).getBambooCount()) |
|
56
|
|
.toList(); |
|
57
|
|
Stream<Integer> bambooCountFilled = |
|
58
|
|
Stream.concat( |
|
59
|
|
bambooCounts.stream(), |
|
60
|
1
1. getCompletion : Replaced long subtraction with addition → KILLED
|
Stream.generate(() -> 0).limit((long) numberOfTimes - bambooCounts.size())); |
|
61
|
1
1. getCompletion : replaced float return with 0.0f for com/takenoko/objective/MultipleGardenerObjective::getCompletion → KILLED
|
return 1 - ((float) bambooCountFilled |
|
62
|
2
1. lambda$getCompletion$3 : Replaced integer subtraction with addition → KILLED
2. lambda$getCompletion$3 : replaced Integer return value with 0 for com/takenoko/objective/MultipleGardenerObjective::lambda$getCompletion$3 → KILLED
|
.map(v -> Math.abs(v - objective.getTargetSize())) |
|
63
|
|
.reduce(0, Integer::sum) |
|
64
|
3
1. getCompletion : Replaced integer multiplication with division → KILLED
2. getCompletion : Replaced float division with multiplication → KILLED
3. getCompletion : Replaced float subtraction with addition → KILLED
|
/ (numberOfTimes * objective.getTargetSize())); |
|
65
|
|
// spotless:on |
|
66
|
|
} |
|
67
|
|
|
|
68
|
|
public List<PositionVector> getPositionsToComplete(Board board) { |
|
69
|
1
1. getPositionsToComplete : replaced return value with Collections.emptyList for com/takenoko/objective/MultipleGardenerObjective::getPositionsToComplete → TIMED_OUT
|
return objective.getPositionsToComplete(board); |
|
70
|
|
} |
|
71
|
|
|
|
72
|
|
@Override |
|
73
|
|
public boolean equals(Object o) { |
|
74
|
2
1. equals : replaced boolean return with false for com/takenoko/objective/MultipleGardenerObjective::equals → TIMED_OUT
2. equals : negated conditional → KILLED
|
if (this == o) return true; |
|
75
|
3
1. equals : negated conditional → KILLED
2. equals : negated conditional → KILLED
3. equals : replaced boolean return with true for com/takenoko/objective/MultipleGardenerObjective::equals → KILLED
|
if (o == null || getClass() != o.getClass()) return false; |
|
76
|
|
MultipleGardenerObjective that = (MultipleGardenerObjective) o; |
|
77
|
3
1. equals : negated conditional → KILLED
2. equals : negated conditional → KILLED
3. equals : replaced boolean return with true for com/takenoko/objective/MultipleGardenerObjective::equals → KILLED
|
return numberOfTimes == that.numberOfTimes && objective.equals(that.objective); |
|
78
|
|
} |
|
79
|
|
|
|
80
|
|
@Override |
|
81
|
|
public int hashCode() { |
|
82
|
1
1. hashCode : replaced int return with 0 for com/takenoko/objective/MultipleGardenerObjective::hashCode → KILLED
|
return Objects.hash(objective, numberOfTimes); |
|
83
|
|
} |
|
84
|
|
|
|
85
|
|
@Override |
|
86
|
|
public String toString() { |
|
87
|
1
1. toString : replaced return value with "" for com/takenoko/objective/MultipleGardenerObjective::toString → TIMED_OUT
|
return "Multiple Gardener Objective <" |
|
88
|
|
+ objective.toString() |
|
89
|
|
+ ", " |
|
90
|
|
+ numberOfTimes |
|
91
|
|
+ " times>"; |
|
92
|
|
} |
|
93
|
|
} |
| | Mutations |
| 32 |
|
1.1 Location : verify Killed by : com.takenoko.objective.MultipleGardenerObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.MultipleGardenerObjectiveTest]/[nested-class:TestVerify]/[method:verify_shouldReturnTrueWhenTheObjectiveIsCompleted()] changed conditional boundary → KILLED 2.2 Location : verify Killed by : com.takenoko.objective.MultipleGardenerObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.MultipleGardenerObjectiveTest]/[nested-class:TestVerify]/[method:verify_shouldReturnFalseWhenTheObjectiveIsNotCompleted()] negated conditional → KILLED
|
| 44 |
|
1.1 Location : copy Killed by : com.takenoko.objective.MultipleGardenerObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.MultipleGardenerObjectiveTest]/[nested-class:TestCopy]/[method:shouldReturnACopyOfTheObjective()] replaced return value with null for com/takenoko/objective/MultipleGardenerObjective::copy → KILLED
|
| 52 |
|
1.1 Location : lambda$getCompletion$0 Killed by : none replaced int return with 0 for com/takenoko/objective/MultipleGardenerObjective::lambda$getCompletion$0 → SURVIVED
|
| 55 |
|
1.1 Location : lambda$getCompletion$1 Killed by : com.takenoko.objective.MultipleGardenerObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.MultipleGardenerObjectiveTest]/[nested-class:TestGetCompletion]/[method:shouldReturnTheCompletionPercentageWhenTheObjectiveIsStarted()] replaced Integer return value with 0 for com/takenoko/objective/MultipleGardenerObjective::lambda$getCompletion$1 → KILLED
|
| 60 |
|
1.1 Location : getCompletion Killed by : com.takenoko.objective.MultipleGardenerObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.MultipleGardenerObjectiveTest]/[nested-class:TestGetCompletion]/[method:shouldReturnTheCompletionPercentageWhenTheObjectiveIsStarted()] Replaced long subtraction with addition → KILLED
|
| 61 |
|
1.1 Location : getCompletion Killed by : com.takenoko.objective.MultipleGardenerObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.MultipleGardenerObjectiveTest]/[nested-class:TestGetCompletion]/[method:shouldReturnTheCompletionPercentageWhenTheObjectiveIsStarted()] replaced float return with 0.0f for com/takenoko/objective/MultipleGardenerObjective::getCompletion → KILLED
|
| 62 |
|
1.1 Location : lambda$getCompletion$3 Killed by : com.takenoko.objective.MultipleGardenerObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.MultipleGardenerObjectiveTest]/[nested-class:TestGetCompletion]/[method:shouldReturnTheCompletionPercentageWhenTheObjectiveIsStarted()] Replaced integer subtraction with addition → KILLED 2.2 Location : lambda$getCompletion$3 Killed by : com.takenoko.objective.MultipleGardenerObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.MultipleGardenerObjectiveTest]/[nested-class:TestGetCompletion]/[method:shouldReturnTheCompletionPercentageWhenTheObjectiveIsNotStarted()] replaced Integer return value with 0 for com/takenoko/objective/MultipleGardenerObjective::lambda$getCompletion$3 → KILLED
|
| 64 |
|
1.1 Location : getCompletion Killed by : com.takenoko.objective.MultipleGardenerObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.MultipleGardenerObjectiveTest]/[nested-class:TestGetCompletion]/[method:shouldReturnTheCompletionPercentageWhenTheObjectiveIsNotStarted()] Replaced integer multiplication with division → KILLED 2.2 Location : getCompletion Killed by : com.takenoko.objective.MultipleGardenerObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.MultipleGardenerObjectiveTest]/[nested-class:TestGetCompletion]/[method:shouldReturnTheCompletionPercentageWhenTheObjectiveIsNotStarted()] Replaced float division with multiplication → KILLED 3.3 Location : getCompletion Killed by : com.takenoko.objective.MultipleGardenerObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.MultipleGardenerObjectiveTest]/[nested-class:TestGetCompletion]/[method:shouldReturnTheCompletionPercentageWhenTheObjectiveIsNotStarted()] Replaced float subtraction with addition → KILLED
|
| 69 |
|
1.1 Location : getPositionsToComplete Killed by : none replaced return value with Collections.emptyList for com/takenoko/objective/MultipleGardenerObjective::getPositionsToComplete → TIMED_OUT
|
| 74 |
|
1.1 Location : equals Killed by : com.takenoko.objective.MultipleGardenerObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.MultipleGardenerObjectiveTest]/[nested-class:TestEquals]/[method:shouldReturnFalseWhenTheObjectIsNotEqual()] negated conditional → KILLED 2.2 Location : equals Killed by : none replaced boolean return with false for com/takenoko/objective/MultipleGardenerObjective::equals → TIMED_OUT
|
| 75 |
|
1.1 Location : equals Killed by : com.takenoko.objective.MultipleGardenerObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.MultipleGardenerObjectiveTest]/[nested-class:TestEquals]/[method:shouldReturnTrueWhenTheObjectIsEqual()] negated conditional → KILLED 2.2 Location : equals Killed by : com.takenoko.objective.MultipleGardenerObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.MultipleGardenerObjectiveTest]/[nested-class:TestEquals]/[method:shouldReturnTrueWhenTheObjectIsEqual()] negated conditional → KILLED 3.3 Location : equals Killed by : com.takenoko.objective.MultipleGardenerObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.MultipleGardenerObjectiveTest]/[nested-class:TestEquals]/[method:shouldReturnFalseWhenTheObjectIsNotAnInstanceOfMultipleGardenerObjective()] replaced boolean return with true for com/takenoko/objective/MultipleGardenerObjective::equals → KILLED
|
| 77 |
|
1.1 Location : equals Killed by : com.takenoko.objective.MultipleGardenerObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.MultipleGardenerObjectiveTest]/[nested-class:TestEquals]/[method:shouldReturnFalseWhenTheObjectIsNotEqual()] negated conditional → KILLED 2.2 Location : equals Killed by : com.takenoko.objective.MultipleGardenerObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.MultipleGardenerObjectiveTest]/[nested-class:TestEquals]/[method:shouldReturnTrueWhenTheObjectIsEqual()] negated conditional → KILLED 3.3 Location : equals Killed by : com.takenoko.objective.MultipleGardenerObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.MultipleGardenerObjectiveTest]/[nested-class:TestEquals]/[method:shouldReturnFalseWhenTheObjectIsNotEqual()] replaced boolean return with true for com/takenoko/objective/MultipleGardenerObjective::equals → KILLED
|
| 82 |
|
1.1 Location : hashCode Killed by : com.takenoko.objective.MultipleGardenerObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.MultipleGardenerObjectiveTest]/[nested-class:TestHashCode]/[method:shouldReturnADifferentHashCodeWhenTheObjectIsNotEqual()] replaced int return with 0 for com/takenoko/objective/MultipleGardenerObjective::hashCode → KILLED
|
| 87 |
|
1.1 Location : toString Killed by : none replaced return value with "" for com/takenoko/objective/MultipleGardenerObjective::toString → TIMED_OUT
|