Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - rayz

Pages: [1]
1
Interesting behaviour bots / Bot test 1
« on: April 03, 2009, 04:58:02 PM »
Since I went through all of the trouble to make it a bot to test my algorithm, I thought I might post it here.

It's an interesting behavior bot.  It approimates sine and cosine for use with direction setting. I think most of the stuff is explained in the comments.

I commented out a tracking and shooting section.  If you uncomment it (except for the shooting part), and make a new version with more .up store commands, you can have the two species of bots just run straight at each other and go into complex little loops.    

Anyway, here it is!

Works best in no costs environment, too inefficient to run otherwise.
Code: [Select]
'An attempt to make the bot move north no matter how it is turned.
'Lacks precision due to a integer-only stack.
'Attempt to correct that by waiting to divide bigs numbers till end.
'
'edit these to wherever--maybe pi should be epigenetic?
'sineIn and sineOut are input/output for Taylor series
'sineOut returns a number multiplied by factor2 (approx.)
'pi and factor are internal constants for sine calculation
'aimHeading is the absolute heading that the bot wants to travel
'magnitude is how approximately how fast (in Darwinbots units) the bot will travel
'turn is how much the bot itself turns each cycle--useful to sweep area around the bot
'aimTurn is how much the bot changes the heading each cycle.
def sineIn 50
def sineOut 51
def pi 52
def factor 53
def aimHeading 410
def magnitude 54
def turn 55
def aimTurn 56
def factor2 57

'set constants
cond
*.robage 1 =
start
31415 .pi store
10000 .factor store
32000 .factor2 store
100 .magnitude store
0 .aimHeading store
*.tiepres .deltie store
35 .turn store
5 .aimTurn store
'just to move them out of the way
1221 .eye1width store
1221 .eye2width store
1221 .eye3width store
1221 .eye4width store
'1221 .eye5width store
1221 .eye6width store
1221 .eye7width store
1221 .eye8width store
1221 .eye9width store
stop

'manage body
cond
*.body 10 <
*.nrg 300 >
start
100 .strbody store
stop

cond
*.nrg 500 <
*.body 10 >
start
10 .fdbody store
stop

cond
start
*.aim *.turn add .setaim store
*.aimHeading *.aimTurn add .aimHeading store
stop

'try to aim the eye and shoot
'cond
'*.refup *.myup !=
'*.eye5 0 !=
'start
'*.refxpos *.refypos angle .aimHeading store
'*.aimHeading *.aim sub *.turn sub .eye5dir store
'*.turn *.aim add *.aimHeading sub .aimshoot store
'-6 .shoot store
'*.nrg 2 div .shootval store
'stop
'
'cond
'*.waste 100 >
'start
'-4 .shoot store
'*.waste .shootval store
'stop

'begin movement section: it makes the bot move in the direction of aimHeading
'normalize aimheading
cond
*.aimHeading 1256 >=
start
*.aimHeading 1256 sub .aimHeading store
stop

cond
*.aimHeading 0 <
start
*.aimHeading 1256 add .aimHeading store
stop

'from here down it makes the bot move in the direction of *.aimheading
cond
start
*.aimHeading *.aim sub .sineIn store
stop

'begin sineIn normalization
cond
*.sineIn 0 <
start
*.sineIn 1256 add .sineIn store
stop

cond
*.sineIn 1256 >
start
*.sineIn 1256 sub .sineIn store
stop

'Taylor expansion of sine function
cond
start
628 *.sineIn sub *.pi mult 628 div *.factor div 1 pow *.factor2 mult 1 div 628 *.sineIn sub *.pi mult 628 div *.factor div 3 pow *.factor2 mult 6 div sub 628 *.sineIn sub *.pi mult 628 div *.factor div 5 pow *.factor2 mult 120 div add 628 *.sineIn sub *.pi mult 628 div *.factor div 7 pow *.factor2 mult 5040 div sub .sineOut store
stop

cond
start
*.sineOut *.magnitude mult *.factor2 div .sx store
stop

'calculate value for .up
cond
start
314 *.aimHeading *.aim sub sub .sineIn store
stop

cond
*.sineIn 0 <
start
*.sineIn 1256 add .sineIn store
stop

