A tutorial on creating a random boolean balancer class, to allow for more even distribution of 'random' values in your games.

Article by Richard Davey. Posted on 8th Feb 2017.   @photonstorm


This is another great tutorial from Tomáš Rychnovský, all about how to balance the distribution of 'random' booleans in your game: "Last year I worked on many small games, were obstacles were generated procedurally on the fly. Getting random numbers from random numbers generator played big role in it. Unfortunately, randomness can be sometimes pretty ... random. Let's say you just want to get randomly true or false to place some obstacle to the right or left. Be sure, that very quickly you will encounter situations, when you will not like the result. Sometimes, there will be too many obstacles on one or other side and game may get boring for long time periods.

Fast fix may be to add some counters to check if not too many obstacles is on one or other side. I was solving this often and to make situation worse, clients had requests like: "I want first 5 obstacles to be left and right in turns, so it will be kind of tutorial for player. So, I decided to solve it once and forever with small class, which I named RandomBooleanBalancer."

Read More