diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2022-11-01 14:28:00 +0100 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2022-11-01 14:28:00 +0100 |
| commit | 10e9cb1056a4ad1c5eee9c4a58ddb2b94e5fc746 (patch) | |
| tree | cc4292c0487dcedd1d3c78a78b73101cb030cb4b | |
| parent | 67a79a65dd938019ce13b8f616d320548bb273e7 (diff) | |
Minor changes
| -rw-r--r-- | __pycache__/snake.cpython-310.pyc | bin | 0 -> 5439 bytes | |||
| -rwxr-xr-x | qlearning.py | 23 |
2 files changed, 23 insertions, 0 deletions
diff --git a/__pycache__/snake.cpython-310.pyc b/__pycache__/snake.cpython-310.pyc Binary files differnew file mode 100644 index 0000000..53436e3 --- /dev/null +++ b/__pycache__/snake.cpython-310.pyc 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 |
