-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBot.java
98 lines (88 loc) · 2.13 KB
/
Bot.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**
* Provides basic game state handling.
*/
public abstract class Bot extends AbstractSystemInputParser {
private Ants ants;
/**
* {@inheritDoc}
*/
@Override
public void setup(int loadTime, int turnTime, int rows, int cols, int turns, int viewRadius2,
int attackRadius2, int spawnRadius2) {
setAnts(new Ants(loadTime, turnTime, rows, cols, turns, viewRadius2, attackRadius2,
spawnRadius2));
}
/**
* Returns game state information.
*
* @return game state information
*/
public Ants getAnts() {
return ants;
}
/**
* Sets game state information.
*
* @param ants game state information to be set
*/
protected void setAnts(Ants ants) {
this.ants = ants;
}
/**
* {@inheritDoc}
*/
@Override
public void beforeUpdate() {
ants.setTurnStartTime(System.currentTimeMillis());
ants.clearMyAnts();
ants.clearEnemyAnts();
ants.clearMyHills();
ants.clearEnemyHills();
ants.clearFood();
ants.clearDeadAnts();
ants.getOrders().clear();
ants.clearVision();
}
/**
* {@inheritDoc}
*/
@Override
public void addWater(int row, int col) {
ants.update(Ilk.WATER, new Tile(row, col));
}
/**
* {@inheritDoc}
*/
@Override
public void addAnt(int row, int col, int owner) {
ants.update(owner > 0 ? Ilk.ENEMY_ANT : Ilk.MY_ANT, new Tile(row, col));
}
/**
* {@inheritDoc}
*/
@Override
public void addFood(int row, int col) {
ants.update(Ilk.FOOD, new Tile(row, col));
}
/**
* {@inheritDoc}
*/
@Override
public void removeAnt(int row, int col, int owner) {
ants.update(Ilk.DEAD, new Tile(row, col));
}
/**
* {@inheritDoc}
*/
@Override
public void addHill(int row, int col, int owner) {
ants.updateHills(owner, new Tile(row, col));
}
/**
* {@inheritDoc}
*/
@Override
public void afterUpdate() {
ants.setVision();
}
}