Welcome To Darwinbots > Newbie
inline conditions
jknilinux:
Hi everyone,
I was wondering if someone could show me the basics of inline conditions, or at least a link to a similar thread or tutorial. thanks!
peterb:
--- Quote from: jknilinux ---Hi everyone,
I was wondering if someone could show me the basics of inline conditions, or at least a link to a similar thread or tutorial. thanks!
--- End quote ---
the best way is to create them by writing them out
for example (testing eye5 here
[div class=\'codetop\']CODE[div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']*.eye5 50 sub sgn 1 sub sgn 1 add -1 mul .shoot store
10 -40 -1 -2 -1
50 0 0 -1 -1 (etc)
60 10 1 0 0
other usefull commands are floor abs sgn and mod
mod like in
*.robage 140 mod 130 sub sgn ==>>> etc to get something trigering after x cycles
or robage 51 mod 49 floor 49 sub...
there is a wikipage about this subject too, somewhere around here, do by writing yourself I think its more easy to understand.
bacillus:
It isn't the most effective way to get things done, but is the only way to get a decent bot down in one store .
Peter B, some quick suggestions:
-DB does have increment/decrement commands, so 1 add becomes ++ and 1 sub becomes --
-To make subtraction easier, use - instead of -1 mult
I posted a topic about conditionless logic in the DNA section a while ago, but am too lazy to find it myself.
Moonfisher:
I thought he ment inline conditions as in conditions inside genes.... but thinking about it, it does sound like he means conditions buildt into a single store...
If you want to see examples of Single Store (SS) bots, then look at the SS league... I think OneManBucket is well dokumented, and if you look for the topic in the starting gate containing Brevis then there's a lot of good tips on how to build and debug a SS bot.
If you mean inline conditions, like the ones used inside a gene (Not in the condition space) then they work just like regular conditions, but they won't get and'ed automaticaly.
The way it works is pretty straight forward, if you put something in the boolean stack while inside a gene then it will be a condition for the following lines in the same gene. The boolean used is always the one on top of the stack, so in order to have several conditions you need to and/or them together.
You can also overide any previous conditions by simply adding a new condition without and/or'ing it with the previous ones.
So if you write :
*.eye5 0 =
140 .aimsx store
*.nrg 100 >
40 .up store
Then the 2 conditions are not related, if eye5 is 0 you will turn, if you have over 100 energy you will move forward.
But if you write :
*.eye5 0 =
140 .aimsx store
*.nrg 100 > and
40 .up store
Then you will only move forward when eye5 is 0 and you have over 100 energy. The boolean stack will contain up to 20 booleans I think.
Then there's some additional operator that you can use, not, dupbool and dropbool can be usefull for cutting condition costs :
*.eye5 0 =
*.nrg 100 > and
*.robage 5 < or
140 .aimleft store
dupbool
*.body 50 < and
40 .up store
dropbool
dupbool
*.in1 123 = and
40 .dx store
dropbool
not
40 .aimright store
This will turn left if eye5 is 0 and you have over 100 nrg or if robage is less than 5. It will move forward if body is also less than 50.
If in1 is 123 and the first set of conditions was true then it will also move sideways (But the body size will be irelevant)
This is because the first set was duplicated before the body 50 < part was added, and then the top boolean was dropped, taking us back to the value from the first set of conditions.
In the end if the first set of conditions amounted to false we turn right.
Not sure I'm doing a good job at explaining this... I think theres a section on the wiki about the integer stack and how it works... the boolean stack is pretty much the same just with booleans... in the end it's just a stack (If you've worked with those before) like in any programing laguage... when you write a condition you push the result into the stack, but instead of poping values from it the top value is just used.
You can also read about the boolean operators on the wiki, generaly most of what you need is found on the sysvars and operators page.
(I currently find myself wishing the source was as welldocumented )
jknilinux:
Sorry, I didn't know I was being vague. Basically, I wanted to make complex viruses, but since they can only be one gene long, I need to find a way to put conditional logic inside a regular gene. So what I needed was just info on the boolean stack and stuff.
Thanks for pointing me in the right direction! I'll figure out the rest.
Navigation
[0] Message Index
[#] Next page
Go to full version