-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRadExp.java
84 lines (58 loc) · 1.71 KB
/
RadExp.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
import cern.ais.gridwars.Coordinates;
import cern.ais.gridwars.UniverseView;
import cern.ais.gridwars.bot.PlayerBot;
import cern.ais.gridwars.command.MovementCommand;
import java.lang.Long;
import java.util.List;
public class RadExp implements PlayerBot
{
@Override public void getNextCommands(UniverseView universeView, List<MovementCommand> list)
{
long mine;
long troops;
long counter;
char go[] = new char[4];
for (Coordinates c : universeView.getMyCells()) {
mine = universeView.getPopulation(c);
troops = mine;
/* Breeding Base: */
troops-=5;
if(troops<=0) continue;
go[0]=0;
go[1]=0;
go[2]=0;
go[3]=0;
counter = 0;
if((!universeView.belongsToMe(c.getUp())) || universeView.getPopulation(c.getUp()) < mine ){
counter++;
go[0]++;
}
if((!universeView.belongsToMe(c.getLeft())) || universeView.getPopulation(c.getLeft()) < mine ){
counter++;
go[1]++;
}
if((!universeView.belongsToMe(c.getDown())) || universeView.getPopulation(c.getDown()) < mine ){
counter++;
go[2]++;
}
if((!universeView.belongsToMe(c.getRight())) || universeView.getPopulation(c.getRight()) < mine ){
counter++;
go[3]++;
}
troops = troops / counter;
if(troops<5) continue;
if(go[3]==1){
list.add(new MovementCommand(c,MovementCommand.Direction.RIGHT, troops));
}
if(go[2]==1){
list.add(new MovementCommand(c,MovementCommand.Direction.DOWN, troops));
}
if(go[1]==1){
list.add(new MovementCommand(c,MovementCommand.Direction.LEFT, troops));
}
if(go[0]==1){
list.add(new MovementCommand(c,MovementCommand.Direction.UP, troops));
}
}
}
}