Skip to content
Permalink
Browse files

move to tail

  • Loading branch information...
kssilveira committed Mar 9, 2019
1 parent 0d029d1 commit f1332420aa7038aeb91b2d1fee7fc04e32619331
Showing with 16 additions and 10 deletions.
  1. +16 −10 app/main.py
@@ -77,7 +77,8 @@ def __init__(self, data):
body = you['body']
self.health = you['health']
self.head = body[0]
for part in body:
self.tail = body[-1]
for part in body[:-1]:
self.board[part['y']][part['x']] = 1

def adjacent(self, x, y):
@@ -123,6 +124,13 @@ def move_to_free(self):
print 'no direction'
return 'up'

def move_to_tail(self, moves):
x = self.tail['x']
y = self.tail['y']
res = moves[y][x]
print 'x', x, 'y', y, 'res', res
return res

def move_to_food(self, distances, moves):
res = 'up'
mindist = sys.maxint
@@ -155,19 +163,17 @@ def move():

# import pdb; pdb.set_trace()

direction = game.move_to_free()
distances, moves = game.distances(game.head['x'], game.head['y'])

if game.health <= 50:
distances, moves = game.distances(game.head['x'], game.head['y'])
print 'distances'
pprint.pprint(distances)

print 'distances'
pprint.pprint(distances)

# print 'moves'
# pprint.pprint(moves)
# print 'moves'
# pprint.pprint(moves)

direction = game.move_to_tail(moves)
if False and game.health <= 50:
direction = game.move_to_food(distances, moves)

return move_response(direction)

@bottle.post('/end')

0 comments on commit f133242

Please sign in to comment.
You can’t perform that action at this time.