add history to existing snakes
This commit is contained in:
+5
-1
@@ -1,6 +1,8 @@
|
||||
from snakes.TemplateSnake import TemplateSnake
|
||||
|
||||
import random
|
||||
|
||||
class DummSnake:
|
||||
class DummSnake(TemplateSnake):
|
||||
def choose_move(self, data: dict) -> str:
|
||||
is_move_safe = {"up": True, "down": True, "left": True, "right": True}
|
||||
|
||||
@@ -38,6 +40,7 @@ class DummSnake:
|
||||
|
||||
if len(safe_moves) == 0:
|
||||
print(f"MOVE {data['turn']}: No safe moves detected! Moving down")
|
||||
self.add_to_history({"my_head": my_head, "my_neck": my_neck, "move": move, "safe_moves": safe_moves, "is_move_safe": is_move_safe})
|
||||
return {"move": "down"}
|
||||
|
||||
# Choose a random move from the safe ones
|
||||
@@ -46,6 +49,7 @@ class DummSnake:
|
||||
# TODO: Step 4 - Move towards food instead of random, to regain health and survive longer
|
||||
# food = game_state['board']['food']
|
||||
|
||||
self.add_to_history({"my_head": my_head, "my_neck": my_neck, "move": move, "safe_moves": safe_moves, "is_move_safe": is_move_safe})
|
||||
print(f"{data['game']['id']} MOVE {data['turn']}: {move} picked from all valid options in {is_move_safe}")
|
||||
|
||||
return move
|
||||
|
||||
Reference in New Issue
Block a user