summaryrefslogtreecommitdiff
path: root/qlearning.py
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 /qlearning.py
parent67a79a65dd938019ce13b8f616d320548bb273e7 (diff)
Minor changes
Diffstat (limited to 'qlearning.py')
-rwxr-xr-xqlearning.py23
1 files changed, 23 insertions, 0 deletions
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