Author Topic: Help needed for MB  (Read 3296 times)

Offline Zype

  • Bot Neophyte
  • *
  • Posts: 3
    • View Profile
Help needed for MB
« on: November 05, 2013, 01:28:07 PM »
I'm new in this and I'm not very good at English, but I'll try to understand anything.
I started with Darwinbots three days ago and I want to create my own multibot, a worm called Guss. This is the idea: three bots united in a chain, a head, a body and a tail. When you put a single bot it is instantly transformed to a head; then, the head generates the body and, finally, the body generates the tail. Sysvars .head, .body and .tail mark the type of bot. I made some trials, but I only get a big crowd of bots out of control.
For any details or suggestions, please contact me.

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Re: Help needed for MB
« Reply #1 on: November 07, 2013, 09:57:24 AM »
MBs are relatively hard to make. Here is a worm example for you:

Code: [Select]
' Seasnake 1.0
' Author:  EricL
' A segmented multibot

' Out variables
' These are broadcast to everyone
def linkstate 800
def mynumexposed 801
def mychain 802

'Tie variables
'These are broadcast via ties
def targetx 415    ' .tout6
def targety 416    '.tout7

'tout1 is mychain
'tout2 is mynum
'tout3 is my linkstate

' Private Variables
'These are private to this bot only
def justreproduced 50
def mynum 51
def mylastx 52
def mylasty 53
def myvelx 54
def myvely 55

'Begin coding region
start

'Initialization
'Anti info shot logic
0 .fixpos store
0 .focuseye store

'Set my unique number
clearbool
*.robage 0 =
*971 0 = and
-30000 32000 rnd .mynum store

'My unique number is one les than my parent if birthed
*.robage 0 =
*.971 0 != and
*.971 dec .mynum store

'Always set a bunch of stuff
clearbool
300 .eye5width store
.dnalen .memloc store
.dnalen .tmemloc store
*.mynum .readtie store
*.mynum .tienum store
*.mynum .971 store
*.mychain .tout1 store
*.mynum .tout2 store
*.linkstate .tout3 store
*.mynum .mynumexposed store
*.xpos *.mylastx sub .myvelx store
*.ypos *.mylasty sub .myvely store

'Tie Feeding Defense
.tieval .tieloc store
1000 .tieval store

'Set my chain number if part of a caterpiller
'If the head or alone, use my number for the chain number for both sight and ties
clearbool
*.linkstate 0 =
*.linkstate 3 = or
*.mynum .mychain store
*.mynum .tout1 store
0 .eye5dir store

'If the tail or in the middle, set my chain number from the guy ahead of me for both sight and ties
'Then set my number to one less than the guy in front of me.
*.linkstate 1 =
*.linkstate 2 = or
*.tin1 .mychain store
*.tin1 .tout1 store
*.tin6 .targetx store
*.tin7 .targety store

*.linkstate 1 =
*.linkstate 2 = or
*.tin2 1 sub .mynumexposed store
*.tin2 1 sub .tout2 store


'Get rid of the birth tie
clearbool
*.robage 1 =
*.mynum .tie store

clearbool
*.robage 2 =
*.tin1 *.mynumexposed <= and
.deltie inc
100 .up store

'Movement
clearbool
*.eye5 0 =
*.linkstate 0 =
*.linkstate 3 = or  and
10 .up store
20 rnd 10 sub .aimdx store

'Find Conspecs
clearbool
*.eye5 0 >
*.memval *.dnalen = and
*.linkstate 1 != and
*.linkstate 2 != and
*.in2 *.mynumexposed > and
*.in1 2 != and
*.in1 3 != and
*.in2 *.mychain != and
*.robage 2 > and
*.justreproduced 0 = and
*.refxpos *.refypos angle .setaim store
*.refveldx *.body mult 1000 div .dx store
*.refvelup 11 add .up store

'Find Prey
clearbool
*.eye5 0 >
*.memval *.dnalen != and
*.robage 2 > and
*.refxpos *.refypos angle .setaim store
*.refveldx .dx store
*.refvelup 10 add .up store
35 .eye5width store

