Fix simple bot
This commit is contained in:
parent
c0f31e61df
commit
440fc4fdec
1 changed files with 5 additions and 5 deletions
|
@ -1,7 +1,7 @@
|
||||||
import sys, json, random
|
import sys, json, random
|
||||||
|
|
||||||
def move(command):
|
def move(moves):
|
||||||
record = { 'moves': [command] }
|
record = {'moves': moves}
|
||||||
print(json.dumps(record))
|
print(json.dumps(record))
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
@ -13,12 +13,12 @@ for line in sys.stdin:
|
||||||
other_planets = [p for p in state['planets'] if p['owner'] != 1]
|
other_planets = [p for p in state['planets'] if p['owner'] != 1]
|
||||||
|
|
||||||
if not my_planets or not other_planets:
|
if not my_planets or not other_planets:
|
||||||
move(None)
|
move([])
|
||||||
else:
|
else:
|
||||||
planet = max(my_planets, key=lambda p: p['ship_count'])
|
planet = max(my_planets, key=lambda p: p['ship_count'])
|
||||||
dest = min(other_planets, key=lambda p: p['ship_count'])
|
dest = min(other_planets, key=lambda p: p['ship_count'])
|
||||||
move({
|
move([{
|
||||||
'origin': planet['name'],
|
'origin': planet['name'],
|
||||||
'destination': dest['name'],
|
'destination': dest['name'],
|
||||||
'ship_count': planet['ship_count'] - 1
|
'ship_count': planet['ship_count'] - 1
|
||||||
})
|
}])
|
||||||
|
|
Loading…
Reference in a new issue