Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Code for medium article about RL on Snake
j+=1
s = env.get_board()
a = np.argmax(rlModel.predict(s)[0])
if np.random.rand(1) < random_action_threshold:
a = env.random_action()
s1, reward, done = env.step(a)
rlModel.train_single_step(s, s1, a, reward, maximum_discount)
rAll += reward
if done:
break
random_action_threshold = 1./((i/50) + 10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment