From 4d4d5b1481f366f70f5fd4a97e3afbed3b9a28dd Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Tue, 1 Nov 2022 17:34:15 +0100 Subject: [PATCH] Minor changes --- qlearning.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/qlearning.py b/qlearning.py index 60775e3..492039d 100755 --- a/qlearning.py +++ b/qlearning.py @@ -76,10 +76,11 @@ def event_handler(game,event): state=2**11*snake_go_up+2**10*snake_go_right+2**9*snake_go_down+2**8*snake_go_left+2**7*apple_up+2**6*apple_right+2**5*apple_down+2**4*apple_left+2**3*obstacle_up+2**2*obstacle_right+2**1*obstacle_down+obstacle_left # Choose an action + action=random.choice((0,1,2,3)) if np.max(qtable[state]) > 0: action = np.argmax(qtable[state]) - else: - action=random.choice((0,1,2,3)) + + print(np.max(qtable[state])) # Update current state Q if last_state != None: