Author Topic: First wire layer  (Read 2644 times)

Offline Welwordion

  • Bot Destroyer
  • ***
  • Posts: 325
    • View Profile
First wire layer
« on: April 23, 2006, 10:21:19 AM »
Ok, here is the first running version of a wire laying bot(refer to my post about communication networks). He is programmed to be ant bot type like, so we have a queen that will give birth to the first scout(a wire layer).
Thx to the help of purple youko I could debug most of it, however there still seems to be some bugs regarding gene8 which should prevent the scout from reproducing directly after birth, I could bypass this by setting the age condition to 10 > at gene 10, which will cause him to face  the queen when turning back to lay a satellitebot(wirepart) behind him and such preventing him from blocking himself between his parent and child.
Note also that although I originally wanted to create him for both versions he currently only works in 2.4
as their is no out5 in 2.37 and also some other strange reasonprevents a child to determining his function(job)
using the outchannels.
Nevertheless the delgene command in gene 1 ,and the original distance  calculation in gene9(currently disabled by ')  to use for gene 10 shows that I orignally intended to make him compatible for both:


Code: [Select]
def function 50
'queen 1 scout 3 mob 4 satellite 5
def satposx 70
def satposy 71
def job 153

'1Where was the house again? (save hive position) @good
cond
*.robage 0 =
start
*.xpos 971 store
*.ypos 972 store
.delgene *971 sgn mult inc
.fixpos inc
stop

'2I want to be a mother! (If no one gives you a task you become a queen) @good
cond
*.robage 50 >
*.function 0 =
start
.function inc
.out5 inc
stop

'3:( my childhoods over (assigns a task to you)  
cond
*.numties 0 >
*.function 0 =
*.robage 1 =
start
*.in5 2 add .function store
*.in5 2 add .out5 store
stop


'4Mommy!!! (ties to your parent)
cond
*.robage 5 =
start
1 .tie store
stop


'5I am to old for that (free yourself from the tie )
cond
*.robage 6 =
*.numties 0 >
start
1 .deltie store
stop


'6Go and get snacks for the party. (create a single scout)
cond
*.nrg 5000 >
*.job 0 =
*.function 1 =
start
20 .repro store
.job inc
stop

'7I have no mother fixiation.(turns scout away from mother)
cond
*.robage 7 =
*.function 3 =
start
618 .aimdx store
stop

'8My birthplace is a small town in ...(set your first point for distance measurement)
cond
*.satposx 0 =
*.satposy 0 =
start
*971 .satposx store
*972 .satposy store
stop

'9Our house looks so small from here.(measure distance to the last satellite)
'cond
'start
'*.satposx *.xpos sub 10 div *.satposx *.xpos sub 10 div mult
'*.satposy *.ypos sub 10 div *.satposy *.ypos sub 10 div mult 10 div add
'33 store
'stop

'10breadcrumbs? thats outdated. (place the wire/satellite bots when you reach a certain ditance)
cond
*.function 3 =
*.robage 10 >
'*33 6000 >
*.satposx *.satposy dist 800 >
start
*.xpos .satposx store
*.ypos .satposy store
618 .aimdx store
5 .repro  store
.fixpos inc
stop

'11What was I doing again? (resume moving after placing the satellite)
cond
*.refage 0 =
*.eye5 0 >
*.refeye *.myeye =
*.function 3 =
start
618 .aimdx store
.fixpos dec
stop

'12Maybe its a little more ahead?(scout moves on if he sees nothing)
cond
*.function 3 =
*.eye5 0 =
start
10 .up store
.fixpos *.fixpos sgn mult dec
stop

'13yo buddy where are you going? (food our enemy coordinates are shown in out1 and out2)
cond
*.function 5 =
*.refeye *.myeye !=
start
*.refxpos .out1 store
*.refypos .out2 store
stop

'14rumours travel faster then light XD
'(reads info about coordinates and show it in out1 and out2 for the next bot in line)
cond
*.function 5 =
*.refeye *.myeye =
start
*.in1 .out1 store
*.in2 .out2 store
stop

'15lets get internet(satellites tries to get the next satelitte in eye5 so he can read his outs)
cond
*.eye5 0 =
*.function 5 =
start
10 *.eye1 *.eye2 add *.eye3 add *.eye4 add *.eye6 sub *.eye7 sub *.eye8 sub *.eye9 sub sgn mult .aimsx store
stop

'16heh that looks interesting ( turns toward nearest bot)
cond
*.function 3 =
*.refeye *.myeye !=
start
*.eye1 dup *.eye2 sub abs add *.eye2 add 2 div
dup *.eye3 sub abs add *.eye3 add 2 div
dup *.eye4 sub abs add *.eye4 add 2 div
dup *.eye5 sub abs add *.eye5 add 2 div
dup *.eye6 sub abs add *.eye6 add 2 div
dup *.eye7 sub abs add *.eye7 add 2 div
dup *.eye8 sub abs add *.eye8 add 2 div
dup *.eye9 sub abs add *.eye9 add 2 div

dup dup *.eye5 sub sgn 1 sub abs 5 mult add
dup *.eye6 sub sgn 1 sub abs 6 mult add
dup *.eye4 sub sgn 1 sub abs 4 mult add
dup *.eye7 sub sgn 1 sub abs 7 mult add
dup *.eye3 sub sgn 1 sub abs 3 mult add
dup *.eye6 sub sgn 1 sub abs 8 mult add
dup *.eye2 sub sgn 1 sub abs 2 mult add
dup *.eye9 sub sgn 1 sub abs 9 mult add
dup *.eye1 sub sgn 1 sub abs 1 mult add
sub abs

5 sub 35 mult .aimdx store
stop

'17ok you have guard duty(satelites become fixed)
cond
*.function 5 =
*.robage 7 =
start
.fixpos inc
stop


'18the ample is red(stop when you get close enough to an object)
cond
*.refeye *.myeye !=
*.eye5 35 >
*.function 3 =
start
.fixpos inc
stop

end

Well as I said to yoko the next step will be to programm wires that work in both direction or can move along their scout(using the radius/distance from the hive) and also to add the mob(workers/hunters) that uses the information in out1 and out2 to find food.
« Last Edit: April 23, 2006, 10:25:06 AM by Welwordion »