'Look away from your own cells
clearbool
*.linkstate 3 =
*.mychain *.in3 = 
*.mychain *.in3 !=
*.in3 0 != and
*.in2 *.mynum <= and or  and
*.justreproduced 0 = and
*.setaim 314 1 rnd mult 157 sub add .setaim store
0 .eye5width store

'Body Management
'Increase body if body is less than 90% of nrg level
clearbool
*.body 100 mult *.nrg 9 mult <
100 .strbody store

'Release body if body is greater than 110% of nrg
*.body 100 mult *.nrg 11 mult >
100 .fdbody store

'Waste removal
clearbool
*.waste 100 >
*.waste .shootval store
314 .aimshoot store
-4 .shoot store

'Slime Production
clearbool
*.nrg 5000 >
*.slime 100 < and
10 .mkslime store

'Shell Production
*.nrg 5000 >
*.shell 1000 < and
10 .mkshell store

'Antivirus
clearbool
*.thisgene 1 !=
1 .delgene store
*.thisgene 1 =
*.genes 1 > and
2 .delgene store

'Set the linksate
clearbool
*.numties 0 =
0 .linkstate store
*.numties 1 =
*.tmemval *.dnalen = and
*.linkstate 2 =
*.linkstate 0 = or and
*.tiepres *.mynum = and
1 .linkstate store
*.numties 2 =
*.justreproduced 0 = and
*.tmemval *.dnalen = and
*.linkstate 3 =
*.linkstate 1 = or and
2 .linkstate store
*.numties 1 =
*.robage 2 > and
*.linkstate 0 =
*.tiepres *.mynum != and
'This is the case where the head gets shot off.  The guy behind is still linkstate 2 but the tie ahead is gone
*.linkstate 2 =
*.trefxpos 0 =  and or and
3 .linkstate store

'Too many ties or other tie problems
clearbool
*.numties 2 >
*.linkstate 3 =
*.numties 1 > and or
*.linkstate 1 =
*.numties 1 > and or
*.linkstate 0 =
*.numties 0 > and or
*.numties 1 =
*.linkstate 1 !=
*.linkstate 3 != and and or
*.numties 1 =
*.linkstate 1 =
*.tiepres *.mynum != and and or

*.numties 1 =
*.linkstate 2 = and or

*.numties 1 =
*.linkstate 3 = and
*.tiepres *.mynum = and or

'*.linkstate 3 =
'*.tin2 *.mynumexposed > and or

*.linkstate 3 =
*.tin3 3 = and or

'Delete ties from non-conspecs
*.tmemval 0 !=
*.tmemval *.dnalen != and or
*.tiepres .deltie store

'tie to conspec
clearbool
*.linkstate 0 =
*.linkstate 3 = or
*.eye5 0 > and
*.memval *.dnalen = and
*.in3 *.mynumexposed > and
*.in1 0 =
*.in1 1 =
*.refmulti 0 != and or and
*.in3 *.mychain != and
*.mynum .tie store

'follow the leader
clearbool
*.linkstate 1 =
*.linkstate 2 = or
*.tin1 *.mychain = and
*.trefxpos *.trefypos angle .setaim store
*.trefup .up store
*.trefdn .dn store

'Tie too long
clearbool
*.tielen 100 >
*.linkstate 1 =
*.linkstate 2 = or and
*.up 10 add .up store

'Dampen wild swings
clearbool
*.linkstate 3 !=
*.trefvelyoursx *.velsx sub abs 10 > and
*.velsx -1 mult .sx store

'Tie too short
clearbool
*.tielen -50 <
*.tielen 0 != and
*.linkstate 1 =
*.linkstate 2 = or and
*.dn 20 add .dn store

'Keep the tie angle freely rotating
'And set the tie length and stiffness
clearbool
*.multi 0 >
*.linkstate 1 =
*.linkstate 2 = or and
*.mynum .tienum store
-1 .fixang store
25 .fixlen store
100 .stifftie store

