Randomizer
by th15
Some would call it fuzzy logic, I call it essential. It is a simple way to avoid "dead-ends" where the rover will keep doing something, say banging against a wall and doing nothing else for the entire match. In this example I have used, I will show you how to make a 1 out of 2 randomizer (i.e. a coin flip!).
Step 1 Add a randomizer element from the math section.

Set the maximum to 1 and the minimum to zero.

Step 2 Now, add a rangetest device (also under math) and connect it with a wire from the randomizer. Leave the wire at its default settings (when set, set input to output.)

Set the maximum and minimum value on the rangetest device to 1 and leave the input at zero. This means the range is only 1 number.

Step 3 Hook up whatever you want to be changed by the randomizer with a wire from the rangetest device. In this case I wish to change the mode on my modeswitch to blue mode.

Set the trigger event to INRANGE and set property MODE to VALUE to BLUE. This means that when the randomizer produces a 1 it will cause the mode to change to blue. I have also added a looptimer to trigger the randomizer. To apply this to anything else just change the trigger device to whatever you want.

Other Uses Other Probabilities: It is as simple as changing the min and max on the randomizer and the range of the rangetest. For example, to create a 2 out of 3 chance, set the min of the randomizer to 0 and its max to 2. Then set the min of the rangetest to 1 and its max to 2. To create a 1 in 10 chance, set the min of the randomizer to 0 and its max to 9. Then set the min and max of the rangetest to 9.

Changing Trigger Device: Almost any other device will work with this. I use a looptimer still to create a random mode for my rover. Every once in awhile (1 in 10 chance every second) my rover will make a sudden unexpected swerve. I made it work even when my rover is in bump mode so that it will never get stuck against the wall since the random mode will kick in sooner or later and turn it out.

Any suggestions on easier ways to do this welcome at th15@pacific.net.sg.

MindRover TM , MindRover: The Europa Project TM , and Cognitoy TM are trademarks of CogniToy, LLC, 1999.