From 10e9cb1056a4ad1c5eee9c4a58ddb2b94e5fc746 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Tue, 1 Nov 2022 14:28:00 +0100 Subject: Minor changes --- __pycache__/snake.cpython-310.pyc | Bin 0 -> 5439 bytes qlearning.py | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 __pycache__/snake.cpython-310.pyc create mode 100755 qlearning.py diff --git a/__pycache__/snake.cpython-310.pyc b/__pycache__/snake.cpython-310.pyc new file mode 100644 index 0000000..53436e3 Binary files /dev/null and b/__pycache__/snake.cpython-310.pyc differ diff --git a/qlearning.py b/qlearning.py new file mode 100755 index 0000000..7834f6f --- /dev/null +++ b/qlearning.py @@ -0,0 +1,23 @@ +#!/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)) \ No newline at end of file -- cgit v1.2.3