Ways to remove RNG
Moderator: ScummVM Team
-
- Posts: 2
- Joined: Sat Mar 24, 2018 1:45 am
Ways to remove RNG
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.
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
http://wiki.scummvm.org/index.php/SCUMM ... ndomNumber
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
https://github.com/scummvm/scummvm/blob ... .cpp#L2104
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?
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?
-
- Posts: 2
- Joined: Sat Mar 24, 2018 1:45 am
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.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?