Skip to content

Commit 4e74fbc

Browse files
authoredNov 19, 2018
solved movement
Solved a bug in final_move, so that the model can now turn properly.
1 parent 1e0a2a9 commit 4e74fbc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎snakeClass.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,11 @@ def run():
196196

197197
#perform random actions based on agent.epsilon, or choose the action
198198
if randint(0, 200) < agent.epsilon:
199-
final_move = to_categorical(randint(0, 2), num_classes=3)[0]
199+
final_move = to_categorical(randint(0, 2), num_classes=3)
200200
else:
201201
# predict action based on the old state
202202
prediction = agent.model.predict(state_old.reshape((1,11)))
203-
final_move = to_categorical(np.argmax(prediction[0]), num_classes=3)[0]
203+
final_move = to_categorical(np.argmax(prediction[0]), num_classes=3)
204204

205205
#perform new move and get new state
206206
player1.do_move(final_move, player1.x, player1.y, game, food1, agent)

0 commit comments

Comments
 (0)
Please sign in to comment.