Bots and Simulations > Bot Tavern

How do you make a bot stop moving?

<< < (4/6) > >>

Testlund:
I must be adding the code in the wrong place then, because all I get is a bot twitching with movement vectors pointing in 4 directions, or the code is completely ignored.

I want a bot that moves away a short distance just to get out of the way of a shooting bot and then stop moving.

Panda:
whos piece of code mine or pete's

Testlund:
This makes the bot move forever:

[div class=\'codetop\']CODE[div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']start
*.refxpos 0 >
*.refxpos *.refypos angle .setaim store
8 .shootval store
-6 .shoot store
stop
start
*.nrg 16000 >
10 .strbody store
stop
start
*.body 16000 >
50 .repro store
15 .aimdx store
stop
cond
  *.shflav -1 =
  *.shflav -6 = or
start
  *.maxvel .up store
  *.maxvel .dx store
stop

cond
  *.shflav 0 =
start
  *.velup - .up store
  *.veldx - .dx store
stop

Moonfisher:
Don't forget to reset .shflav, it isn't done automaticaly...
.up however is reset automaticaly, so for instance :

*.shflav 0 !=
0 .shflav store
*.aim *.shang sub .setaim store '(This line just aims in the direction you where shot from, I can't remember if aim is adjusted before movement, but I think it is)
*.maxvel .dn store

This should give you full power for one cycle then stop acceleration, if there's no fluid resistance you may keep moving though, otherwise you should stop by yourself.

Countering movement speed is a bit tricky if you're also turning, since you'll keep trying to adjust in every direction.

If you have no fluids and you want to stop fast, you can use 1 .fixpos store to stop completely and lock in place. (Just have .fixpos dec in a gene with no condition at the start of your code)

Testlund:
Yes! That did it! Here's the complete bot:

[div class=\'codetop\']CODE[div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']start
*.refxpos 0 >
*.refxpos *.refypos angle .setaim store
8 .shootval store
-6 .shoot store
stop
start
*.nrg 16000 >
10 .strbody store
stop
start
*.body 16000 >
50 .repro store
15 .aimdx store
stop
cond
*.shflav -1 =
start
25 .up store
stop
cond
*.shflav -6 =
start
25 .dn store
stop
start
*.shflav 0 !=
0 .shflav store
*.aim *.shang sub .setaim store
*.maxvel .dn store
stop

It has a hard time escaping an efficient hunter though, but it's ok.  

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version