Skip to content

Add opening seed control for selfplay opening randomness - #2423

Open
john-sp wants to merge 2 commits into
LeelaChessZero:masterfrom
john-sp:seed-for-selfplay
Open

Add opening seed control for selfplay opening randomness#2423
john-sp wants to merge 2 commits into
LeelaChessZero:masterfrom
john-sp:seed-for-selfplay

Conversation

@john-sp

@john-sp john-sp commented Jun 28, 2026

Copy link
Copy Markdown
Member

Adds a new selfplay flag, --opening-seed, to control randomness used by shuffled and random opening modes.

Changes:

  • Adds --opening-seed with default -1 to preserve existing nondeterministic behavior.
  • Uses the seeded opening RNG for: --openings-mode=shuffled and --openings-mode=random
  • Adds a non-breaking Random(int seed) constructor while leaving Random::Get() unchanged.
  • Keeps unrelated tournament randomness on the existing global RNG.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds deterministic control over selfplay opening selection by introducing a dedicated RNG seed (--opening-seed) used only for opening-book shuffling and random opening selection, while leaving the existing global RNG behavior unchanged for other tournament randomness.

Changes:

  • Add --opening-seed (default -1) to control randomness for --openings-mode=shuffled and --openings-mode=random.
  • Introduce a new Random(int seed) constructor that preserves current non-deterministic seeding for negative seeds.
  • Use a per-tournament opening_random_ RNG for opening shuffle/selection instead of Random::Get().

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/utils/random.h Exposes a seeded Random(int seed) constructor to support deterministic RNG instances.
src/utils/random.cc Implements seeded initialization (negative seed preserves current non-deterministic behavior).
src/selfplay/tournament.h Adds a dedicated opening_random_ member RNG for opening-related randomness.
src/selfplay/tournament.cc Adds --opening-seed, initializes opening_random_, and switches shuffled/random opening logic to use it.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/selfplay/tournament.cc Outdated
Comment thread src/selfplay/tournament.cc Outdated
@john-sp
john-sp requested review from Menkib64, borg323 and mooskagh June 28, 2026 15:05
Comment thread src/selfplay/tournament.cc Outdated
Comment thread src/selfplay/tournament.cc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants