Darwinbots Forum

Bots and Simulations => DNA - General => Topic started by: Testlund on September 09, 2014, 12:35:19 PM

Title: Smart avoiding bahavior
Post 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:

Code: [Select]
cond
 *.shflav -1 =
 *.shflav -6 = or
start
 *.aim *.shang .setaim store
 100 .up store
stop
Title: Re: Smart avoiding bahavior
Post by: Testlund on September 09, 2014, 05:57:23 PM
I suppose this is the best there is:

 *.shang sub .setaim store
 *.maxvel .up store
Title: Re: Smart avoiding bahavior
Post by: Botsareus on September 09, 2014, 06:01:38 PM
[Warning]Nooby qustion [/Warning]

Testlund, what does shang do?
Title: Re: Smart avoiding bahavior
Post by: Botsareus on September 09, 2014, 06:29:25 PM
Oh, shot angle, got it.  8)

Sorry, I was cooking, wanted a quick anws.
Title: Re: Smart avoiding bahavior
Post by: Numsgil on September 11, 2014, 11:46:13 PM
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.
Title: Re: Smart avoiding bahavior
Post by: Testlund on September 12, 2014, 05:09:04 AM
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.