1 | package com.takenoko.bot.unitary; | |
2 | ||
3 | import com.takenoko.actions.objective.DrawObjectiveAction; | |
4 | import com.takenoko.actions.objective.RedeemObjectiveAction; | |
5 | import com.takenoko.bot.PriorityBot; | |
6 | import com.takenoko.bot.utils.HistoryAnalysis; | |
7 | import com.takenoko.engine.Board; | |
8 | import com.takenoko.engine.BotState; | |
9 | import com.takenoko.engine.GameEngine; | |
10 | import com.takenoko.engine.History; | |
11 | import com.takenoko.objective.EmperorObjective; | |
12 | import com.takenoko.objective.Objective; | |
13 | import com.takenoko.objective.ObjectiveType; | |
14 | import com.takenoko.objective.PandaObjective; | |
15 | import java.util.List; | |
16 | ||
17 | public class SmartObjective extends PriorityBot { | |
18 | private static final int ARBITRARY_MARGIN = 0; | |
19 | ||
20 | @Override | |
21 | protected void fillAction(Board board, BotState botState, History history) { | |
22 |
1
1. fillAction : removed call to com/takenoko/bot/unitary/SmartObjective::addActionWithPriority → TIMED_OUT |
this.addActionWithPriority(analyzeObjectivesToRedeem(botState, history), DEFAULT_PRIORITY); |
23 | ||
24 |
1
1. fillAction : negated conditional → TIMED_OUT |
if (board.hasObjectiveTypeInDeck(ObjectiveType.PANDA)) { |
25 |
1
1. fillAction : removed call to com/takenoko/bot/unitary/SmartObjective::addActionWithPriority → TIMED_OUT |
this.addActionWithPriority( |
26 | new DrawObjectiveAction(ObjectiveType.PANDA), DEFAULT_PRIORITY); | |
27 | } | |
28 |
1
1. fillAction : negated conditional → TIMED_OUT |
if (board.hasObjectiveTypeInDeck(ObjectiveType.GARDENER)) { |
29 |
1
1. fillAction : removed call to com/takenoko/bot/unitary/SmartObjective::addActionWithPriority → TIMED_OUT |
this.addActionWithPriority( |
30 | new DrawObjectiveAction(ObjectiveType.GARDENER), DEFAULT_PRIORITY); | |
31 | } | |
32 |
1
1. fillAction : negated conditional → TIMED_OUT |
if (board.hasObjectiveTypeInDeck(ObjectiveType.SHAPE)) { |
33 |
1
1. fillAction : removed call to com/takenoko/bot/unitary/SmartObjective::addActionWithPriority → TIMED_OUT |
this.addActionWithPriority( |
34 | new DrawObjectiveAction(ObjectiveType.SHAPE), DEFAULT_PRIORITY); | |
35 | } | |
36 | ||
37 | botState.getAchievedObjectives().stream() | |
38 |
2
1. lambda$fillAction$0 : negated conditional → TIMED_OUT 2. lambda$fillAction$0 : replaced boolean return with true for com/takenoko/bot/unitary/SmartObjective::lambda$fillAction$0 → TIMED_OUT |
.filter(v -> v.getClass() != PandaObjective.class) |
39 |
1
1. fillAction : removed call to java/util/stream/Stream::forEach → TIMED_OUT |
.forEach( |
40 | v -> | |
41 |
1
1. lambda$fillAction$1 : removed call to com/takenoko/bot/unitary/SmartObjective::addActionWithPriority → TIMED_OUT |
this.addActionWithPriority( |
42 | new RedeemObjectiveAction(v), DEFAULT_PRIORITY)); | |
43 | } | |
44 | ||
45 | public RedeemObjectiveAction analyzeObjectivesToRedeem(BotState botState, History history) { | |
46 | /* | |
47 | * If we have only one panda objective, do not redeem it | |
48 | * If we have any other objective, redeem any of them | |
49 | */ | |
50 | List<Objective> pandaObjectives = | |
51 | botState.getAchievedObjectives().stream() | |
52 | .filter(PandaObjective.class::isInstance) | |
53 | .toList(); | |
54 | ||
55 | // If we have two PandaObjective we redeem one | |
56 |
2
1. analyzeObjectivesToRedeem : changed conditional boundary → TIMED_OUT 2. analyzeObjectivesToRedeem : negated conditional → KILLED |
if (pandaObjectives.size() > 1) { |
57 |
1
1. analyzeObjectivesToRedeem : replaced return value with null for com/takenoko/bot/unitary/SmartObjective::analyzeObjectivesToRedeem → TIMED_OUT |
return new RedeemObjectiveAction(pandaObjectives.get(0)); |
58 | } | |
59 | ||
60 | // If when we redeem an objective, and it does not make us win we don't redeem | |
61 |
1
1. analyzeObjectivesToRedeem : Replaced integer addition with subtraction → TIMED_OUT |
if (botState.getRedeemedObjectives().size() + 1 |
62 |
2
1. analyzeObjectivesToRedeem : changed conditional boundary → TIMED_OUT 2. analyzeObjectivesToRedeem : negated conditional → TIMED_OUT |
< GameEngine.DEFAULT_NUMBER_OF_OBJECTIVES_TO_WIN.get(history.keySet().size())) { |
63 | return null; | |
64 | } | |
65 | ||
66 |
1
1. analyzeObjectivesToRedeem : negated conditional → TIMED_OUT |
if (pandaObjectives.size() == 1 |
67 | && pandaObjectives.get(0).getPoints() | |
68 |
2
1. analyzeObjectivesToRedeem : Replaced integer addition with subtraction → TIMED_OUT 2. analyzeObjectivesToRedeem : Replaced integer addition with subtraction → TIMED_OUT |
+ botState.getObjectiveScore() |
69 | + EmperorObjective.EMPEROR_BONUS | |
70 |
3
1. analyzeObjectivesToRedeem : changed conditional boundary → TIMED_OUT 2. analyzeObjectivesToRedeem : Replaced integer addition with subtraction → TIMED_OUT 3. analyzeObjectivesToRedeem : negated conditional → TIMED_OUT |
> HistoryAnalysis.getMaxCurrentBotScore(history) + ARBITRARY_MARGIN) { |
71 |
1
1. analyzeObjectivesToRedeem : replaced return value with null for com/takenoko/bot/unitary/SmartObjective::analyzeObjectivesToRedeem → TIMED_OUT |
return new RedeemObjectiveAction(pandaObjectives.get(0)); |
72 | } | |
73 | ||
74 | return null; | |
75 | } | |
76 | } | |
Mutations | ||
22 |
1.1 |
|
24 |
1.1 |
|
25 |
1.1 |
|
28 |
1.1 |
|
29 |
1.1 |
|
32 |
1.1 |
|
33 |
1.1 |
|
38 |
1.1 2.2 |
|
39 |
1.1 |
|
41 |
1.1 |
|
56 |
1.1 2.2 |
|
57 |
1.1 |
|
61 |
1.1 |
|
62 |
1.1 2.2 |
|
66 |
1.1 |
|
68 |
1.1 2.2 |
|
70 |
1.1 2.2 3.3 |
|
71 |
1.1 |