Bots and Simulations > Bot Tavern
Random Bot
Tilthanseco:
I took the random bot idea and used an internal random number generator instead of "rnd".
This way mutations can still affect the bot very well. I'm running this bot as a alga with a simple bot.
Regular Random Bot 0 to 1000
--- Code: ---cond
start
1000 rnd 1000 rnd store
stop
--- End code ---
Very Simple Internal Generator 0 to 999
--- Code: ---'Environmental Seed
cond
*.robage 1 =
start
*.xpos *.ypos add 2 div 51 store
stop
'Location Generator
cond
start
*51 125 mult 31991 mod 51 store
*51 1000 mod 52 store
stop
'Value Generator to keep from Looping
cond
*52 51 !=
start
*51 125 mult 31991 mod 51 store *51 1000 mod *52 store
stop
--- End code ---
P.S. Making a random number generator is hard... It took me most of the day to make a random enough one that was simple while limited to a state of 32000.
Many tries led to loops of often only 10 numbers.
Botsareus:
Nice concept. How is this better then using rnd?
Numsgil:
Yeah, random number generators are hard. You might want to read chapter 7 of Numerical Recipes in C if you're interested in the subject at all. It's a good introductory chapter on generators and why they're tricky.
Tilthanseco:
Thanks Nums, I read 7.1 and it was interesting and useful. The rest was out of my league...
I found out what my big problem was though, the stack only holds 2^21 and I was thinking 2^32. The stack overflows were leading to my looping problems.
The book says I should use a fraction to limit the rand like: state * 143/1125 but this leads to half as many 0's as other numbers. ???
Using a mod like: state mod 1001 gives the right number of 0's, what's up with that?
I settled on this:
--- Code: ---'Seed
cond
*.robage 1 =
start
*.xpos *.ypos add 9 div 51 store
stop
'Location Generator
cond
start
*51 211 mult 1663 add 7875 mod 51 store
*51 143 mult 1125 div 52 store
stop
'Value Generator
cond
*52 51 !=
start
*51 211 mult 1663 add 7875 mod 143 mult 1125 div *52 store
stop
--- End code ---
@Botsareus I figured a random number generator that was able to change would be better than a static Random gen. :P
This new one works almost as well as rnd according to my very limited testing, besides the stupid 0's. (Replacing [143 mult 1125 div] with [1001 mod] fixes that)
I thought you would like it because it lets mutations affect more things.
P.S. The stack is so small, I had to reduce my fraction from 1001/7875 to 143/1125 :wacko:
Botsareus:
oh 8)
Navigation
[0] Message Index
[#] Next page
Go to full version