MiSTer_SAM icon indicating copy to clipboard operation
MiSTer_SAM copied to clipboard

Improve randomness

Open Mellified opened this issue 3 years ago • 9 comments

SAM seems to not be as random as we'd expect. While not definitive, there are runs of the same core or game several times in a row.

Look at ways to improve randomness. Consider keeping a list of recently played games and excluding the same titles from being selected again.

Mellified avatar Apr 26 '21 03:04 Mellified

Suggestion is to use $RANDOM as a seed.

Mellified avatar Apr 28 '21 04:04 Mellified

I changed shuf to use --random-source=/dev/urandom. Not clear if this improved things though.

Mellified avatar May 17 '21 19:05 Mellified

I have been playing around with this for arcade games. I delete the file from the tmp game list file after it is selected. That prevents it from being selected again until the list is empty.

mra="$(shuf --head-count=1 --random-source=/dev/urandom ${mralist})"
sed -i "/${mra}/d" ${mralist}

also once the list is empty I populate it again by calling build_mralist

This works for me. I am sure the gurus and implement this in a prettier way.

Thanks,

crispytreat avatar Jun 28 '21 15:06 crispytreat

@mrchrisster, please look into this one. It would be nice if it could be done how spotify does with the shuffle feature. Aka it creates a list then once the list has been played then it creates a new shuffle list.

thehughhefner avatar Feb 01 '22 14:02 thehughhefner

This is now implemented for non zip archives. SAM will play every game once before repopulating the list of games.

mrchrisster avatar Apr 05 '22 23:04 mrchrisster

Cores now don't repeat twice in a row and big zip archives will now also not repeat. I feel like this justifies closing the issue.

mrchrisster avatar Apr 17 '22 00:04 mrchrisster

I have seen one game show up at least 5 times today. It is the only thing in my TGFX16-CD folder. Does every core have an equal chance of being selected? If so, could there be a way to balance cores that have few games vs many games?

TheRealBenForce avatar Sep 28 '22 22:09 TheRealBenForce

Thanks for your error reporting. I believe i have fixed the issue but working on some other changes as well.

The problem with balancing cores by games is that you might get a lot of SNES games and not a lot of other games because it has such a big library of games. What SAM does is never play the same core twice though

mrchrisster avatar Sep 28 '22 23:09 mrchrisster

Personally, I'd prefer to see a lot of different games from the same core rather than the repeating games if cores have an equal chance of being selected (I think) and some cores have small libraries. Anyway, SAM is awesome and working quite well! Looking forward to following updates!

TheRealBenForce avatar Sep 30 '22 17:09 TheRealBenForce