Created
January 31, 2021 21:43
-
-
Save ikbendewilliam/ae64fd1d2da29f8f41eb930174858846 to your computer and use it in GitHub Desktop.
Code for medium article about RL on Snake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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