Random game it's not to much randomly :)
-
@djdiabolik By the nature of choosing randomly you WILL get repeats close to one another. Do you want "random except recent selections"?
I don't doubt that you're experiencing an issue, but splitting your ROM collection into subfolders seems unnecessary when you're using a GUI and not viewing the file structure directly. You could be creating issues like this (using features intended to work with another file structure).
Does the random feature work when you have all of one system's ROMs in the same directory? The issue could be as simple as the Rand() function traversing subdirectories.
-
@djdiabolik said in Random game it's not to much randomly :):
For mame2003plus I have not divided the roms into subfolders A..B..C..D etc etc. All zip files it's inside a single subfolders "mame2003-plus" on main "arcade" folder.
and here too... i can also see the "random" current feature not too much randomly :)Are you using the 'random' help button in the
mame2003-plus
subfolder or from thearcade
folder ? How many single games do you have in thearcade
folder - directly there ? -
@IanDaemon
apparently having separated the roms alphabetically in all subfolder called "A" "B" "C" it doesn't seem to cause any problems.
Using the actual "Random" button I can see that the games are chosen from all the available folders...a title starting with the letter A can be chosen and, after another press of "Random" button a title whit letter C or P or any else.as already said the "problem" is that the same title reappears and is reselected usually after 2 or 3 consecutive pressed of "Random" button when absurdly with a choice of over 3000 titles there is a very wide choice and this should be less frequent.
Try to understand me........ also whit my English knowledge it's not made me easy to explain what am I trying to say :)
@mitu
Apparently it's not important...... infact when i open the "Arcade" section and i press one time the "Random" button a games from "mame2003-plus" it's be selected.
here too the same game is reselected very frequently..... usually after two or three consecutive press of "Random" button :)I am more and more convinced that with a video I would be able to make you realize what happens :)
...Really sorry for my bad english..
-
@djdiabolik said in Random game it's not to much randomly :):
I am more and more convinced that with a video I would be able to make you realize what happens :)
I realise what it happens, what's not clear to me is the full structure of the folder. Let's go again over the
arcade
folder:- are you located directly in the
arcade
system where you press the Random game shortcut ? - what folders do you have in the
arcade
system ? - how many games do you have in the
arcade
folder (and not in sub-folders) ?
- are you located directly in the
-
- Yes...
- In arcade folder i have only one folder... "mame2003-plus" and "media" (contain the snapshot for gamelist.xml)
- on mame2003-plus folder it's 2059 zip files.
-
@djdiabolik So...this? (ignore the file sizes)
-
@djdiabolik I'll take a look.
I have a suspicion that 'random' counts only the games in the main folder (excluding the sub-folders) and that's why it's always picking the same number (or close to it, if you have few games in the main folder).
Could be related to the reports of users about screensaver not being 'random' enough - though it wasn't something I was able to reproduce. -
@IanDaemon
Wait... i have the same folder structure also on a folder on windows (for made skraper of all roms).
This is the content of "/roms/arcade"Inside mame2003-plus there are all roms zips
@mitu for curiosity... how is random choice made ?
each game has its own id and retropie chooses an id at random and selects it ?Or simply retropie made a random step upward or downward respect the last game selected ?
-
@mitu for curiosity... how is random choice made ?
- step 1 - count the games in the system.
- step 2 - pick a random number between 0 and N, where is N is the number of games
- step 3 - go to that game.
-
@mitu said in Random game it's not to much randomly :):
step 1 - count the games in the system.
step 2 - pick a random number between 0 and N, where is N is the number of games
step 3 - go to that game.Oh ok..... therefore it may happen that the same game is reselected frequently if the variable N it is "generated not too randomly" :) ?
This reminds me of one thing... i have a good knowledge whit BASIC and AutoIT developing:
About 5 years ago I was writing a program where I needed to generate a randomatic variable.
If i remember correctly this variable need to obtain a value from 1 to 60....... I remember that this variable, after several tests, always seemed to obtain very similar values.By way of workaround i "made/intent" a new routine of random choice.... i used a loop... an example:
- RND(X) 1 to 10000 <- Temp variable
- RND(N) 1 to 60 <- The variable i need
- Made a complete loop whit variable X and regenerate variable N every time.
I don't know if I've made myself clear.... but thus the choice of the variable I needed immediately appeared more randomatic :)
-
@djdiabolik I just tested the functionality and it appears to be working correctly on my end. Wouldn't your loop just complete the same "non-random selection" ten thousand times?
-
@iandaemon mmmmmmmm....
i don't have idea because it's happend on my pi4 setup :)I can say that if the same thing happened to me on a roulette wheel I could get rich :)
Here it's very strange........ from a collection of about 2000 games if i press 15 times random button i can clearly see the same game selected from the 3 or 4 times.
then we can say that it's just "randomness" :)
-
I believe that it's happening to you. I'm just trying to figure out the logic in my head. Selecting a random number from one to "N" should give you a random number within the constraints given. If the total number of games isn't "N" then where might "N" be coming from? Maybe there is some limit to the subfolders traversed and that is affecting "N"? I'm not sure, but this sounds like a mystery.
-
Can't reproduce this. I have a system with 1000+ games in a sub-folder, pressing
X
always gets me a random game. It doesn't matter whether there's a few games in the main folder or not.If you can zip your
gamelist.xml
and upload it somewhere I could try to reproduce it using it. -
"Random Number Generation is too Important to be Left to Chance" -- Robert Coveyou
Thanks to @DjDiabolik for bringing this up and sorry, the next sections will be technical. I can not judge what role your specific setup plays in the described effect, but I have evidence that some part is also caused by the current implementation. Maybe your described effect is a cumulation of both.
I had a review of the codesegments in question, and the randomness is not really a unique randomness (if it would be a roulette it would be rigged). However, on my setup I have not noticed the same games selected/shown over short time / X presses, but some do show up more often in the slideshow than others and some have never been shown.
Here is my analysis:
-
Major flaw is the use of
rand()
in the code which does not spread evenly inRAND_MAX
(=not uniform random as a ideal coin). Your effect @DjDiabolik may be caused by a non synchronized clock (which is likely as the Rpi has no real hardware clock as a PC and if the Rpifake-hwclock
is disabled or not updated on shutdown the Rpi time "stands still"). If system time is not updated and your system boots up with a tolerance of +/-0.5 sec you will most likely get the same random numbers fromrand()
as the random number generator gets initialized with the same time (which then defines the sequence of random numbers). -
It is very, very unlikely to get the screensaver image/video to show the last game in the overall gamelist list. If you maintain 3000 ROMs for example the likelyhood is not 1/3000 but 1/2147483647 (NB: 2147483647 = 2^31-1 which is
RAND_MAX
on Linux-Rpi). This subtle programmatically introduced non-uniforminess is something tried to be mitigated on the random game/random system selection but in a odd way. -
Whenever one uses custom images to display during the screensaver there is a modulo bias, so even if
rand()
would be uniform distributed random numbers, some custom images are shown more often than others.
I lifted the code a while ago and I am happy to file a PR the next days: It utilizes a fast real uniform random number generator (not depending on time as sole source of entropy/initialization), uses the benefits of C++11 and has less code to accomplish the same.
-
-
@iandaemon said in Random game it's not to much randomly :):
I believe that it's happening to you. I'm just trying to figure out the logic in my head. Selecting a random number from one to "N" should give you a random number within the constraints given. If the total number of games isn't "N" then where might "N" be coming from? Maybe there is some limit to the subfolders traversed and that is affecting "N"? I'm not sure, but this sounds like a mystery.
lol...i don't have idea. I'm probably the one who's noticing it too much :)
@mitu said in Random game it's not to much randomly :):
Can't reproduce this. I have a system with 1000+ games in a sub-folder, pressing
X
always gets me a random game. It doesn't matter whether there's a few games in the main folder or not.If you can zip your
gamelist.xml
and upload it somewhere I could try to reproduce it using it.it's not a problems.... tomorrow or next time i turn on my Pi4 i get for you the gamelist.xml of my NES system. It's about 3000 roms divided alphabetically by subfolder and try to upload on zippyshare or somethigs similar (suggest if you have a preferred host site).
i can also provide the gamelist.xml of my arcade system whit only mame2003-plus collection. here all roms it's inside a single subfolders and also here I can notice this strange randomness :)Guys... what seems strange to me it's this. with a smaller collection of roms obviously the chances that the same game will be selected randomly more times is higher:
For example.. Atari Linx entire collection it's only 95 titles. But with a larger collection, in theory, it should be the exact opposite :)@Lolonois i have read carefully your explanation...... but it's too much techicals for my knowledge here :)
-
@djdiabolik said in Random game it's not to much randomly :):
i can also provide the gamelist.xml of my arcade system whit only mame2003-plus collection. here all roms it's inside a single subfolders and also here I can notice this strange randomness :)
It doesn't matter how many games are, as long as the issue occurs with that system.
-
@lolonois said in Random game it's not to much randomly :):
Major flaw is the use of rand() in the code which does not spread evenly in RAND_MAX (=not uniform random as a ideal coin). Your effect @DjDiabolik may be caused by a non synchronized clock (which is likely as the Rpi has no real hardware clock as a PC and if the Rpi fake-hwclock is disabled or not updated on shutdown the Rpi time "stands still"). If system time is not updated and your system boots up with a tolerance of +/-0.5 sec you will most likely get the same random numbers from rand() as the random number generator gets initialized with the same time (which then defines the sequence of random numbers).
using microseconds for the seed would seem like a simpler solution - http://www.guyrutenberg.com/2007/09/03/seeding-srand/
even if the clock isn't synced, the microseconds for a boot should vary enough i would have thought?
-
@dankcushions time has moved on (sorry for the pun) since then (referring to your blog post reference). I filed a PR which uses a permuted congruential generator, along with all other remidiations. I also like the approach that the PCG has getting more statistical analysis/correctness validation by a brain more knowingly than mine on that topic.
-
@lolonois yes, i've seen the PR which prompted my reply. to me it seems cool but a bit over engineered if a 3 line fix would more or less fix it (if my thinking is correct), but i'm also at the mercy of smarter people's opinions :)
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.