-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNewRad.java
79 lines (60 loc) · 1.89 KB
/
NewRad.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
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 NewRad implements PlayerBot
{
@Override public void getNextCommands(UniverseView universeView, List<MovementCommand> list)
{
long troops;
long mine;
long go[] = new long[4];
/* 0 - UP
1 - LEFT
2 - DOWN
3 - RIGHT */
for (Coordinates c : universeView.getMyCells()) {
mine = universeView.getPopulation(c);
troops = mine;
if(troops>=25){
troops-=5;
troops = troops/4;
if(troops<5) continue;
if( universeView.isEmpty(c.getUp()) || !universeView.belongsToMe(c.getUp())){
go[0] = troops;
}else if(universeView.getPopulation(c.getUp()) < mine){
go[0] = troops;
}else{
go[0] = 0;
}
if( universeView.isEmpty(c.getLeft()) || !universeView.belongsToMe(c.getLeft())){
go[1] = troops;
}else if(universeView.getPopulation(c.getLeft()) < mine){
go[1] = troops;
}else{
go[1] = 0;
}
if( universeView.isEmpty(c.getDown()) || !universeView.belongsToMe(c.getDown())){
go[2] = troops;
}else if(universeView.getPopulation(c.getDown()) < mine){
go[2] = troops;
}else{
go[2] = 0;
}
if( universeView.isEmpty(c.getRight()) || !universeView.belongsToMe(c.getRight())){
go[3] = troops;
}else if(universeView.getPopulation(c.getRight()) < mine){
go[3] = troops;
}else{
go[3] = 0;
}
list.add(new MovementCommand(c,MovementCommand.Direction.UP, go[0]));
list.add(new MovementCommand(c,MovementCommand.Direction.LEFT, go[1]));
list.add(new MovementCommand(c,MovementCommand.Direction.DOWN, go[2]));
list.add(new MovementCommand(c,MovementCommand.Direction.RIGHT, go[3]));
}
}
}
}