Don't run off the edge

This commit is contained in:
Ben Shiller 2023-09-10 22:19:02 -05:00
parent 72ea0126f7
commit 6d748d395f
No known key found for this signature in database
GPG Key ID: DC46F01400846797
2 changed files with 10 additions and 5 deletions

View File

@ -1,4 +1,3 @@
import logging
import os import os
from fastapi import FastAPI, Request from fastapi import FastAPI, Request
@ -41,5 +40,3 @@ async def identify_server(request: Request, call_next):
response = await call_next(request) response = await call_next(request)
response.headers["server"] = "shillerben/gitea/starter-snake-python" response.headers["server"] = "shillerben/gitea/starter-snake-python"
return response return response
logging.getLogger("werkzeug").setLevel(logging.ERROR)

View File

@ -49,8 +49,16 @@ class StarterSnake(Snake):
is_move_safe["up"] = False is_move_safe["up"] = False
# TODO: Step 1 - Prevent your Battlesnake from moving out of bounds # TODO: Step 1 - Prevent your Battlesnake from moving out of bounds
# board_width = game_state['board']['width'] board_width = game_state.board.width
# board_height = game_state['board']['height'] board_height = game_state.board.height
if my_head.x == 0:
is_move_safe["left"] = False
elif my_head.x == board_width - 1:
is_move_safe["right"] = False
if my_head.y == 0:
is_move_safe["down"] = False
elif my_head.y == board_height - 1:
is_move_safe["up"] = False
# TODO: Step 2 - Prevent your Battlesnake from colliding with itself # TODO: Step 2 - Prevent your Battlesnake from colliding with itself
# my_body = game_state['you']['body'] # my_body = game_state['you']['body']