#Snake game with Q-learning AI

4 messages · Page 1 of 1 (latest)

fast depot
#

Can someone help me? I have made a snake game in python, and the game itself works. However, when i tried to add Q-learning to it, it broke and i have no clue why it did
(this is my first time using Q learning so i didn't expect much more but still annoying xD)
https://paste.pythondiscord.com/Q5JQ

wanton furnace
#

I mean one issue is that you're running the Q-learning loop without actually playing the game?

fast depot
# wanton furnace The game broke?

Yes, it gave an error message

   action = select_action(state)
            ^^^^^^^^^^^^^^^^^^^^
 File "c:\Users\jens4_1vw956y\OneDrive\vs code\Game Dev\snake.py", line 95, in select_action
   return np.argmax(Q[state_index])
                    ~^^^^^^^^^^^^^
IndexError: index 47 is out of bounds for axis 2 with size 4```