Author Topic: Hive 0.2 (F2, I guess)(22-05-2008)  (Read 3754 times)

Offline goffrie

  • Bot Builder
  • **
  • Posts: 65
    • View Profile
Hive 0.2 (F2, I guess)(22-05-2008)
« on: May 21, 2008, 09:45:09 PM »
This is an antbot-type bot, with multiple energy-sharing "queens" and a  lot of workers. A conspec system which puts *.timer in *.out5 and/or  *.out6 allows each bot to be loyal only to its own colony. (out5 is for  queens only, out6 is for everyone) There is a problem with workers  clumping around the hive - I tried to fix this by placing a timeout on  how long each worker can stay near the hive, but it didn't work too  well. Also, the conspec system is often a cycle late and I could not  stop the queens from sometimes tying to non-queens. The workers will  automatically delete the ties, but sometimes another bot (often a  veggy) will get tied and the workers will try to kill it, but will also  be killing the queen(s). Any help with these problems would be appreciated.
 
  Run this bot with a very small initial count (one per hive) and place  it in a large field with lots of veggies. (32000x24000 would be optimal  because it uses .xpos and .ypos to locate the hive.) Try to keep them away from being next to a corner, as that will probably mess up some of the worker logic.

I'm aware that the workers' eye genes are suboptimal but I'm too lazy to fix them. Basically, eyes 1-4 are unused.

