Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Randomize not very random?
#2
(04-06-2025, 12:21 PM)BrianT Wrote: Moving it into the "new game" loop so it is run at the start of each new game, I'm always seeing 49,0,21,24.

Move it above do (out of the main loop). There is no reason to call it again when the new game starts.
Still, it shouldn't behave as you said...

Apart from that you should call randomize only once, what comes to mind is this - if you load the game in emulator with some kind of "fast load" (or whatever it is called in fuse), the emulator might reset its state and load quickly, meaning it always take the same time since the Spectrum resets until the programme starts and randomize is called.

I'm not sure if it is that, but might be...
Before solving it, you should test if this is the reason.
To see if it can be the problem, turn off quick load options in emulator and type load"" manually, wait a while and load. If you don't get the same values, then that was it.

If that's what it was, still you want the programme to be used in emulators, so you still need to make it right in emulator when loaded with its quick loading options.
Here is what might solve it - to avoid that - don't call randomize at the start of the programme, but wait some user interaction. That can be when the user choose "H" or "L" for the first time - only then call randomize and shuffle and set some variable like "RandomizeAlreadyCalled = 1", so never call it again - after that you can pick the first card and respond to the user. Then randomize will get different seed, depending on time it takes to the user to take his first choice.

Swan, my ZX Spectrum emulator https://github.com/zoran-vucenovic/swan
Reply


Messages In This Thread
Randomize not very random? - by BrianT - 04-06-2025, 12:21 PM
RE: Randomize not very random? - by Zoran - 04-06-2025, 01:26 PM
RE: Randomize not very random? - by boriel - 04-06-2025, 07:07 PM
RE: Randomize not very random? - by BrianT - 04-06-2025, 08:35 PM
RE: Randomize not very random? - by Zoran - 04-08-2025, 10:40 AM

Forum Jump:


Users browsing this thread: 3 Guest(s)