Need help with a simple Random generator

I want my bot to randomly choose which direction to turn when it reaches an obstacle. Right now it only turns right. All I need is a variable to hold one of two possible numbers, either a 0 or a 1 or a 1 or a 2. The below code only produces a #6 for ever:

[code]turnDir var nib

top:
turnDir = random 2
debug [dec turnDir, 13]

goto top[/code]

Help!!

Thiat is because you are always feeding it the same value.

You might try something like:

[code]
TurnDir var bit
Rand var long

Rand = random 2
Top:
rand = random rand ; feed in the old value
TurnDir = rand & 0x1 ; takes the low bit to be either 0 or 1
debug …
goto top[/code]

Kurt
P.S. - I know nothing, I have not compiled or tested, so use at your own risk.

Thanks Kurte,

It works!

0011111101001001111110000011001110111010000100111101000101001000