#!/usr/bin/env python
"""
// The DoTurn function is where your code goes. The PlanetWars object contains
// the state of the game, including information about all planets and fleets
// that currently exist. Inside this function, you issue orders using the
// pw.IssueOrder() function. For example, to send 10 ships from planet 3 to
// planet 8, you would say pw.IssueOrder(3, 8, 10).
//
// There is already a basic strategy in place here. You can use it as a
// starting point, or you can throw it out entirely and replace it with your
// own. Check out the tutorials and articles on the contest website at
// http://www.ai-contest.com/resources.
"""
import PlanetWars.IO
import PlanetWars.doturn
def main():
f=open("log.txt","w")
map_data = ''
while(True):
current_line = raw_input()
f.write(current_line)
if len(current_line) >= 2 and current_line.startswith("go"):
currentState = PlanetWars.IO.ParseGameState(map_data)
PlanetWars.doturn.DoTurn( currentState )
PlanetWars.IO.FinishTurn()
map_data = ''
else:
map_data += current_line + '\n'
f.close()
if __name__ == '__main__':
try:
import psyco
psyco.full()
except ImportError:
pass
try:
main()
except KeyboardInterrupt:
print 'ctrl-c, leaving ...'