summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2022-11-01 14:28:00 +0100
committerLoic Guegan <manzerbredes@mailbox.org>2022-11-01 14:28:00 +0100
commit10e9cb1056a4ad1c5eee9c4a58ddb2b94e5fc746 (patch)
treecc4292c0487dcedd1d3c78a78b73101cb030cb4b
parent67a79a65dd938019ce13b8f616d320548bb273e7 (diff)
Minor changes
-rw-r--r--__pycache__/snake.cpython-310.pycbin0 -> 5439 bytes
-rwxr-xr-xqlearning.py23
2 files changed, 23 insertions, 0 deletions
diff --git a/__pycache__/snake.cpython-310.pyc b/__pycache__/snake.cpython-310.pyc
new file mode 100644
index 0000000..53436e3
--- /dev/null
+++ b/__pycache__/snake.cpython-310.pyc
Binary files 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