Weighted random number generator for choosing tiles.
While messing around with the RandomSprite script to add some variation to my level generation I ran into the problem where too much variation was being added:
http://i.imgur.com/D4mgNYg.png
To fix this issue I implemented a weighted random number generator to select from the list of available tiles. The weighted random generator function was provided by one of the nice people in #unity3d on freenode.
Weighted Random Number Generator function - http://pastebin.com/7wurEHWk
RandomSprite modified to use weighted function - http://pastebin.com/rT52z97a
Script applied to a prefab - http://i.imgur.com/NHGaw0o.png
The result - http://i.imgur.com/V1OMxtG.png
Posted Oct 9, 2014, 9:00 PM UTC
Thank you for sharing this!