Darwinbots Forum
Bots and Simulations => DNA - General => Topic started by: Testlund on September 09, 2014, 12:35:19 PM
-
I'm trying to get a bot to swim the hell out of the way when it gets hit by hostile fire, but none of the combinations I try are effective. It either ends up making crazy turns are swim directly at the bot shooting at it. Any suggestions?
This is the best I've found so far but it's not good enough:
cond
*.shflav -1 =
*.shflav -6 = or
start
*.aim *.shang .setaim store
100 .up store
stop
-
I suppose this is the best there is:
*.shang sub .setaim store
*.maxvel .up store
-
[Warning]Nooby qustion [/Warning]
Testlund, what does shang do?
-
Oh, shot angle, got it. 8)
Sorry, I was cooking, wanted a quick anws.
-
I suppose this is the best there is:
*.shang sub .setaim store
*.maxvel .up store
You probably want to use *.shang - .setaim store
That is, sub is a binary command, so it's going to pull two values from teh stack. If there's only one, it'll get a 0 value, and do what you expect, but if there's still a number on the stack for whatever reason it won't do what you expect. The - command is a unary command, and negates the top value of the stack.
See the wiki page on negate (http://wiki.darwinbots.com/w/-) for more (well, not really :)) details.
-
I tried your suggestion but it doesn't seem to make any difference. The problem is that it will turn for each shot that hits it, but it doesn't go on to the next line that tells it to move away.
Here is one that works fairly well:
*.refxpos *.refypos angle sub .setaim store
32 .up store
If I replace "sub" here with "-" I get a weird result where the bot just keeps switching back and forth if it sees something.
What makes it particularly problematic is that the dna is dependent on what other instructions are written and in what order they occur. Sometimes it just ignores instructions.