Darwinbots Forum
Bots and Simulations => DNA - General => Topic started by: Testlund on September 16, 2014, 04:12:26 PM
-
There should only be a 1 chance out of 3 for this bot to start shooting when energy becomes lower than body, but that is completely ignored and the bot will always shoot.
'If 50 is not 3; shoot!
cond
*.nrg *.body <
50 3 !=
start
-6 .shoot store
stop
'Reset 50 to 0 when .nrg becomes more than .body.
cond
*.nrg *.body >
start
0 50 store
100 .strbody store
stop
'Set 50 to a random number between 1 and 3 when .nrg and .body are equal.
cond
*.nrg *.body =
start
3 rnd 50 store
stop
-
You forgot the * on the 50
-
Oops
In the shoot gene
-
OK, that improved it a little but the randomness is only generated when the sim starts, after that the shooting bots will ignore the instruction and always shoot.
So with free variables you always type it like this?
cond
*random 3 =
start
stop
Not like this?
cond
*.random 3 =
start
stop
-
Ok, I see exacty what is going on... sorry for the confusion...
If it is a number it is just "50" if not it is always starts with a period as in:
def pizza 50
.pizza or *.pizza
-
OK. Well, the randomness is only run when the sim starts. After that the bots will be stuck with there choices. I was thinking there should be a way to re-run whenever the bots get "hungry".
-
'If 50 is not 3; shoot!
cond
*.nrg *.body <
50 * 3 !=
start
-6 .shoot store
stop
'Reset 50 to 0 when .nrg becomes more than .body.
cond
*.nrg *.body >
start
0 50 store
100 .strbody store
stop
'Set 50 to a random number between 1 and 3 when .nrg and .body are equal.
cond
*.nrg *.body =
start
3 rnd 50 store
stop
or
'If 50 is not 3; shoot!
cond
*.nrg *.body <
*50 3 !=
start
-6 .shoot store
stop
'Reset 50 to 0 when .nrg becomes more than .body.
cond
*.nrg *.body >
start
0 50 store
100 .strbody store
stop
'Set 50 to a random number between 1 and 3 when .nrg and .body are equal.
cond
*.nrg *.body =
start
3 rnd 50 store
stop
The confusion is between a physical address or a defined operator, they both mean the same thing.
.nrg is comrehanded by the compiler as some orbitrary number as well as the number itself say 50.
-
Well the way you say it you want a 1/3 chance but you post 2/3 chance
Try 3 50 store as your reset (2/3)
Try *50 3 = as time to shoot (1/3)
-
Yeah, I thought backwards there. :P I get a little better result now, at least when the sim starts.