RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login

    Random game it's not to much randomly :)

    Scheduled Pinned Locked Moved Ideas and Development
    random gamerandomemulationstatiogame selection
    24 Posts 5 Posters 2.5k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • dankcushionsD
      dankcushions Global Moderator @Lolonois
      last edited by dankcushions

      @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?

      1 Reply Last reply Reply Quote 0
      • LolonoisL
        Lolonois
        last edited by

        @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.

        dankcushionsD 1 Reply Last reply Reply Quote 0
        • dankcushionsD
          dankcushions Global Moderator @Lolonois
          last edited by

          @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 :)

          DjDiabolikD 1 Reply Last reply Reply Quote 0
          • DjDiabolikD
            DjDiabolik @dankcushions
            last edited by DjDiabolik

            I guys are following the discussion :)
            Whit my bad english it's already difficult to made an example........

            Damn... when i made the video whit GB and CATRAP for the other my thread I could show you the example of this too :)

            I also had to post the gamelist.xml but it just passed my mind ... really sorry ...

            1 Reply Last reply Reply Quote 0
            • First post
              Last post

            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.