Page 1 of 1

Seeded runs?

PostPosted: Monday, 12th May 2014, 00:07
by Leadpainter
Is there a file I can fiddle with or a mod that's been created that lets me and a friend run the same dungeon?

Re: Seeded runs?

PostPosted: Monday, 12th May 2014, 00:16
by duvessa
Levels in Crawl are generated as-needed, not as soon as the game is begun (otherwise, how would Abyss and Pandemonium be infinite?) So I think unless you set the state of the RNG every time a level is generated, you won't be getting the same dungeon.

Re: Seeded runs?

PostPosted: Monday, 12th May 2014, 00:21
by Leadpainter
duvessa wrote:Levels in Crawl are generated as-needed, not as soon as the game is begun (otherwise, how would Abyss and Pandemonium be infinite?) So I think unless you set the state of the RNG every time a level is generated, you won't be getting the same dungeon.


So is it possible?

Re: Seeded runs?

PostPosted: Monday, 12th May 2014, 00:36
by nicolae
Leadpainter wrote:
duvessa wrote:Levels in Crawl are generated as-needed, not as soon as the game is begun (otherwise, how would Abyss and Pandemonium be infinite?) So I think unless you set the state of the RNG every time a level is generated, you won't be getting the same dungeon.


So is it possible?


It's not been done yet, so whether it's possible depends on how eager you are to make a lot of changes to Crawl's random number generation code.

Re: Seeded runs?

PostPosted: Monday, 12th May 2014, 00:48
by Patashu
Leadpainter wrote:
duvessa wrote:Levels in Crawl are generated as-needed, not as soon as the game is begun (otherwise, how would Abyss and Pandemonium be infinite?) So I think unless you set the state of the RNG every time a level is generated, you won't be getting the same dungeon.


So is it possible?

It would require modification of the source code. And I suspect the devs are not interested in doing it, because they want the RNG of the game to be harder to predict, not easier. (There used to be a problem in Nethack online servers where you could generate games locally with timestamps around the timestamp you suspect your new online game was made at, and if you find one that looks the same, you can explore the dungeon locally then play online with perfect foresight, aka cheating)

A good example of a roguelike with seeded dungeons is Brogue. You can pass it a seed and the entire dungeon is generated based on that seed the same for everyone. (There were even some bugs that made it not generate the same way that have since been fixed, so seeds working is a priority.)

Re: Seeded runs?

PostPosted: Monday, 12th May 2014, 02:45
by Kate
Command line options:
-seed <num> init the rng to a given sequence (a hex number > 0)

The functionality has existed for a while (for debugging purposes mainly, and I don't think it actually worked properly until pretty recently). It's been used a bit for testing bots, but not for much other than that as far as I know.

Re: Seeded runs?

PostPosted: Monday, 12th May 2014, 03:11
by Patashu
MarvinPA wrote:
Command line options:
-seed <num> init the rng to a given sequence (a hex number > 0)

The functionality has existed for a while (for debugging purposes mainly, and I don't think it actually worked properly until pretty recently). It's been used a bit for testing bots, but not for much other than that as far as I know.

But is the RNG used for developing levels separate from the RNG used to produce in-game results separate from the RNG used for purely aesthetic/non-gameplay randomness? (Brogue does this, Crawl I suspect does not)

Re: Seeded runs?

PostPosted: Monday, 12th May 2014, 03:17
by duvessa
No. The levels generated will diverge as soon as there is almost any different action between the two games. Even navigating the species/background selection changes the RNG state - you can start two HuCjs with the same seed and still get different D:1s.

Re: Seeded runs?

PostPosted: Monday, 12th May 2014, 03:29
by reaver
Patashu wrote:
MarvinPA wrote:
Command line options:
-seed <num> init the rng to a given sequence (a hex number > 0)

The functionality has existed for a while (for debugging purposes mainly, and I don't think it actually worked properly until pretty recently). It's been used a bit for testing bots, but not for much other than that as far as I know.

But is the RNG used for developing levels separate from the RNG used to produce in-game results separate from the RNG used for purely aesthetic/non-gameplay randomness? (Brogue does this, Crawl I suspect does not)
The RNG used to do aesthetic stuff is separate from the gameplay one. (ui_random).

However, the normal gameplay one is not separate from the level generation one.

I actually tried this - I took a save file, copied it, went downstairs, restored and did it again. The resultant levels were different, I don't know why. From the rng conservation MarvinPA mentioned I would of expected the levels to be the same.
EDIT: from what duvessa said, there is a possibility I was was subtly changing the RNG state. Ideally I should have done this with an rc file which automatically moves downstairs without player involvement.

I think it would be pretty easy to hack in a global which swapped out the RNG seed when level generation started and stopped. Then it would be a matter for finding the few cases this isn't enough. (Acquirement, species specific troves, etc.) and this feature could become a reality.

Re: Seeded runs?

PostPosted: Monday, 12th May 2014, 04:22
by Kate
Right, I should have been clearer in that for bot testing the bots would always give the exact same input (and some recent bugfixes were what made it actually work for that purpose, IIRC). Like it says in the initial commit implementing it, seeding doesn't pre-generate levels and I have no clue how easy or hard that'd be to make work.

Re: Seeded runs?

PostPosted: Monday, 12th May 2014, 05:03
by Patashu
MarvinPA wrote:Right, I should have been clearer in that for bot testing the bots would always give the exact same input (and some recent bugfixes were what made it actually work for that purpose, IIRC). Like it says in the initial commit implementing it, seeding doesn't pre-generate levels and I have no clue how easy or hard that'd be to make work.

You don't have to pre-generate levels to have deterministic dungeons from a seed, but you do have to store the seed you started the game with in the save file and bring that seed back every time you need it to generate a level.

Re: Seeded runs?

PostPosted: Tuesday, 13th May 2014, 14:47
by Alarkh
How about adding a random generator: one, seed-able for the generation of the dungeon and the existing one for everything else ?