'Aim eyes to the rear for the last guy in the chain
clearbool
*.linkstate 1 =
628 .eye5dir store
628 .eye5width store

'Aim eyes to the sides for the middle nodes, alternating them side to side
*.linkstate 2 =
*.mynum 2 mod 628 mult -314 add 628 *.robage 2 mod mult add .eye5dir store
200 .eye5width store

'The head looks ahead as do lone bots
*.linkstate 3 =
*.linkstate 0 = or
0 .eye5dir store

'Target Aquisition
clearbool
0 .targetx store
0 .targety store
*.eye5 0 =
*.tin6 *.tin7 dist 1000 < and
*.tin6 .targetx store
*.tin7 .targety store

*.eye5 0 >
*.memval *.dnalen != and
*.in3 *.mychain != and
*.reftype 0 = and
*.refxpos .targetx store
*.refypos .targety store

'Head Shooting
clearbool
*.linkstate 3 =
100 .shoot store

'Aiming
clearbool
*.targetx 0 !=
*.linkstate 3 != and
*.targetx *.myvelx 2 mult sub .targetx store
*.targety *.myvely 2 mult sub .targety store
*.targetx *.targety angle 1256 add 1256 mod *.aim sub .eye5dir store
35 .eye5width store

'Shooting
'When we see something
clearbool
*.eye5 10 >
*.memval *.dnalen != and
*.in2 *.mychain != and
*.eye5dir -1 mult .aimshoot store
-6 .shoot store

'Power up shots for things close up
*.eye5 20 <
1 .shootval store
*.eye5 20 >=
 5 .shootval store

'Shooting
'When we touch something
clearbool
*.eye5 0 =
*.refxpos 0 != and
*.memval *.dnalen != and
*.in2 *.mychain != and
*.refxpos *.refypos angle -1 mult .aimshoot store
-6 .shoot store
 17 .shootval store

'Sharing
clearbool
*.mynum .tienum store
50 .sharenrg store
50 .shareshell store
50 .shareslime store
100 .sharewaste store

'Reproduction
clearbool
*.justreproduced 5 =
*.setaim 628 add .setaim store

*.justreproduced 0 >
.justreproduced dec

clearbool
*.nrg 5000 >=
*.body 500 >= and
*.linkstate 0 =
*.linkstate 1 = or and
50 .repro store
*.setaim 628 add .setaim store
5 .justreproduced store

'Make sure tie operations operate on the tie this node created
clearbool
*.tiepres *.mynum !=
*.mynum .tiepres store
*.mynum .tienum store

'Store the postion for the next cycle
clearbool
*.xpos .mylastx store
*.ypos .mylasty store

stop
end


Sorry for late reply, I had more pressing issues to deal with, and I start work back up Friday.

Offline Zype

  • Bot Neophyte
  • *
  • Posts: 3
    • View Profile
Re: Help needed for MB
« Reply #2 on: November 07, 2013, 10:19:12 AM »
Thank you for these data. My first design had only three free sysvars and twelve genes, and it doesn't work like I wanted. But there is a problem: I've tried to see how it works, but the bot info says that it has no genes, and I haven't seen any 'start', 'cond' or 'stop' in the DNA code. How can I know where does the gene start?

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Re: Help needed for MB
« Reply #3 on: November 07, 2013, 10:54:01 AM »
Wow, I just realized this is a Single Gene bot as well as an MB.

All I know is this thing behaves like a worm.

The line
Code: [Select]
'Begin coding region
start

Is where the gene starts.

Offline Zype

  • Bot Neophyte
  • *
  • Posts: 3
    • View Profile
Re: Help needed for MB
« Reply #4 on: November 07, 2013, 11:02:32 AM »
OK. I'll use all this information to improve my bot. It's strange... a multibot with only one gene... I suppose that in Darwinbots all is possible. If I have any problem or you have some idea, please use this topic. Thank you again!