Minor changes

This commit is contained in:
Loic Guegan 2022-11-01 17:07:09 +01:00
parent 4f113282d7
commit d2f75ae502
2 changed files with 8 additions and 12 deletions

View file

@ -38,7 +38,6 @@ def isWall(h,game):
return(True) return(True)
return(False) return(False)
def event_handler(game,event): def event_handler(game,event):
h=game.snake[0] h=game.snake[0]
left=(h[0]-1,h[1]) left=(h[0]-1,h[1])
@ -62,6 +61,14 @@ def event_handler(game,event):
obstacle_down=(down in game.snake or isWall(down, game)) obstacle_down=(down in game.snake or isWall(down, game))
obstacle_left=(left in game.snake or isWall(left, game)) obstacle_left=(left in game.snake or isWall(left, game))
reward=0
if event==1:
reward=1
elif event==-1:
reward=-10
state=2048*snake_go_up
if game.snake[0][0]==10: if game.snake[0][0]==10:
game.direction=6 game.direction=6

View file

@ -168,14 +168,3 @@ class Snake:
pygame.display.flip() pygame.display.flip()
clock.tick(self.fps) clock.tick(self.fps)
return(self.score) return(self.score)
game=Snake()
def event_handler(game):
if game.snake[0][0]==10:
game.direction=6
for i in range(0,10):
score=game.run()
print("Game ended with "+str(score))