-2*random(0,1)+1
-2*random(0,1)+1
It's a handy formula I use a lot for randomly selecting between -1 and 1 but not 0
Why is this useful? Because -1 * x = -x and 1 * x = x
This would let you randomly go left or right (with a lot more code obviously)
It has many other uses. I just thought I'd share it with you guys.
It's a handy formula I use a lot for randomly selecting between -1 and 1 but not 0
Why is this useful? Because -1 * x = -x and 1 * x = x
This would let you randomly go left or right (with a lot more code obviously)
It has many other uses. I just thought I'd share it with you guys.
Comments
That sure is simple but elegant, @Orbz , (like me... haha!); thanks for sharing. :-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps