-
Notifications
You must be signed in to change notification settings - Fork 3
/
EmptyBot.py
64 lines (52 loc) · 1.89 KB
/
EmptyBot.py
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
#!/usr/bin/env python
#
""" EmptyBot - a skeleton of a bot that you can modify.
Overcommented for educational purposes.
"""
# Import the PlanetWars class from the PlanetWars module.
from PlanetWars import PlanetWars
def DoTurn(pw):
""" Function that gets called every turn.
This is where to implement the strategies.
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.py.
"""
# The source variable will contain the planet from which we send the ships.
# Create a source planet, if you want to know what this object does, then read the Planet
# class in PlanetWars.py.
source = None
# The dest variable will contain the destination, the planet to which we send the ships.
dest = None
#(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 the source and dest variables contain actual planets, then
# send half of the ships from source to dest.
if (not source is None and not dest is None) :
pw.IssueOrder(source, dest)
# Don't change from this point on. Also not necessary to understand all the details.
# Machinery that reads the status of the game and puts it into PlanetWars.
# It calls DoTurn.
def main():
map_data = ''
while(True):
current_line = raw_input()
if len(current_line) >= 2 and current_line.startswith("go"):
pw = PlanetWars(map_data)
DoTurn(pw)
pw.FinishTurn()
map_data = ''
else:
map_data += current_line + '\n'
if __name__ == '__main__':
try:
import psyco
psyco.full()
except ImportError:
pass
try:
main()
except KeyboardInterrupt:
print 'ctrl-c, leaving ...'