Don't run off the edge
This commit is contained in:
parent
72ea0126f7
commit
6d748d395f
|
@ -1,4 +1,3 @@
|
|||
import logging
|
||||
import os
|
||||
|
||||
from fastapi import FastAPI, Request
|
||||
|
@ -41,5 +40,3 @@ async def identify_server(request: Request, call_next):
|
|||
response = await call_next(request)
|
||||
response.headers["server"] = "shillerben/gitea/starter-snake-python"
|
||||
return response
|
||||
|
||||
logging.getLogger("werkzeug").setLevel(logging.ERROR)
|
||||
|
|
|
@ -49,8 +49,16 @@ class StarterSnake(Snake):
|
|||
is_move_safe["up"] = False
|
||||
|
||||
# TODO: Step 1 - Prevent your Battlesnake from moving out of bounds
|
||||
# board_width = game_state['board']['width']
|
||||
# board_height = game_state['board']['height']
|
||||
board_width = game_state.board.width
|
||||
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
|
||||
# my_body = game_state['you']['body']
|
||||
|
|
Loading…
Reference in New Issue
Block a user