-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBot.java
More file actions
95 lines (84 loc) · 1.98 KB
/
Bot.java
File metadata and controls
95 lines (84 loc) · 1.98 KB
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
/**
* Provides basic game state handling.
*/
public abstract class Bot extends AbstractSystemInputParser {
protected 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.clearAnts();
ants.clearHills();
ants.clearFood();
ants.clearWater();
ants.getOrders().clear();
ants.clearVision();
}
/**
* {@inheritDoc}
*/
@Override
public void addWater(int row, int col) {
ants.updateWater(new Tile(row, col));
}
/**
* {@inheritDoc}
*/
@Override
public void addAnt(int row, int col, int owner) {
ants.updateAnts(owner, new Tile(row, col));
}
/**
* {@inheritDoc}
*/
@Override
public void addFood(int row, int col) {
ants.updateFood(new Tile(row, col));
}
/**
* {@inheritDoc}
*/
@Override
public void removeAnt(int row, int col, int owner) {
ants.updateDeadAnts(owner, 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();
}
}