Author Topic: Aiming/moving problems  (Read 3979 times)

Offline Testlund

  • Bot God
  • *****
  • Posts: 1574
    • View Profile
Aiming/moving problems
« on: September 15, 2014, 02:43:40 PM »
EDIT: Blah-blah-rant...

Code: [Select]
The correct code is posted below!

                ||
                ||
                ||
              \\||//
               \\//
                           
« Last Edit: September 15, 2014, 06:30:28 PM by Testlund »
The internet is corrupt and controlled by criminally minded people.

Offline Testlund

  • Bot God
  • *****
  • Posts: 1574
    • View Profile
Re: Aiming/moving problems
« Reply #1 on: September 15, 2014, 03:38:16 PM »
It doesn't execute the code in the correct order! I want the bot to set the angle, then turn around and THEN move!

cond
 *.eyef 0 >
start
  *.refxpos *.refypos angle .setaim store
 628 .aimdx store
 64 .up store
stop

It doesn't matter which order I place the code. The bot always moves forward before it turns!  :blueblob:
The internet is corrupt and controlled by criminally minded people.

Offline Shadowgod2

  • Bot Destroyer
  • ***
  • Posts: 387
    • View Profile
Re: Aiming/moving problems
« Reply #2 on: September 15, 2014, 04:08:06 PM »
Use a trigger

cond
*50 1 =
start
...
stop

cond
*.eyef 0 >
start
628 .turnsx store
1 50 store
stop

Something like that

Offline Testlund

  • Bot God
  • *****
  • Posts: 1574
    • View Profile
Re: Aiming/moving problems
« Reply #3 on: September 15, 2014, 05:00:06 PM »
What is the number 50 here supposed to do. You mean .aimsx, not .turnsx, right? If I use this the bot will just turn, not move away:

cond
*.eyef 0 >
start
628 .aimsx store
1 50 store
stop

But I found if I use .dn instead the bot will get away better.

cond
 *.eyef 0 >
start
 64 .dn store
 *.refxpos *.refypos .setaim store
 628 .aimdx store
stop


The internet is corrupt and controlled by criminally minded people.

Offline Peter

  • Bot God
  • *****
  • Posts: 1177
    • View Profile
Re: Aiming/moving problems
« Reply #4 on: September 15, 2014, 05:01:31 PM »
It doesn't execute the code in the correct order! I want the bot to set the angle, then turn around and THEN move!

cond
 *.eyef 0 >
start
  *.refxpos *.refypos angle .setaim store
 628 .aimdx store
 64 .up store
stop

It doesn't matter which order I place the code. The bot always moves forward before it turns!  :blueblob:
The order of the code doesn't matter. There's a solid order of actions, I don't know where it was described, but it's somewhere on the forom, I think EricL wrote it down. Apparently moving goes before turning, so you need to turn and then you can move forward the next cycle.

Moving backwards works even better. :P
« Last Edit: September 15, 2014, 05:03:16 PM by Peter »
Oh my god, who the hell cares.

Offline Shadowgod2

  • Bot Destroyer
  • ***
  • Posts: 387
    • View Profile
Re: Aiming/moving problems
« Reply #5 on: September 15, 2014, 05:09:58 PM »
That's why I said use triggers. 50 was ment to be that trigger and yas aimsx not turnsx. I am typing on iPod and is difficult sorry

Moving back is better though

Offline Testlund

  • Bot God
  • *****
  • Posts: 1574
    • View Profile
Re: Aiming/moving problems
« Reply #6 on: September 15, 2014, 05:27:54 PM »
I think I got everything working now! Ignore the post at the top at the moment. I will update soon.
The internet is corrupt and controlled by criminally minded people.

Offline Testlund

  • Bot God
  • *****
  • Posts: 1574
    • View Profile
Re: Aiming/moving problems
« Reply #7 on: September 15, 2014, 06:23:55 PM »
Ok, I got it working now, though it can of course be improved upon.

If you load this sim you will have bots at different ages. They're designed to behave differently according to their age.

Try adding bots every 5000 cycles to see how it works. You can also place bots with a 5000 age difference close to each other so you don't have to wait for it.

Code: [Select]
def births 50

'Maximum alertness required
start
 250 .eye3dir store
 75 .eye4dir store
 -75 .eye6dir store
 -250 .eye7dir store
stop

start
 250 .eye3width store
 100 .eye4width store
 45 .eye5width store
 100 .eye6width store
 250 .eye7width store
stop

cond
 *.robage 0 =
start
 628 .aimdx store
stop

cond
 *.robage 2
start
 0 .focuseye store
stop

cond
 *.robage 4 mod 0 =
start
 -1 .focuseye store
stop

cond
 *.robage 4 mod 1 =
start
 1 .focuseye store
stop

cond
 *.robage 6 mod 0 =
start
 -6 .focuseye store
stop

cond
 *.robage 6 mod 1 =
start
 2 .focuseye store
stop

'Better get away before my parents eat me!
cond
 *.robage 128 <
start
  64 .up store
stop

'If I see a tie bot I will make slime and delete any ties.
cond
 *.eyef 0 >
 *.reftie 0 >
 *.slime 2000 <
 *.nrg 2000 >
start
 1000 .mkslime store
 *.tiepres .deltie store
stop

'Ouch! Time to flee!
cond
 *.shflav -1 = or
 *.shflav -6 =
start
 *.shang sub .setaim store
 *.maxvel .up store
