Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion deep_quoridor/src/v2/TODO.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# V1 Parity

- Replay buffer length: righ now we're not rolling out old games to respect the length
- Continuation

# Other improvements and new features
Expand Down
10 changes: 9 additions & 1 deletion deep_quoridor/src/v2/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ def train(config: Config):
}
)

# Trim oldest games to stay within the replay buffer size limit
while len(moves_per_game) > config.training.replay_buffer_size:
moves_per_game.pop(0)
game_filename.pop(0)

total_moves = sum(moves_per_game)

games_needed_to_train = config.training.games_per_training_step * (training_steps + 1)
Expand All @@ -134,7 +139,8 @@ def train(config: Config):
Timer.start("sample")
samples = []

games = np.random.choice(last_game, batch_size, p=[moves / total_moves for moves in moves_per_game])
buffer_size = len(moves_per_game)
games = np.random.choice(buffer_size, batch_size, p=[moves / total_moves for moves in moves_per_game])
samples_per_game = Counter(games)
for game_number in samples_per_game:
file = config.paths.replay_buffers / game_filename[game_number]
Expand All @@ -156,6 +162,8 @@ def train(config: Config):
"value_loss": value_loss,
"total_loss": total_loss,
"games_played": last_game,
"replay_buffer_games": buffer_size,
"replay_buffer_moves": total_moves,
"time-sample": time_sample,
"time-train": time_train,
"time-waiting-to-train": time_waiting_to_train,
Expand Down