Welcome To Darwinbots > Newbie
inline conditions
Shasta:
A little bit late, but here is an example of Animal Minimalis as a one gene bot:
[div class=\'codetop\']CODE[div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']'Animal_Minimalis
'By: Nums
'Good for mutation sims and for
'newbies to see how a basic bot works.
'Contains everything necessary for it
'to survive and reproduce.
' Gene 1 Food Finder
start
*.eye5 0 >
*.refeye *.myeye != and
''''''''
*.refveldx .dx store
*.refvelup 30 add .up store
' Gene 2 Eat Food
'''
*.eye5 50 >
*.refeye *.myeye != and
''''''''
-1 .shoot store
*.refvelup .up store
' Gene 3 Avoiding Family
'''
*.eye5 0 =
*.refeye *.myeye = or
''''''''
314 rnd .aimdx store
' Gene 4 Reproduce
'''
*.nrg 20000 >
''''''''
10 .repro store
stop
end
This is pretty basic, and really all you have to do is remove the cond/start statements, and be careful with your and statements. Once you start throwing in nested statements it gets a bit harder.
--- Code: ---If *.eye5 0 !=
If *.refeye *.myeye !=
If *.refeye 0 =
'Deal with veggie
Else
'Eat
Else
'Deal with family
--- End code ---
Turns into:
--- Code: ---*.eye5 0 != dupbool
*.refeye *.myeye != and dupbool
*.refeye 0 = overbool overbool and
'Deal with veggie
dropbool
not and
'Eat
dropbool not
'Deal with family
--- End code ---
(Pretty sure that is right, did it quick)
I may put up a tutorial on them in the wiki sometime.
d-EVO:
--- Quote from: Shasta ---(Pretty sure that is right, did it quick)
--- End quote ---
Its not.
I tryed it and it wont shoot but aproaches the alge
This is the code I used
--- Code: ---'ANIMAL 1G
start
*.eye5 0 != dupbool
*.refeye *.myeye != and dupbool
*.refeye 0 = overbool overbool and
1 .up store
dropbool
not and
-1 .shoot store
dropbool not
300 rnd .aimdx store
stop
--- End code ---
think there is a prob with the "not" function. please check, I can never get it to work
Shasta:
The bot actually does work as I have the conditions set up to, they just are not set up like you are thinking.
--- Quote from: Shasta ---
--- Code: ---If *.eye5 0 !=
If *.refeye *.myeye !=
If *.refeye 0 =
'Deal with veggie
Else''''''''''''''''''''''''''''''''''''''''
'Eat
Else
'Deal with family
--- End code ---
--- End quote ---
('''''ed for emphasis) In most/all programming languages Else sections only run when the IF statement before them failed. So, it is only trying to feed when the bot is NOT a veggie (one could use this to not kill a veggie and just feed a bit), so its actually doing exactally what you have it set up to do, push the veggies around and attack hunters.
So if you want to make it so the bot attacks everything thats not family remove the ''''''' lines
--- Code: ---'ANIMAL 1G
start
*.eye5 0 != dupbool
*.refeye *.myeye != and dupbool
*.refeye 0 = overbool overbool and'''''''''''''''''''''''''''''''''''''''
1 .up store
dropbool''''''''''''''''''''''''''''''''''''
not and'''''''''''''''''''''''''''''''''''''''''
-1 .shoot store
dropbool not
300 rnd .aimdx store
stop
--- End code ---
Also, a few tips to make it a bit more effective, put in a range check before it starts to shoot (*.eye5 < WhatEverDistanceYouWant), change the rotate value so it always makes a certain amount of turn (314 .aimdx is 1/4 of a revolution)
jknilinux:
Wow, that's really helpful! Thanks Shasta!
ikke:
Question / comment:
' Gene 2 Eat Food
cond
*.eye5 50 >
*.refeye *.myeye !=
start
*.refxpos *.refypos angle .setaim store
-1 .shoot store
*.nrg 100 >
-6 .shoot store
*.refvelup .up store
Stop
Will not result in a bot spraying -6 shots if nrg>100 regardless of the cond statement. Apparently either
a) everything between start and stop is only executed if cond is met
or
B ) the cond bool is anded with inline Booleans
Which is it?
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version