Here is the DNA:
Code: [Select]
   'PyHive0.2.txt compiled by PyBot V2 from PyHive0.2.pyr.
   def hivexpos 971
   def hiveypos 972
   def status 973
   def queen 974
   def counter 53
   def return 54
   def first 55
   def seen 56
   def counter2 57
   cond
   *.status 0 =
   start
   *.refveldx dup *.dx != .dx store
   *.refvelup 30 add dup *.up != .up store
   *.robage 0 =
   1 dupbool dup *.timer != and .timer store dropbool
   100 dupbool dup *.eye5width != and .eye5width store dropbool
   dropbool *.eye5 45 >
   -1 dupbool dup *.shoot != and .shoot store dropbool
   8 dupbool dup *.shootval != and .shootval store dropbool
   *.refvelup dupbool dup *.up != and .up store dropbool
   dropbool *.eye5 0 =
   628 *.timer div dupbool dup *.aimdx != and .aimdx store dropbool
   not
   1 dupbool dup *.timer != and .timer store dropbool
   *.refxpos *.refypos angle dupbool dup *.setaim != and .setaim store dropbool
   dropbool *.waste 1000 >
   -4 dupbool dup *.shoot != and .shoot store dropbool
   *.waste dupbool dup *.shootval != and .shootval store dropbool
   dropbool *.nrg 25000 > *.body 6000 > and
   32000 rnd dupbool dup *.timer != and .timer store dropbool
   *.xpos dupbool dup *.hivexpos != and .hivexpos store dropbool
   *.ypos dupbool dup *.hiveypos != and .hiveypos store dropbool
   0 dupbool dup *.eye5width != and .eye5width store dropbool
   .status inc
   .fixpos inc
   dropbool
   stop
   
   cond
   *.status 0 !=
   start
   *.timer dup *.out6 != .out6 store
   stop
   
   cond
   *.robage 0 = *.status 1 = and
   start
   20 rnd 0 = *.queen 1 = or
   1 dupbool dup *.status != and .status store dropbool
   0 dupbool dup *.queen != and .queen store dropbool
   not
   2 dupbool dup *.status != and .status store dropbool
   dropbool
   stop
   
   cond
   *.robage 0 > *.status 1 = and
   start
   *.in5 *.timer 1 sub = *.seen 0 = and *.refeye *.myeye = and
   *.refkills 1 add dupbool dup *.seen != and .seen store dropbool
   dupbool not dupbool *.in5 *.timer 1 sub = *.seen *.refkills 1 add = and *.refeye *.myeye = and and
   0 dupbool dup *.seen != and .seen store dropbool
   .tie inc
   not and not or not
   0 dupbool dup *.seen != and .seen store dropbool
   dropbool
   50 dup *.sharenrg != .sharenrg store
   .tieang1 dec
   .tieang2 dec
   .tieang3 dec
   .tieang4 dec
   1 dup *.fixpos != .fixpos store
   80 rnd 0 =
   -4 dupbool dup *.shoot != and .shoot store dropbool
   *.waste dupbool dup *.shootval != and .shootval store dropbool
   dropbool *.body 2000 > *.nrg 31000 < and
   1000 dupbool dup *.fdbody != and .fdbody store dropbool
   dropbool *.body 2000 < *.nrg 10000 > and
   1000 dupbool dup *.strbody != and .strbody store dropbool
   dropbool *.nrg 25000 >
   dupbool dupbool *.shell 30000 < and
   500 dupbool dup *.mkshell != and .mkshell store dropbool
   dropbool dropbool dupbool dupbool *.poison 30000 < and
   500 dupbool dup *.strpoison != and .strpoison store dropbool
   dropbool dropbool
   dropbool
   *.shoot dup *.ploc != .ploc store
   *.robage 5 >
   60 dupbool dup *.aimdx != and .aimdx store dropbool
   dupbool dupbool *.body 20000 > *.nrg 20000 > and and
   1 dupbool dup *.queen != and .queen store dropbool
   50 dupbool dup *.repro != and .repro store dropbool
   not and not dupbool not dupbool *.nrg 10000 > *.body 1000 > and *.eye5 40 < and and
   0 dupbool dup *.queen != and .queen store dropbool
   10 *.body 1000 div add dupbool dup *.repro != and .repro store dropbool
   dropbool dropbool dropbool
   not
   dropbool
   *.xpos dup *.hivexpos != .hivexpos store
   *.ypos dup *.hiveypos != .hiveypos store
   *.timer dup *.out5 != .out5 store
   stop
   
   cond
   *.robage 0 > *.status 2 = and *.return 0 = and
   start
   *.robage 1 =
   .tie inc
   .mkshell dupbool dup *.vloc != and .vloc store dropbool
   -32000 dupbool dup *.venval != and .venval store dropbool
   31 dupbool dup *.counter2 != and .counter2 store dropbool
   628 dupbool dup *.aimdx != and .aimdx store dropbool
   4 dupbool dup *.delgene != and .delgene store dropbool
   dropbool *.numties 0 >
   *.tiepres dupbool dup *.deltie != and .deltie store dropbool
   dropbool
   .shoot dup *.ploc != .ploc store
   *.hivexpos *.hiveypos dist 300 <
   .counter2 inc
   not
   0 dupbool dup *.counter2 != and .counter2 store dropbool
   dropbool *.eye5 0 > *.in6 *.timer 1 sub = not and
   0 dupbool dup *.counter != and .counter store dropbool
   dupbool not dupbool *.counter2 30 > and
   *.hivexpos *.hiveypos angle 628 add dupbool dup *.setaim != and .setaim store dropbool
   15 dupbool dup *.up != and .up store dropbool
   not and dupbool *.eye6 0 > and
   34 dupbool dup *.aimdx != and .aimdx store dropbool
   not and dupbool *.eye7 0 > and
   69 dupbool dup *.aimdx != and .aimdx store dropbool
   not and dupbool *.eye8 0 > and
   104 dupbool dup *.aimdx != and .aimdx store dropbool
   not and dupbool *.eye9 0 > and
   139 dupbool dup *.aimdx != and .aimdx store dropbool
   not and not or not
   dupbool dupbool *.counter 30 < and
   174 dupbool dup *.aimdx != and .aimdx store dropbool
   .counter inc
   not and
   2 dupbool dup *.aimdx != and .aimdx store dropbool
   10 dupbool dup *.up != and .up store dropbool
   dropbool
   dropbool *.eye5 0 > *.in6 *.timer 1 sub = not and
   *.refveldx dupbool dup *.dx != and .dx store dropbool
   dupbool dupbool *.eye5 35 > and
   *.refxpos *.refypos angle dupbool dup *.setaim != and .setaim store dropbool
   8 dupbool dup *.shootval != and .shootval store dropbool
   dupbool dupbool *.refeye 0 = and
   -1 dupbool dup *.shoot != and .shoot store dropbool
   not and not dupbool not dupbool *.venom 30 >= *.refshell 0 > and 3 rnd 0 = and and
   -3 dupbool dup *.shoot != and .shoot store dropbool
   30 dupbool dup *.shootval != and .shootval store dropbool
   not and not or not
   -6 dupbool dup *.shoot != and .shoot store dropbool
   dropbool
   *.refvelup dupbool dup *.up != and .up store dropbool
   not and
   *.refvelup 30 add dupbool dup *.up != and .up store dropbool
   dropbool
   dropbool *.body 800 < *.nrg 15000 > and
   500 dupbool dup *.strbody != and .strbody store dropbool
   dropbool *.body 800 > *.nrg 30000 < and
   500 dupbool dup *.fdbody != and .fdbody store dropbool
   dropbool *.nrg 10000 > *.venom 1000 < and
   200 dupbool dup *.strvenom != and .strvenom store dropbool
   dropbool *.fixed 0 !=
   .fixpos dec
   dropbool *.shflav -1 = *.refeye 0 = *.in6 *.timer 1 sub = or and *.poison 500 < and
   500 *.poison sub dupbool dup *.strpoison != and .strpoison store dropbool
   dropbool *.shflav -6 = *.refeye 0 = *.in6 *.timer 1 sub = or and *.shell 500 < and
   500 *.shell sub dupbool dup *.mkshell != and .mkshell store dropbool
   dropbool
   0 dup *.shflav != .shflav store
   *.waste 1000 >
   -4 dupbool dup *.shoot != and .shoot store dropbool
   *.waste dupbool dup *.shootval != and .shootval store dropbool
   dropbool
   stop
   
   cond
   *.robage 0 > *.status 2 = and *.nrg 30000 >= and *.body 1000 > and *.return 0 = and
   start
   .return inc
   stop
   
   cond
   *.robage 0 > *.status 2 = and *.nrg 10000 < and *.return 0 != and
   start
   0 dup *.return != .return store
   31 dup *.counter2 != .counter2 store
   628 dup *.aimdx != .aimdx store
   stop
   
   cond
   *.robage 0 > *.status 2 = and *.shflav 0 != and *.shflav -2 != and *.return 0 != and
   start
   0 dup *.return != .return store
   *.shell 500 <
   500 *.shell sub dupbool dup *.mkshell != and .mkshell store dropbool
   dropbool
   500 dup *.strpoison != .strpoison store
   stop
   
   cond
   *.robage 0 > *.status 2 = and *.return 0 != and
   start
   *.eye5 0 = *.in5 *.timer 1 sub = not or
   *.hivexpos *.hiveypos angle dupbool dup *.setaim != and .setaim store dropbool
   30 *.velup sub 0 ceil 30 floor dupbool dup *.up != and .up store dropbool
   dropbool *.eye5 40 < *.in5 *.timer 1 sub = and
   *.refvelup 30 add dupbool dup *.up != and .up store dropbool
   dropbool *.eye5 40 >= *.in5 *.timer 1 sub = and
   -2 dupbool dup *.shoot != and .shoot store dropbool
   1200 dupbool dup *.shootval != and .shootval store dropbool
   *.refxpos *.refypos angle dupbool dup *.setaim != and .setaim store dropbool
   *.refxpos dupbool dup *.hivexpos != and .hivexpos store dropbool
   *.refypos dupbool dup *.hiveypos != and .hiveypos store dropbool
   *.refvelup dupbool dup *.up != and .up store dropbool
   *.refveldx dupbool dup *.dx != and .dx store dropbool
   dropbool *.numties 0 >
   *.tiepres dupbool dup *.deltie != and .deltie store dropbool
   dropbool *.hivexpos *.hiveypos dist 200 <
   .counter inc
   not
   0 dupbool dup *.counter != and .counter store dropbool
   dropbool *.counter 700 >
   1 dupbool dup *.status != and .status store dropbool
   dup ^ inc
   stop

