Skip to content

Commit

Permalink
solved movement
Browse files Browse the repository at this point in the history
Solved a bug in final_move, so that the model can now turn properly.
  • Loading branch information
maurock authored Nov 19, 2018
1 parent 1e0a2a9 commit 4e74fbc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions snakeClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,11 @@ def run():

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

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

0 comments on commit 4e74fbc

Please sign in to comment.