e5frog Posted July 31, 2022 Share Posted July 31, 2022 Not sure the routine is used the way it was intended. At start of game you should seed which number in the pedefined scrambled numbers loop you want to start with. An easy seed method is running a counter and save it in the register used by the random routine while waiting for user input (wait for no input first to prevent "cheating"). Doing a "ds REG" in the loop waiting for input is probably shortest/quickest. "ds S" if scratchpad is set/used. After your seed number is set you don't change it again, only the random routine changes that register (0o25 in this case). It takes one step at the time in the predefined scrambled order of 256 values - without repeats. When you need to use a new number for the single particular function, call the routine and there will be a new number in the register. It's possible to create a different order of numbers by using another mask in the routine (wiki has 16 possible options). Not using the randomizer the way it was meant to be used might mess with the "randomness". When using just 2 bits, pure random would give 25% for any direction, 6.5% for two in a row... 1.6% for three in a row. The subroutine only mixes eight bits with no repeats, it's quite possible you can get the same number several times in a row when just keeping two bits. My suggestion is that you save the previous number and fetch a new random number if it's the same (the two used bits) as last time and keep getting a new random number until it's different - or just try X amount of times before using that number anyway, or do an operation (sr 1 or sr 4 or com or inc... ) ... or setup a data table that has a good mix and start at a seeded number in that set to mix up the start position. The pseudorandom numbers routine is just a compacted table, saves some space not needing a 256 byte table. Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.