cond
*.sineIn 1256 >
start
*.sineIn 1256 sub .sineIn store
stop

'Taylor expansion of sine function
cond
start
628 *.sineIn sub *.pi mult 628 div *.factor div 1 pow *.factor2 mult 1 div 628 *.sineIn sub *.pi mult 628 div *.factor div 3 pow *.factor2 mult 6 div sub 628 *.sineIn sub *.pi mult 628 div *.factor div 5 pow *.factor2 mult 120 div add 628 *.sineIn sub *.pi mult 628 div *.factor div 7 pow *.factor2 mult 5040 div sub .sineOut store
stop

cond
start
*.sineOut *.magnitude mult *.factor2 div .up store
stop
'end movement section

'cond
'*.nrg 500 >
'*.body 1000 >=
'start
'50 .repro store
'stop
end

2
DNA - General / Multibot movement ideas
« on: January 06, 2009, 09:56:01 PM »
Please forgive me if I'm being redundant and rambling.  I can be that way.   

I was thinking about how to move a large multibot.  I was thinking that one of the major problems in moving a large multibot is the difficulty in making each individual bot face the same direction... so I was trying to create an algorithm to make each individual bot move the same direction, no matter what the heading of the bot is at the time.   So this is my small mini-algorithm:

sine and cosine take the top value from the stack, and give back the sine and cosine values for that number (in Darwinbot units).
heading is a variable that is passed along ties-- it shows what heading the bots want to move in.
magnitude is a variable that is passed along ties-- it shows how fast the bot wants to move in the particular direction.

Code: [Select]
cond
start
heading *.angle sub cosine magnitude mult .up store
heading *.angle sub sine magnitude mult .dx store
stop

If this worked, then the heading could be determined by some sort of queen, and passed along to each bot using ties-- so each bot would move in the same direction, preventing the need for more complicated algorithms to deal with other suff.

It wasn't until I tried to implement this that I realized that the sine and cosine functions don't exist!    I then started thinking that a sine and function would be so nice to have...   Does anyone know if a sine and cosine function exist?  If so, what are they?  If not, how should I mimic them?

Thankee all!

-rayz

3
F1 bots / Bot v 1.1
« on: January 05, 2009, 05:33:39 PM »
The predecessor of the no fixpos version...found that fixpos could be quite helpful.

Code: [Select]
def enemysighted 50
def foodxpos 51
def foodypos 52

cond
start
-8 .shootval store
stop

cond
*.body 50 <
*.nrg 200 >
start
100 .strbody store
stop

cond
*.body 50 >
start
10 .fdbody store
stop

'eye5 goes all around, eye1 now points forward
'eye1 at 0
'eye2 at 157 right
'eye3 at 314
'eye4 at 471
'eye6 at 628
'eye7 at 785
'eye8 at 942
'eye9 at 1099
'cond
'start
'1221 .eye5width store
'157 .eye1width store
'157 .eye2width store
'157 .eye3width store
'157 .eye4width store
'157 .eye6width store
'157 .eye7width store
'157 .eye8width store '35
'157 .eye9width store
'-140 .eye1dir store '0
'-262 .eye2dir store '1
'-384 .eye3dir store '2
'-506 .eye4dir store '3
'-593 .eye6dir store '4
'-715 .eye7dir store '5
'-837 .eye8dir store '6
'-959 .eye9dir store '7
'stop

cond
start
*.tiepres .deltie store
stop

cond
start
359 .aimsx store
*.maxvel .up store
stop

'I've arrived at the spot, but no food...better stop looking.
cond
*.foodxpos 100 + *.xpos >= *.foodxpos 100 - *.xpos > |
*.foodypos 100 + *.ypos >= *.foodypos 100 - *.ypos > |
*.enemysighted 0 =
start
0 .out1 store
0 .out2 store
0 .out3 store
0 .foodxpos store
0 .foodypos store
0 .shoot store
stop

'Oh no, lost sight of it!
cond
*.refshoot *.myshoot = *.eye5 0 = |
*.enemysighted 1 =
start
0 .out1 store
0 .out2 store
0 .out3 store
0 .enemysighted store
0 .shoot store
0 .foodxpos store
0 .foodypos store
stop