stop

'Non-shooting bots are safe to eat.
cond
 *.eyef 0 >
 *.reftype 1 !=
 *.refshoot 0 =
start
 *.refxpos *.refypos angle .setaim store
 .up store
 -6 .shoot store
stop

'But if a shooting bot is smaller than me I think I can eat it.
cond
 *.eyef 0 >
 *.reftype 1 !=
 *.refshoot 0 >
 *.refbody *.body <
 *.refbody *.body !%=
start
 *.refxpos *.refypos angle .setaim store
 *.refveldx .dx store
 *.refvelup 16 add .up store
 16 .shootval store
 -6 .shoot store
stop

If I'm female and see a male I should stay around (Not sure if this DNA does it right though).
cond
 *.robage 5000 >
 *.robage 10000 <
 *.eyef 0 >
 *.refshoot *.myshoot =
 *.refup *.myup =
 *.refaimsx *.myaimsx =
 *.refage 10000 >
 *.refage 15000 <
start
 *.refxpos *.refypos angle sub .setaim store
 .dn inc
stop

'If I'm male and see a female it's time to make babies, unless I'm not hungry. Then I'll eat her instead!
cond
 *.robage 10000 >
 *.robage 15000 <
 *.eyef 0 >
 *.refage 5000 >
 *.refage 10000 <
 *.refshoot *.myshoot =
 *.refup *.myup =
 *.refaimsx *.myaimsx =
 *.refbody 500 >
 *.refbody *.body <
 *.nrg *.body >
start
 *.refxpos *.refypos angle .setaim store
 *.refveldx .dx store
 *.refvelup 16 add .up store
 -8 .shoot store
stop

'Metabolism
cond
 *.nrg *.body >
start
 10 .strbody store
stop

'Time to poop!
cond
 *.waste 1000 >
start
 628 .aimshoot store
 -4 .shoot store
 1000 .shootval store
stop

'Has to use my fat reserves cause I'm starving!
cond
 *.nrg 128 <
start
 100 .fdbody store
stop

'Navigation
cond
 *.eye4 25 >
start
 -50 .aimright store
stop

cond
 *.eye6 25 >
start
 50 .aimright store
stop

'Being hungry makes me wanna search around for food.
cond
 *.nrg 32 >
 *.body *.nrg >
start
 32 rnd .aimsx store
 32 rnd .aimdx store
 .up inc
stop

'Stearing away from those shapes.
cond
 *.eye4 50 >
 *.reftype 1 =
start
 157 .aimright store
stop

cond
 *.eye6 50 >
 *.reftype 1 =
 *.edge 0 !>
start
 -157 .aimright store
stop

'The edge. No way forward here.
cond
 *.edge 0 >
start
 157 rnd .aimsx store
stop

'Making babies is costly. No more than 5 at a time. (though the counter stops already at 3-5 births)
cond
 *.shflav -8 =
 *.body 1000 >
 *.nrg 1000 >
 *.robage 5000 >
 *.robage 10000 <
 *.births 5 <=
start
 5 .sexrepro store
 .births inc
 314 rnd .aimdx store
stop

'No more mating now! I have to eat first.
cond
 *.eyef 0 >
 *.refshoot *.myshoot >=
 *.refup *.myup =
 *.refaimsx *.myaimsx =
 *.refage 10000 >
 *.births 4 >
start
 64 .dn store
 *.refxpos *.refypos .setaim store
 628 .aimdx store
stop

'Alright I think I can handle another pregnancy now.
cond
 *.body 3000 >
 *.nrg 3000 >
start
 0 .births store
stop

'Can't wait for a male here. Better multiply by myself before my species die out.
cond
 *.robage 5000 >
 *.robage 10000 <
 *.Body 64 >
 *.nrg 64 >
 *.totalmyspecies 5 <
start
 50 .repro store
 314 rnd .aimdx store
stop

'Protection against body shots.
cond
 *.nrg 999 >
 *.body 999 >
 *.shell 34 <
start
 300 .mkshell store
stop

cond
 *.nrg 1999 >
 *.body 1999 >
 *.shell 68 <
start
 600 .mkshell store
stop

cond
 *.nrg 3999 >
 *.body 3999 >
 *.shell 334 <
start
 1000 .mkshell store
stop

cond
 *.nrg 7999 >
 *.body 7999 >
 *.shell 668 <
start
 2000 .mkshell store
stop

cond
 *.nrg 15999 >
 *.body 15999 >
 *.shell 334 <
start
 5000 .mkshell store
stop

'I'm just a kid so I better stay away from those grown-ups.
cond
 *.robage 5000 <
 *.eyef 0 >
 *.refshoot *.myshoot >=
 *.refbody *.body >
start
 628 .aimdx store
 *.maxvel 64 add .dn store
stop

'I'm getting old. My senses are not as alert as they used to be.
cond
 *.robage 32000 =
start
 0 .eye1dir store
 0 .eye2dir store
 0 .eye3dir store
 0 .eye4dir store
 0 .eye6dir store
 0 .eye7dir store
 0 .eye8dir store
 0 .eye9dir store
 0 .eye1width store
 0 .eye2width store
 0 .eye3width store
 0 .eye4width store
 0 .eye5width store
 0 .eye6width store
 0 .eye7width store
 0 .eye8width store
 0 .eye9width store
 0 .focuseye store
stop

end
The internet is corrupt and controlled by criminally minded people.