Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add fixedSeed param to GameSetup and use it to initialize RNG #875

Merged

Conversation

Bruno-DaSilva
Copy link
Collaborator

@Bruno-DaSilva Bruno-DaSilva commented Jun 25, 2023

By specifying a fixed seed, this fixes variance between benchmark runs of, say, fightertest. See thread in: https://discord.com/channels/549281623154229250/1122484736913318021

Credit to @Beherith for figuring out this was a seeding issue

Feel free to nitpick, so I can get a better idea of what's important to y'all.

By specifying a fixed seed, this fixes variance between benchmark runs of, say, fightertest. See thread in: https://discord.com/channels/549281623154229250/1122484736913318021
@Bruno-DaSilva Bruno-DaSilva force-pushed the bruno/consistent-benchmarks branch from ed4fde1 to 3822bb9 Compare June 25, 2023 22:50
@Beherith
Copy link
Contributor

I dunno how to push to this specific branch, my desktop version seems a tad broken when i tried to switch, could you please add this to https://github.com/beyond-all-reason/spring/blob/BAR105/doc/StartScriptFormat.txt

FixedSeed = 1; //Initialize the synced RNG with a specific seed for reproducible benchmarking runs only

@Bruno-DaSilva
Copy link
Collaborator Author

@Beherith I bet it's because it's in my fork instead of the main repo - you'd have to setup your local repo with a different remote url to https://github.com/Bruno-DaSilva/rts-spring branch bruno/consistent-benchmarks

Went ahead and added that line - can you confirm it's in the right place?

@Beherith
Copy link
Contributor

Gets the LGTM from me, ill wait for the others to sign off too

@@ -50,6 +50,8 @@
NumTeams=y; // same here, set this to check if the script is right
NumAllyTeams=z; // see above

FixedSeed = 1; //Initialize the synced RNG with a specific seed for reproducible benchmarking runs only
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why 'benchmarking runs only'? Surely it's useful for things like say reproducible cutscenes in missions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Didnt think of that, thats a good use case!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed - check out the new description

rng.Seed(gameID.intArray[0] ^ gameID.intArray[1] ^ gameID.intArray[2] ^ gameID.intArray[3]);
Broadcast(CBaseNetProtocol::Get().SendRandSeed(rng()));
if (myGameSetup->fixedSeed == 0) {
GenerateAndSendGameID();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't gameID be sent regardless?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good find, you're absolutely right this should live outside the condition

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed!

@@ -582,6 +584,7 @@ bool CGameSetup::Init(const std::string& buf)

file.GetTDef(mapSeed, unsigned(0), "GAME\\MapSeed");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like "map seed" exists which makes "fixed seed" not obviously RNG related. Perhaps call it "FixedRNGSeed" or something? Otherwise looks good though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

FixedRNGSeed is much more clear. Changing that 🙌

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done 👍

dsGameData->SetRandomSeed(rng.NextInt());
} else {
dsGameData->SetRandomSeed(dsGameSetup->fixedSeed);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

FYI @Beherith @sprunk added to dedicated server, too. Compiles fine but untested.

@Beherith Beherith merged commit 771bea2 into beyond-all-reason:BAR105 Jun 30, 2023
@FIr3baL
Copy link
Contributor

FIr3baL commented Jul 11, 2023

Hey @Beherith , @sprunk , please watch this PR related to this one.
beyond-all-reason/BYAR-Chobby#414

@Bruno-DaSilva
Copy link
Collaborator Author

@FIr3baL I was waiting for when engine was pushed out (was tested and pushed pushed fully out successfully?), else this would cause errors when running the scenario, I think.

@sprunk
Copy link
Collaborator

sprunk commented Jul 11, 2023

nah it should've been safe

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.

4 participants