'cond
'*.eye5 0 >
'start
'0 .aimsx store
'*.maxvel .up store
'stop

'Someone's telling me where the food is!
cond
*.refshoot *.myshoot =
*.enemysighted 0 =
*.in1 0 !=
*.in2 0 !=
start
*.in2 .out2 store
*.in3 .out3 store
*.in2 .foodxpos store
*.in3 .foodypos store
0 .aimsx store
0 .shoot store
stop

cond
*.refshoot *.myshoot =
start
0 .out1 store
0 .fixpos store
stop

cond
*.foodxpos 0 !=
*.foodypos 0 !=
*.enemysighted 0 =
start
*.foodxpos *.foodypos angle .setaim store
0 .aimsx store
*.maxvel .up store
0 .shoot store
stop

'Let the chase begin!
cond
*.eye5 0 !=
*.refshoot *.myshoot !=
start
1 .out1 store
*.refxpos .out2 store
*.refypos .out3 store
1 .enemysighted store
*.refxpos *.refypos angle .setaim store
0 .aimsx store
*.maxvel .up store
0 .fixpos store
0 .foodxpos store
0 .foodypos store
stop

cond
*.eye5 75 >
*.refshoot *.myshoot !=
start
1 .fixpos store
stop

cond
*.eye5 0 !=
*.refshoot *.myshoot !=
start
-6 .shoot store
stop

cond
*.eye5 25 <
*.refshoot *.myshoot !=
start
0 .fixpos store
0 .aimsx store
'*.refxpos *.refypos angle .setaim store
*maxvel .up store
stop

cond
*.eye5 25 >
*.refshoot *.myshoot =
1 0 =
start
*.maxvel .down store
0 .fixpos store
0 .up store
0 .shoot store
stopd

'Reproduce
cond
*.nrg 1000 >
*.fixpos 0 !=
start
50 .repro store
0 .fixpos store
0 .aimsx store
0 .up store
*.maxvel .dn store
stop

cond
*.nrg 1000 >
*.fixpos 0 =
start
0 .aimsx store
50 .repro store
stop

end
*.refxpos *.refypos angle .setaim store

4
Interesting behaviour bots / Hunter Special Follower
« on: January 05, 2009, 05:03:49 PM »
Follows enemy bots.  Strangely effective for the little work I've put into it.

5
Interesting behaviour bots / Bot v 1.1 no fixpos
« on: January 05, 2009, 04:54:42 PM »
A bot that does well when the veggies are fixed.  Tries to swarm enemies.

6
Simulation Emporium / Planet Eater Experimentation
« on: January 05, 2009, 04:38:56 PM »
Some fun with the planet eaters motion!  Run it on "fast" mode for the best effects (faster movement!).

7
Internet Mode Commentary / Multibot teleport problems
« on: April 05, 2008, 09:17:28 PM »
I didn't know if there was a topic like this before, but here goes:

When I started my sim, I loaded "Massed Hunter with Poison and Shell and Slime" as a starting bot.  After a while, the bots started to coalese into a huge mass of bots all connected with hardened ties.  Then I turned on Internet Mode.  However, the teleporter refused to teleport my bots-- it treated them as one huge organism, attempted to save it as an organism file,  and failed miserably.  Now I just have this mass of bots in my sim that will not teleport.  Anyone have a tip to help me teleport my bots?

Thanks!

-rayz

8
This is my first entry- the "Massed Hunter with poison and shell and slime".  Not a very original name, but all I could come up with. This is still a work in progress as I test it against other bots and tweak it.  Fires ties to anchor itself to food and then fires away at it.  It is meant for a food-intensive environment, as it just plows through all food.  Anyway, the code is below.

[you]MOST RECENT VERSION:[/you]
Code: [Select]
cond
*.nrg 750 >
*.body 1000 <
start
100 .strbody store
stop

cond
*.nrg 500 <
*.body 1 >
start
100 .fdbody store
stop

cond
*.shell 100 <
*.nrg 750 >
start
100 .mkshell store
stop

cond
*.slime 100 <
*.nrg 750 >
start
100 .mkslime store
stop

cond
*.poison 100 <
*.nrg 750 >
start
100 .strpoison store
7 .ploc store
stop

