snakeq/qlearning.py
2022-11-01 14:28:00 +01:00

23 lines
No EOL
320 B
Python
Executable file

#!/usr/bin/env python
import sys
import numpy as np
# Import snake game
from snake import Snake
# Setup QTable
qtable=np.zeros((16, 4))
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))