PyBot code:
Code: [Select]
#omit-original-code
 
 def hivexpos at 971
 def hiveypos at 972
 def status at 973 # 0 = initial, 1 = "queen", 2 = worker
 def queen at 974 # 0 = normal, 1 = forced queen
 def counter at 53
 def return at 54
 def first at 55
 def seen at 56
 def counter2 at 57
 
 define isqueen: (in5 == (timer - 1))
 define isconspec: (in6 == (timer - 1))
 
 if (status == 0): # initial stage
     dx = refveldx # match velocity
     up = refvelup + 30 # catch up
     if (robage == 0):
         timer = 1
         eye5width = 100
     if (eye5 > 45):
         shoot = -1
         shootval = 8
         up = refvelup # follow
     if (eye5 == 0):
         aimdx = 628 / timer
     else:
         timer = 1
         setaim = angle(refxpos, refypos) # aim
     if (waste > 1000):
         shoot = -4
         shootval = waste
     if ((nrg > 25000) and (body > 6000)):
         timer = rnd 32000
         hivexpos = xpos
         hiveypos = ypos
         eye5width = 0
         status++
         fixpos++
     
 if (status != 0):
     out6 = timer
 
 if ((robage == 0) and (status == 1)):
     if (((rnd 20) == 0) or (queen == 1)):
         status = 1
         queen = 0
     else:
         status = 2
 
 if ((robage > 0) and (status == 1)):
     if (isqueen and (seen == 0) and (refeye == myeye)):
         seen = (refkills + 1)
     elif (isqueen and (seen == (refkills + 1)) and (refeye == myeye)):
         seen = 0
         tie++
     else
         seen = 0
     sharenrg = 50
     tieang1--
     tieang2--
     tieang3--
     tieang4--
     fixpos = 1
     if ((rnd 80) == 0):
         shoot = -4
         shootval = waste
     if ((body > 2000) and (nrg < 31000)):
         fdbody = 1000
     if ((body < 2000) and (nrg > 10000)):
         strbody = 1000
     if (nrg > 25000):
         if (shell < 30000):
             mkshell = 500
         if (poison < 30000):
             strpoison = 500
     ploc = shoot
     if (robage > 5):
         aimdx = 60
         if ((body > 20000) and (nrg > 20000)):
             queen = 1
             repro = 50
         elif ((nrg > 10000) and (body > 1000) and (eye5 < 40)):
             queen = 0
             repro = (10 + (body / 1000))
     hivexpos = xpos
     hiveypos = ypos
     out5 = timer
 
 if ((robage > 0) and (status == 2) and (return == 0)):
     if (robage == 1):
         tie++
         vloc = &mkshell
         venval = -32000
         counter2 = 31
         aimdx = 628
         delgene = 4
     if (numties > 0):
         deltie = tiepres
     ploc = &shoot
     if (dist(hivexpos, hiveypos) < 300):
         counter2++
     else:
         counter2 = 0
     if ((eye5 > 0) and (!isconspec)):
         counter = 0
     elif (counter2 > 30):
         setaim = (angle(hivexpos, hiveypos) + 628)
         up = 15
     elif (eye6 > 0):
         aimdx = 34
     elif (eye7 > 0):
         aimdx = 69
     elif (eye8 > 0):
         aimdx = 104
     elif (eye9 > 0):
         aimdx = 139
     else:
         if (counter < 30):
             aimdx = 174
             counter++
         else:
             aimdx = 2
             up = 10
     if ((eye5 > 0) and (!isconspec)):
         dx = refveldx
         if (eye5 > 35):
             setaim = angle(refxpos, refypos) # aim
             shootval = 8
             if (refeye == 0):
                 shoot = -1
             elif ((venom >= 30) and (refshell > 0) and (rnd(3) == 0)):
                 shoot = -3
                 shootval = 30
             else:
                 shoot = -6
             up = refvelup
         else:
             up = refvelup + 30
     if ((body < 800) and (nrg > 15000)):
         strbody = 500
     if ((body > 800) and (nrg < 30000)):
         fdbody = 500
     if ((nrg > 10000) and (venom < 1000)):
         strvenom = 200
     if (fixed != 0):
         fixpos--
     if ((shflav == -1) and ((refeye == 0) or isconspec) and (poison < 500)):
         strpoison = 500 - poison
     if ((shflav == -6) and ((refeye == 0) or isconspec) and (shell < 500)):
         mkshell = 500 - shell
     shflav = 0
     if (waste > 1000):
         shoot = -4
         shootval = waste
 
 if ((robage > 0) and (status == 2) and (nrg >= 30000) and (body > 1000) and (return == 0)):
     return++
 
 if ((robage > 0) and (status == 2) and (nrg < 10000) and (return != 0)):
     return = 0
     counter2 = 31
     aimdx = 628
 
 if ((robage > 0) and (status == 2) and (shflav != 0) and (shflav != -2) and (return != 0)):
     return = 0
     if (shell < 500):
         mkshell = 500-shell
     strpoison = 500
 
 if ((robage > 0) and (status == 2) and (return != 0)):
     if ((eye5 == 0) or (!isqueen)):
         setaim = angle(hivexpos, hiveypos)
         up = floor(ceil(30 - velup, 0), 30)
     if ((eye5 < 40) and isqueen):
         up = refvelup + 30
     if ((eye5 >= 40) and isqueen):
         shoot = -2
         shootval = 1200
         setaim = angle(refxpos, refypos)
         hivexpos = refxpos
         hiveypos = refypos
         up = refvelup
         dx = refveldx
     if (numties > 0):
         deltie = tiepres
     if (dist(hivexpos,hiveypos) < 200):
         counter++
     else:
         counter = 0
     if (counter > 700):
         status = 1