cond
start
420 .eye1dir store
315 .eye2dir store
210 .eye3dir store
105 .eye4dir store
-105 .eye6dir store
-210 .eye7dir store
-315 .eye8dir store
-420 .eye9dir store
stop

cond
start
105 .eye1width store
105 .eye2width store
105 .eye3width store
105 .eye4width store
105 .eye5width store
105 .eye6width store
105 .eye7width store
105 .eye8width store
105 .eye9width store
stop

cond
start
-4 .focuseye store
stop

cond
*.eye1 0 >
*.refaimsx *.myaimsx !=
start
560 .aimsx store
0 .aimdx store
stop

cond
start
4 .focuseye store
stop

cond
*.eye9 0 >
*.refaimsx *.myaimsx !=
start
560 .aimdx store
0 .aimsx store
stop

cond
start
-3 .focuseye store
stop

cond
*.eye2 0 >
*.refaimsx *.myaimsx !=
start
420 .aimsx store
0 .aimdx store
stop

cond
start
3 .focuseye store
stop

cond
*.eye8 0 >
*.refaimsx *.myaimsx !=
start
420 .aimdx store
0 .aimsx store
stop

cond
start
-2 .focuseye store
stop
cond
*.eye3 0 >
*.refaimsx *.myaimsx !=
start
280 .aimsx store
0 .aimdx store
stop

cond
start
2 .focuseye store
stop

cond
*.eye7 0 >
*.refaimsx *.myaimsx !=
start
280 .aimdx store
0 .aimsx store
stop

cond
start
-1 .focuseye store
stop

cond
*.eye4 0 >
*.refaimsx *.myaimsx !=
start
140 .aimsx store
0 .aimdx store
stop

cond
start
1 .focuseye store
stop

cond
*.eye6 0 >
*.refaimsx *.myaimsx !=
start
140 .aimdx store
0 .aimsx store
stop

cond
start
0 .focuseye store
stop

cond
*.eye5 0 >
*.refaimsx *.myaimsx !=
*.numties 0 =
start
0 .aimsx store
0 .aimdx store
*.maxvel .up store
1 .tie store
0 .stifftie store
stop

cond
*.eye5 25 >
*.refaimsx *.myaimsx !=
*.refnrg 0 >
*.numties 0 =
start
-1 .shoot store
4 .shootval store
*.maxvel .up store
stop

cond
*.eye5 25 >
*.refaimsx *.myaimsx !=
*.refnrg 200 <
*.refbody 1 >
*.numties 0 =
start
-6 .shoot store
4 .shootval store
10 .up store
stop

cond
*.eye5 0 >
*.refaimsx *.myaimsx !=
*.numties 0 !=
start
0 .aimsx store
0 .aimdx store
10 .up store
1 .tie store
0 .stifftie store
stop

cond
*.eye5 25 >
*.refaimsx *.myaimsx !=
*.refnrg 0 >
*.numties 0 !=
start
-1 .shoot store
4 .shootval store
10 .up store
stop

cond
*.eye5 25 >
*.refaimsx *.myaimsx !=
*.refnrg 200 <
*.refbody 1 >
*.numties 0 !=
start
-6 .shoot store
4 .shootval store
10 .up store
stop

cond
*.eye5 0 >
*.refaimsx *.myaimsx =
start
1 .tie store
630 .aimsx store
0 .aimdx store
0 .stifftie store
stop

cond
*.eye1 0 =
*.eye2 0 =
*.eye3 0 =
*.eye4 0 =
*.eye5 0 =
*.eye6 0 =
*.eye7 0 =
*.eye8 0 =
*.eye9 0 =
*.numties 0 =
start
5 .up store
stop

cond
*.nrg 100 <
*.eye5 50 >
*.refaimsx *.myaimsx =
start
1 .shootval store
-2 .shoot store
stop

cond
*.waste 100 >
*.refaimsx *.myaimsx !=
start
-4 .shoot store
*.waste .shootval store
stop

cond
*.fixpos 0 !=
start
0 .fixpos store
stop

cond
*.nrg 1000 >
start
50 .repro store
stop
end

Oh, this may also be considered mult-bot, as it fires ties which usually become permanent and allow the movement of a group instead of only the individual.

Pages: [1]