-
Notifications
You must be signed in to change notification settings - Fork 3
/
EmptyBot.java
67 lines (54 loc) · 1.56 KB
/
EmptyBot.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
import java.util.*;
/*
RandomBot - an example bot that picks up one of his planets and send half of the ships
from that planet to a random target planet.
Not a very clever bot, but showcases the functions that can be used.
Overcommented for educational purposes.
*/
public class EmptyBot {
/*
* Function that gets called every turn. This is where to implement the strategies.
*/
public static void DoTurn(PlanetWars pw) {
//notice that a PlanetWars object called pw is passed as a parameter which you could use
//if you want to know what this object does, then read PlanetWars.java
//create a source planet, if you want to know what this object does, then read Planet.java
Planet source = null;
//create a destination planet
Planet dest = null;
//(1) implement an algorithm to determine the source planet to send your ships from
//... code here
//(2) implement an algorithm to deterimen the destination planet to send your ships to
//... code here
//(3) Attack
if (source != null && dest != null) {
pw.IssueOrder(source, dest);
}
}
public static void main(String[] args) {
String line = "";
String message = "";
int c;
try {
while ((c = System.in.read()) >= 0) {
switch (c) {
case '\n':
if (line.equals("go")) {
PlanetWars pw = new PlanetWars(message);
DoTurn(pw);
pw.FinishTurn();
message = "";
} else {
message += line + "\n";
}
line = "";
break;
default:
line += (char) c;
break;
}
}
} catch (Exception e) {
}
}
}