« Last Edit: May 27, 2011, 07:22:00 PM by Panda »

Offline bacillus

  • Bot Overlord
  • ****
  • Posts: 907
    • View Profile
Hive 0.2 (F2, I guess)
« Reply #1 on: May 22, 2008, 02:29:51 AM »
Overall not a bad bot, I can draw some ideas out of it. The eye 5 is set inefficiently, though, the initial queen has trouble getting enough energy to start a colony due to its high speed, and the queen to worker ratio is WAY too high. At the moment it seems to be 1:1, try get it down to at least 1:20. In the current ratio, the queens have no way to get enough energy.
« Last Edit: May 22, 2008, 02:38:42 AM by bacillus »
"They laughed at Columbus, they laughed at Fulton, they laughed at the Wright brothers. But they also laughed at Bozo the Clown."
- Carl Sagan

Offline goffrie

  • Bot Builder
  • **
  • Posts: 65
    • View Profile
Hive 0.2 (F2, I guess)
« Reply #2 on: May 22, 2008, 07:41:55 AM »
Quote from: bacillus
Overall not a bad bot, I can draw some ideas out of it. The eye 5 is set inefficiently, though, the initial queen has trouble getting enough energy to start a colony due to its high speed, and the queen to worker ratio is WAY too high. At the moment it seems to be 1:1, try get it down to at least 1:20. In the current ratio, the queens have no way to get enough energy.

