Minor changes
This commit is contained in:
parent
451856be1b
commit
4d4d5b1481
1 changed files with 3 additions and 2 deletions
|
@ -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
|
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
|
# Choose an action
|
||||||
|
action=random.choice((0,1,2,3))
|
||||||
if np.max(qtable[state]) > 0:
|
if np.max(qtable[state]) > 0:
|
||||||
action = np.argmax(qtable[state])
|
action = np.argmax(qtable[state])
|
||||||
else:
|
|
||||||
action=random.choice((0,1,2,3))
|
print(np.max(qtable[state]))
|
||||||
|
|
||||||
# Update current state Q
|
# Update current state Q
|
||||||
if last_state != None:
|
if last_state != None:
|
||||||
|
|
Loading…
Add table
Reference in a new issue