Repository navigation
[Core] Persist resolved random seed when RandomSeed is 0 - #1597
Merged
Merged
Conversation
newSimWithEnv picked a time based seed for RandomSeed 0 but never wrote it back, so reseedRands seeded iteration i with 0 + i. Only iteration 0 was random; iterations 1..N-1 replayed the same fights on every run. Write the resolved seed back to SimOptions, as statweight.go already does, and resolve it in SplitSimRequestForConcurrency so split workers get distinct non-zero start seeds. Port of wowsims/forever#407.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Port of wowsims/forever#407.
Problem
With
RandomSeed0 (unseeded),newSimWithEnvpicks a seed fromtime.Now().UnixNano()for the initial generator but never writes it back toSimOptions.RandomSeed. Every iteration after the first is reseeded inreseedRandsfromsim.Options.RandomSeed + i, which is still 0, so iterations 1..N-1 always run with seeds 1..N-1. Each run with seed 0 replays the same fights except iteration 0.The web UI always sends a non-zero seed (
nextRngSeed), so this hits callers that send 0:wowsimcli, API requests and any request JSON without a seed.Fix
newSimWithEnvwrites the resolved seed back tosimOptions.RandomSeed, the same waystatweight.goresolvesRandomSeed == 0.SplitSimRequestForConcurrencyresolves a 0 seed before splitting, so concurrent workers get distinct non-zero start seeds.rand_test.gofor the write-back, the split offsets, and a fixed seed staying unchanged.Tests
go test ./sim/core/...passes locally apart fromTestProtoVersioning, which needsnpx buf(not installed in the test checkout); no proto files change.