Skip to content

Instantly share code, notes, and snippets.

@ikbendewilliam
Created January 31, 2021 21:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ikbendewilliam/ae64fd1d2da29f8f41eb930174858846 to your computer and use it in GitHub Desktop.
Save ikbendewilliam/ae64fd1d2da29f8f41eb930174858846 to your computer and use it in GitHub Desktop.
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