This repository has been archived by the owner on Dec 3, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStarterBot.java
52 lines (40 loc) · 1.68 KB
/
StarterBot.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
import hlt.*;
import java.util.ArrayList;
public class StarterBot {
public static void main(final String[] args) {
final Networking networking = new Networking();
final GameMap gameMap = networking.initialize("StarterBot");
// We now have 1 full minute to analyse the initial map.
final String initialMapIntelligence =
"width: " + gameMap.getWidth() +
"; height: " + gameMap.getHeight() +
"; players: " + gameMap.getAllPlayers().size() +
"; planets: " + gameMap.getAllPlanets().size();
Log.log(initialMapIntelligence);
final ArrayList<Move> moveList = new ArrayList<>();
for (;;) {
moveList.clear();
networking.updateMap(gameMap);
for (final Ship ship : gameMap.getMyPlayer().getShips().values()) {
if (ship.getDockingStatus() != Ship.DockingStatus.Undocked) {
continue;
}
for (final Planet planet : gameMap.getAllPlanets().values()) {
if (planet.isOwned()) {
continue;
}
if (ship.canDock(planet)) {
moveList.add(new DockMove(ship, planet));
break;
}
final ThrustMove newThrustMove = Navigation.navigateShipToDock(gameMap, ship, planet, Constants.MAX_SPEED/2);
if (newThrustMove != null) {
moveList.add(newThrustMove);
}
break;
}
}
Networking.sendMoves(moveList);
}
}
}