Ways to remove RNG

General chat related to ScummVM, adventure gaming, and so on.

Moderator: ScummVM Team

Post Reply
TheSassyBird
Posts: 2
Joined: Sat Mar 24, 2018 1:45 am

Ways to remove RNG

Post by TheSassyBird » Sat Mar 24, 2018 4:27 pm

I was wondering if there would be ways to remove randomly generated events or assure that I would encounter them from the game Freddi Fish (3). For example, that the Golden Pipes would always spawn at the same three places. Maybe this is possible via the console, I wouldn't know. Anyways thank you for answering my question.

digitall
ScummVM Developer
Posts: 955
Joined: Thu Aug 02, 2012 1:40 pm

Post by digitall » Sun Mar 25, 2018 6:19 pm

I am not an expert in SCUMM HE engine internals, but I suspect that this _might_ be possible by forcing certain object values, but to ensure the game is totally deterministic, I think you would need to modify the SCUMM engine source code to "break" the opcodes used to generate random numbers and compile a new version of SCUMMVM from your modified code... I think that would be opcode 87 and 88 based on:
http://wiki.scummvm.org/index.php/SCUMM ... ndomNumber

digitall
ScummVM Developer
Posts: 955
Joined: Thu Aug 02, 2012 1:40 pm

Post by digitall » Sun Mar 25, 2018 6:24 pm

Hmm... The engine calls the Common::RandomSource code to generate random numbers. You could also replace that code or hobble it, but this could have some graphics effect impact as it seems to be used in places in the engine code other than the script interpreter:
https://github.com/scummvm/scummvm/blob ... .cpp#L2104

digitall
ScummVM Developer
Posts: 955
Joined: Thu Aug 02, 2012 1:40 pm

Post by digitall » Sun Mar 25, 2018 6:29 pm

Aha. I think you can use Common::RandomSource's setSeed method function to reset the PRNG seed to the same value each time. This would make the behaviour deterministic:
https://github.com/scummvm/scummvm/blob ... ndom.h#L49

If you remove the line I indicated in scumm.cpp L1204 and then place a _rnd.setSeed(1) or similar before the main loop there, that should do it.

Can I ask why you want to do this?

TheSassyBird
Posts: 2
Joined: Sat Mar 24, 2018 1:45 am

Post by TheSassyBird » Mon Apr 02, 2018 10:05 pm

digitall wrote:Aha. I think you can use Common::RandomSource's setSeed method function to reset the PRNG seed to the same value each time. This would make the behaviour deterministic:
https://github.com/scummvm/scummvm/blob ... ndom.h#L49

If you remove the line I indicated in scumm.cpp L1204 and then place a _rnd.setSeed(1) or similar before the main loop there, that should do it.

Can I ask why you want to do this?
Thanks for the help, I speedrun Freddi Fish 3 for fun and you need a certain route for the best score, don't want to reset every time I get the wrong seed. It's helps me practice faster.

Post Reply