Wednesday, February 11, 2015

Developer Fitness Challenge Day 6: Randomness is Difficult



What's the fitness challenge? Check out my intro post here.


I have a feeling the programmers out there are going to say "yeah, obviously", but I found out today that randomness can be tricky!

Even in Game Maker, with some nice built-in randomization features, I'm not getting the results I was hoping for using my code that I built to scroll through three random objects that I have for testing (you can see my rough explanation here). How do I know? Well, I tested it out a bunch today; ready for some stats?

 My test was to do 25 separate runs of 10 button presses, marking down what the final selection was each time (1, 2, or 3). After each round of 10 presses, I closed and restarted the app to reset the random seed. At the end of the test, I collected the average selection rate for each of the three rectangles, and here's what I got:


Very interesting, seems that cell 3 (in yellow) is the HEAVY favorite for the current system. We can't have that! Here's the solution I implemented, but haven't yet tested.

In the test button press event, I added an extra layer of 'randomness' by starting the system on a random rectangle each time. Basically, my original code always started at 0 and ran the system, but now it will start at a random number between 0 & 3, then runs the system. This plus my earlier randomization code hopefully will create more even selection rates.


Well that's all for now. I'm going to keep doing some work on this system a bit since it's the cornerstone of the entire game, but will have another update tomorrow on the results of round-2 of testing and next steps!



Fitness Stats
Excercise: 1.5 mile Run 
Weight: 224lbs (208 goal)
Calories: 1960

No comments:

Post a Comment