Author Topic: Antbot v1.3  (Read 3312 times)

Offline bacillus

  • Bot Overlord
  • ****
  • Posts: 907
    • View Profile
Antbot v1.3
« on: April 30, 2008, 07:33:48 PM »
This version is mainly tweaking of core functions, especially the problem that the hive is overcrowded and the queen can't reproduce. The veggies dragged in by the scouts are not killed, but cultivated eg. only attacked if body > 1000.

'Antbot v1.3
''A hivebot by Bacillus

'''''''''''''
'I/O CHANNELS
'''''''''''''
''I/O 1-species conspec
''I/O 2-type recognition
''I/O 3-reserved for communication
''I/O 4-hive conspec
''I/O 5-andrenaline level
''I/O 6-food timer-measures time elapsed since worker last saw food
''I/O 7-X coordinate of last food sighting
''I/O 8-Y coordinate of last food sighting

'''''
'VARS
'''''
''Young Queen-collects energy to form her own colony
''Queen-spawns smaller ants
''Drone-Poisons enemies, collects nrg from workers & other species,
''relays back to queen
''Worker-Finds food, brings it back to queen, and shares location
''of food with other workers
''Scout-Moves quickly to pull in veggies

def youngqueen 0
def queen 1
def drone 2
def worker 3
def scout 4

''''''''''''''''''''''''
'CUSTOM MEMORY LOCATIONS
''''''''''''''''''''''''
''Temp-initialization purposes
''Type-The Ant's job in the colony
''Queenxpos and Queenypos-Queen's coordinates
''Dumpdist-The distance from the queen at which a scout should dump a veggie
''Hiveid-The id of the hive this ant belongs to
''Andrenaline-The amount of andrenaline a drone has
''Memtimer-The time elapsed since worker last saw food
''Foodxpos and Foodypos-the coordinates of the last seen food
def temp 990
def type 991
def queenxpos 992
def queenypos 993
def dumpdist 994
def hiveid 995
def andrenaline 996
def memtimer 997
def foodxpos 998
def foodypos 999

'Initialization
''What type of ant am I?
''Set eyes and conspec
cond
 *.robage 0 =
start
 1000 rnd .temp store
 .youngqueen *.temp sgn -- abs .type mult store
 .drone *.temp sgn .type mult store
 .scout *.temp 200 sub sgn 0 floor .type mult store
 .worker *.temp 300 sub sgn 0 floor .type mult store

 1235 .out1 store

 -436 .eye9dir store
 -327 .eye8dir store
 -218 .eye7dir store
 -109 .eye6dir store
  109 .eye4dir store
  218 .eye3dir store
  327 .eye2dir store
  436 .eye1dir store
 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

'First generation is always a queen
start
 *.thisgene .delgene store
 .youngqueen .type store
stop

'OCULUS
'Update bot
cond
start
 *.hiveid .out4 store
 *.andrenaline .out5 store
 *.type .out2 store
 *.memtimer .out6 store
 *.foodxpos .out7 store
 *.foodypos .out8 store
 *.nrg 3 div *.body sub dup .strbody store - .fdbody store
 -4 *.eye1 *.eye9 sub sgn 0 floor mult *.eye1 *.eye8 sub sgn 0 floor mult *.eye1 *.eye7 sub sgn 0    

floor mult *.eye1 *.eye6 sub sgn 0 floor mult *.eye1 *.eye5 sub sgn 0 floor mult *.eye1 *.eye4 sub  

sgn 0 floor mult *.eye1 *.eye3 sub sgn 0 floor mult *.eye1 *.eye2 sub sgn 0 floor mult 4 *.eye9    

*.eye8 sub sgn 0 floor mult *.eye9 *.eye7 sub sgn 0 floor mult *.eye9 *.eye6 sub sgn 0 floor mult
 *.eye9 *.eye5 sub sgn 0 floor mult *.eye9 *.eye4 sub sgn 0 floor mult *.eye9 *.eye3 sub sgn 0 floor

 mult *.eye9 *.eye2 sub sgn 0 floor mult *.eye9 *.eye1 sub sgn ++ sgn mult add -3 *.eye2 *.eye9 sub  

 sgn ++ sgn mult *.eye2 *.eye8 sub sgn 0 floor mult *.eye2 *.eye7 sub sgn 0 floor mult *.eye2 *.eye6

 sub sgn 0 floor mult *.eye2 *.eye5 sub sgn 0 floor mult *.eye2 *.eye4 sub sgn 0 floor mult *.eye2  

 *.eye3 sub sgn 0 floor mult *.eye2 *.eye1 sub sgn ++ sgn mult add 3 *.eye8 *.eye9 sub sgn ++ sgn    

 mult *.eye8 *.eye7 sub sgn 0 floor mult *.eye8 *.eye6 sub sgn 0 floor mult *.eye8 *.eye5 sub sgn 0  

 floor mult *.eye8 *.eye4 sub sgn 0 floor mult *.eye8 *.eye3 sub sgn 0 floor mult *.eye8 *.eye2 sub  

 sgn ++ sgn mult *.eye8 *.eye1 sub sgn ++ sgn mult add -2 *.eye3 *.eye9 sub sgn ++ sgn mult *.eye3  

 *.eye8 sub sgn ++ sgn mult *.eye3 *.eye7 sub sgn 0 floor mult *.eye3 *.eye6 sub sgn 0 floor mult
 *.eye3 *.eye5 sub sgn 0 floor mult *.eye3 *.eye4 sub sgn 0 floor mult *.eye3 *.eye2 sub sgn ++ sgn  

 mult *.eye3 *.eye1 sub sgn ++ sgn mult add 2 *.eye7 *.eye9 sub sgn ++ sgn mult *.eye7 *.eye8 sub    

 sgn ++ sgn mult *.eye7 *.eye7 sub sgn 0 floor mult *.eye7 *.eye6 sub sgn 0 floor mult *.eye7 *.eye5

 sub sgn 0 floor mult *.eye7 *.eye4 sub sgn ++ sgn mult *.eye7 *.eye2 sub sgn ++ sgn mult *.eye7    

*.eye1 sub sgn ++ sgn mult add -1 *.eye4 *.eye9 sub sgn ++ sgn mult *.eye4 *.eye8 sub sgn ++ sgn    

mult *.eye4 *.eye7 sub sgn ++ sgn mult *.eye4 *.eye6 sub sgn 0 floor mult *.eye4 *.eye5 sub sgn 0    

floor mult *.eye4 *.eye3 sub sgn ++ sgn mult *.eye4 *.eye2 sub sgn ++ sgn mult *.eye4 *.eye1 sub    

sgn ++ sgn mult add 1 *.eye4 *.eye9 sub sgn ++ sgn mult *.eye4 *.eye8 sub sgn ++ sgn mult *.eye4    

*.eye7 sub sgn ++ sgn mult *.eye4 *.eye6 sub sgn ++ sgn mult *.eye4 *.eye5 sub sgn 0 floor mult
 *.eye4 *.eye3 sub sgn ++ sgn mult *.eye4 *.eye2 sub sgn ++ sgn mult *.eye4 *.eye1 sub sgn ++ sgn    

 mult add 0 *.eye5 *.eye9 sub sgn ++ sgn mult *.eye5 *.eye8 sub sgn ++ sgn mult *.eye5 *.eye7 sub    

 sgn ++ sgn mult *.eye5 *.eye6 sub sgn ++ sgn mult *.eye5 *.eye4 sub sgn ++ sgn mult *.eye5 *.eye3  

sub sgn ++ sgn mult *.eye5 *.eye2 sub sgn ++ sgn mult *.eye5 *.eye1 sub sgn ++ sgn mult add

.focuseye store

 12 *.type .scout sub sgn abs -- abs 3 mult ++ mult *.vel sub .up store
 *.type .queen sub sgn abs -- abs .fixpos store
 *.tiepres .tienum store
 500 rnd 1500 add .dumpdist *.type .scout sub sgn abs -- abs mult store
 *.andrenaline *.venom sub .strvenom store
 .andrenaline *.andrenaline sgn mult dec
 .memtimer *.memtimer sgn mult dec
 -2 .venval store
 .shoot .vloc store
 .paralyzed .memloc store
stop

'I'm too small!!
cond
 *.body 150 <
start
 175 *.body sub .strbody store
stop

'Some idiot has tied to me!!
cond
 *.numties 0 !=
 *.type .scout !=
start
 *.tiepres .deltie store
stop

'I am a drone and should turn towards workers and queens
cond
 *.eyef 0 !=
 *.type .drone =
 *.nrg 15000 <
 *.in2 .scout !=
 *.in2 .youngqueen !=
 *.in1 *.out1 = and
 *.in2 .drone !=
start
 *.refxpos *.refypos angle .setaim store
stop

'I'm a worker/young queen, no point turning towards conspecs
cond
 *.eyef 0 !=
 *.type .worker =
 *.body 1000 < and
 *.type .youngqueen = or
 *.out1 *.in1 !=
start
 *.refxpos *.refypos angle .setaim store
stop

'I am a young queen and are big and fat, so I mature
cond
 *.type .youngqueen =
 *.body 10000 >
start
 .fixpos inc
 .queen .type store
 *.xpos .queenxpos store
 *.ypos .queenypos store
 32000 rnd .hiveid store
stop

'I have no hive and you are a queen, I'll join yours
cond
 *.queenxpos 0 =
 *.queenypos 0 =
 *.type .queen !=
 *.type .youngqueen !=
 *.in2 .queen =
start
 *.refxpos .queenxpos store
 *.refypos .queenypos store
 *.in4 .hiveid store
stop

'Mature queens turn so there's enough reproduction space.
cond
 *.type .queen =
start
 20 .aimdx store
 50 *.shell sub .mkshell store
stop

'Drones and workers feed the queen
cond
 *.in1 *.out1 =
 *.in4 *.hiveid =
 *.type .drone =
 *.type .worker = or
 *.in2 .queen =
 *.nrg 500 >
 *.eye5 40 >
start
 *.nrg 1500 sub 1000 ceil .shootval store
 -2 .shoot store
stop

'The queen is dead, I am a huge drone sitting in her place, I think I'll become the new queen.
cond
 *.type .drone =
 *.queenxpos *.queenypos dist 15 <
 *.in2 .queen !=
 *.nrg 30000 >=
start
 .fixpos inc
 .queen .type store
stop

'Drones harvest food from workers to bring to the queen so workers can keep harvesting.
cond
 *.hiveid *.in4 =
 *.type .drone =
 *.in2 .worker =
 *.eye5 40 >
 *.refnrg 1000 >
start
 -1 .shoot store
stop

'I am a drone near a queen, but have no food, so I'll move away.
cond
 *.in1 *.out1 =
 *.in2 .queen =
 *.type .drone =
 *.nrg 500 <=
start
 *.maxvel *.velup add .dn store
stop

'I am a huge Drone/Worker, better go and give some of that food I harvested to the Queen.
cond
 *.type .drone =
 *.nrg 15000 > and
 *.type .worker =
 *.body 2500 > and or
start
 *.queenxpos *.queenypos angle .setaim store
stop

'Oooh, lots of food, let's share!
cond
 *.type .worker =
 *.in1 *.out1 !=
 *.refnrg 20000 >
 *.reffixed 0 =
start
 10 .memtimer store
 *.refxpos .foodxpos store
 *.refypos .foodypos store
stop

'You know where food is, I'll remember where.
cond
 *.type .worker =
 *.in1 *.out1 =
 *.in2 .worker =
 *.in6 *.memtimer >
start
 *.in6 .memtimer store
 *.in7 .foodxpos store
 *.in8 .foodypos store
stop

'Forget it.
cond
 *.type .worker =
 *.memtimer 0 =
 *.foodxpos 0 !=
 *.foodypos 0 !=
start
 628 .aimdx store
 *.maxvel *.veldn add .up store
 0 .foodxpos store
 0 .foodypos store
stop

'I see no food, but know where some is, so I'll go find it.
cond
 *.type .worker =
 *.memtimer 0 >
 *.in1 *.out1 =
 *.eyef 0 = or
start
 *.foodxpos *.foodypos angle .setaim store
stop

'I am a scout and my cargo is near the queen, I'll dump it and go find some more.
''It's fixed, so it won't run away.
cond
 *.type .scout =
 *.numties 1 =
 *.treffixed 0 !=
start
 *.tiepres .deltie store
 314 .aimdx store
 20 .up store
stop

'I am a scout without cargo and see food, let's get it!
cond
 *.type .scout =
 *.numties 0 =
 *.in1 *.out1 !=
 *.reffixed 0 =
 *.nrg 0 >
 *.eyef 0 >
start
 *.refxpos *.refypos angle .setaim store
stop

'I am a scout without cargo and am close to food, so I'll tie to it.
cond
 *.type .scout =
 *.in1 *.out1 !=
 *.nrg 0 >
 *.eye5 40 >
 *.reffixed 0 =
 *.refshoot 0 =
 *.numties 0 =
start
 .tie inc
stop

'I am a scout with cargo, better bring it back so the others can eat it.
''Might as well take some of the spoils myself so the load isn't as heavy.
cond
 *.type .scout =
 *.numties 1 =
start
 *.queenxpos *.queenypos angle .setaim store
 40 .sharenrg store
 1 .sharewaste store
stop

'I am a scout and my cargo is near the queen, I'll dump it and go find some more
''Let's fix it in place so it doesn't run away.
cond
 *.type .scout =
 *.numties 1 =
 *.queenxpos *.queenypos dist *.dumpdist <
start
 .fixpos .tieloc store
 .tieval inc
stop

'I'm not a scout and I see food, let's eat it!
''If the veggie is part of out garden eg a scout pulled it in, to not kill it
cond
 *.eye5 40 >
 *.out1 *.in1 !=
 *.type .scout !=
 *.reffixed 0 =
 *.reffixed 0 >
 *.refbody 1000 > and or
start
 -6 .shoot store
stop

'I am a scout, but am too close to the queen, so I'll move away
cond
 *.type .scout =
 *.queenxpos *.queenypos dist 500 <
 *.queenxpos *.queenypos angle *.aim %=
start
 *.maxvel *.velsx add .dx store
stop

'I am a drone under attack, take countermeasures
''Part 1:If attacked, make andrenaline.
cond
 *.type .drone =
 *.shflav -1 =
 *.shflav -6 = or
start
 *.andrenaline 5 add .andrenaline store
 *.shang .setaim store
 0 .shflav store
stop

''Part 2:If venom is stored due to andrenaline, spit it at the enemy.
cond
 *.eye5 40 >
 *.out1 *.in1 !=
 *.type .drone =
 *.refshoot 0 >
 *.venom 0 >
 *.memval 0 !=
start
 *.venom .shootval store
 -3 .shoot store
stop

''Part 3:You're angry, so I'll be as angry as you.
cond
 *.in1 *.out1 =
 *.in2 .drone =
 *.type .drone =
 *.in5 *.andrenaline >
start
 *.in5 .andrenaline store
stop

'I should really evolve a toilet...
cond
 *.waste 200 >
start
 *.waste .shootval store
 -4 .shoot store
stop

'I am a Queen, so I should really make a colony
cond
 *.type .queen =
 *.nrg 5000 >
start
 5 .repro store
stop
"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
Antbot v1.3
« Reply #1 on: April 30, 2008, 08:11:56 PM »
If you don't understand the code, I.ve posted a small summary in the Bot Tavern. I need some help with I/O 3; It's driving me even more crazy!!!!    
"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 gymsum

  • Bot Destroyer
  • ***
  • Posts: 215
    • View Profile
Antbot v1.3
« Reply #2 on: May 01, 2008, 12:13:28 AM »
I think I've found you're problem...

You have conditions for the ins sysvars, but at no point did you make a store to any of the out sysvars, meaning all in sysvars on conspecs returned 0 by default, or mutant. This could be your underlying problem, you should store some var into the in sysvars.

Offline bacillus

  • Bot Overlord
  • ****
  • Posts: 907
    • View Profile
Antbot v1.3
« Reply #3 on: May 01, 2008, 06:27:03 PM »
Look again. All the I/O channels are updated just before the OCULUS II store.
"They laughed at Columbus, they laughed at Fulton, they laughed at the Wright brothers. But they also laughed at Bozo the Clown."
- Carl Sagan