The initial queen... well, I won't argue.

I'm not sure if I understood your "queen to worker" problem -
Code: [Select]
if ((robage == 0) and (status == 1)):
    if (((rnd 20) == 0) or (queen == 1)):
        status = 1
        queen = 0
    else:
        status = 2
Basically, newly spawned bots have a 1/21 chance of being a queen unless they are forced to be by the parent because it had too much energy and body.

(I just realized that I don't actually need that 'status = 1'. Meh.)

Offline bacillus

  • Bot Overlord
  • ****
  • Posts: 907
    • View Profile
Hive 0.2 (F2, I guess)
« Reply #3 on: May 23, 2008, 12:38:44 AM »
Could be mutations then, or just rotten luck.
if your eye is twice as wide, try adding 15 or -15 .eye5dir to the code, I can't remember which one is right. Also have a look at Oculus; that gave my Antbot the edge when I ran them against each other. (Also that the colonies were far apart and mine were dragging in all the veggies, but that's luck for you).

I'll try make my Guard's patrol area depend on the number of ants in the species.
"They laughed at Columbus, they laughed at Fulton, they laughed at the Wright brothers. But they also laughed at Bozo the Clown."
- Carl Sagan

Offline bacillus

  • Bot Overlord
  • ****
  • Posts: 907
    • View Profile
Hive 0.2 (F2, I guess)
« Reply #4 on: May 23, 2008, 02:33:36 AM »
Oooh, I'm still watching my ants vs. yours. It seems a bad mutation in one of the queens has wiped clean your whole hive. Must have screwed up the conspec. Do the ants have a backup plan for when their queen(s) go missing?
As for my bots, the queens have hit their fertility low, and the populations is slowly leveling out. As soon as they pass the curve, it's going to explode again.
« Last Edit: May 23, 2008, 02:36:32 AM by bacillus »
"They laughed at Columbus, they laughed at Fulton, they laughed at the Wright brothers. But they also laughed at Bozo the Clown."
- Carl Sagan

Offline bacillus

  • Bot Overlord
  • ****
  • Posts: 907
    • View Profile
Hive 0.2 (F2, I guess)
« Reply #5 on: May 23, 2008, 02:49:26 AM »
The lack of Queens is a serious problem. Bots are piling up to transfer nrg, but can't. You can literally see a path where one of my ants chomped its way through the crowd, taking down about 200 of yours along the way.
"They laughed at Columbus, they laughed at Fulton, they laughed at the Wright brothers. But they also laughed at Bozo the Clown."
- Carl Sagan

Offline goffrie

  • Bot Builder
  • **
  • Posts: 65
    • View Profile
Hive 0.2 (F2, I guess)
« Reply #6 on: May 23, 2008, 07:31:26 AM »
Yeah, I made a mistake in the worker code which deleted the queen gene. The code which turned workers into queens then basically killed the bot, as none of the genes would fire (except the conspec).
I made a new version, with mostly rewritten worker code. I'll post that in a bit.