-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHeapBot.java
More file actions
42 lines (31 loc) · 1.2 KB
/
HeapBot.java
File metadata and controls
42 lines (31 loc) · 1.2 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
// This Java API uses camelCase instead of the snake_case as documented in the API docs.
// Otherwise the names of methods are consistent.
import hlt.Command;
import hlt.Game;
import java.util.ArrayList;
import java.util.Random;
public class HeapBot {
public static void main(final String[] args) {
final long rngSeed;
if (args.length > 1) {
rngSeed = Integer.parseInt(args[1]);
} else {
rngSeed = System.nanoTime();
}
final Random rng = new Random(rngSeed);
Game game = new Game();
// At this point "game" variable is populated with initial map data.
// This is a good place to do computationally expensive start-up pre-processing.
// As soon as you call "ready" function below, the 2 second per turn timer will start.
HeapStrategy heapStrategy = new HeapStrategy(game, rng);
game.ready("HeapBot");
for (;;) {
game.updateFrame();
if (game.turnNumber % 200 == 0) {
HeapStrategy.generateHeap(game.gameMap);
}
ArrayList<Command> commandQueue = heapStrategy.getCommand();
game.endTurn(commandQueue);
}
}
}