Skip to content

Instantly share code, notes, and snippets.

@davidADSP
Last active December 1, 2019 22:05
Show Gist options
  • Save davidADSP/49ae97f57e7ff6c18b8922f8fe6ee740 to your computer and use it in GitHub Desktop.
Save davidADSP/49ae97f57e7ff6c18b8922f8fe6ee740 to your computer and use it in GitHub Desktop.
class ReplayBuffer(object):
def __init__(self, config: MuZeroConfig):
self.window_size = config.window_size
self.batch_size = config.batch_size
self.buffer = []
def sample_batch(self, num_unroll_steps: int, td_steps: int):
games = [self.sample_game() for _ in range(self.batch_size)]
game_pos = [(g, self.sample_position(g)) for g in games]
return [(g.make_image(i), g.history[i:i + num_unroll_steps],
g.make_target(i, num_unroll_steps, td_steps, g.to_play()))
for (g, i) in game_pos]
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment