Author Topic: Ant Bot (IB)(Henk)-18.05.04  (Read 3157 times)

Offline Jez

  • Bot Overlord
  • ****
  • Posts: 788
    • View Profile
Ant Bot (IB)(Henk)-18.05.04
« on: December 04, 2006, 09:12:52 AM »
'Topic: multi-celled bots  

' Ant Bot
' By Henk
' A try at emulating the ants

' *************************
' ID's go by out1 and in1 *
' Statusses go by out2,in2*
' *************************
' out1:
' 1=I am the Queen
' 2=I am Baby
' 3=I am worker
' Out2:
' 0=I feel fine.
' 1=I am hungry
' 3=I am still searching for food
' 4=I see food
' 5=I have a lot of waste


' BABY ANT part
' Initiate
cond
*.robage 0 =
start
2 .out1 store
.tie inc
stop

' Tie undo
cond
*.robage 1 =
start
.deltie inc
*55 .readtie store
25 54 store
stop

' ID chances. Chance of new queen is 1%
cond
*.robage 50 =
start
100 rnd 41 store
stop

' Declare identity
cond
*.robage 51 =
*41 50 !=
start
3 .out1 store
stop

cond
*.robage 102 =
*.out1 3 !=
*.out1 4 !=
start
3 .out1 store
stop

'The Royal genes; 50% that old workers become queens also
cond
*.robage 101 =
*41 50 =
start
1 .out1 store
stop

cond
*.out1 1 =
*.nrg 1000 <
start
3 .out1 store
stop

cond
*.robage 1000 >
*.out1 3 =
*.nrg 5000 >
start
1 .out1 store
stop

' Babies go up
cond
*.out1 2 =
*.rdboy 2000 !=
start
2000 .setboy store
stop

' *****************************
' QUEEN ANT part
' Queens ought to be defendable
cond
*.out1 1 =
*.shell 90 <
start
100 *.shell sub .mkshell store
stop

' The queen's bussiness: reproduction
cond
*.nrg 10000 >
*.out1 1 =
*.fixed 0 !=
start
40 .repro store
stop

' the queen needs mass
cond
*.body 20000 <
*.nrg 10000 >
*.out1 1 =
start
15 .strbody store
stop

' The ants eat corpses
cond
*.refnrg 100 <
*.eye5 40 >
start
-6 .shoot store
stop

' The queen floats at about 6000 depth
cond
*.depth 6000 %=
*.rdboy 0 !=
*.out1 1 =
start
0 .setboy store
1 .fixpos store
stop

cond
*.depth 5000 <
*.rdboy -1500 !=
*.out1 1 =
start
-1500 .setboy store
stop

cond
*.depth 7000 >
*.rdboy 1500 !=
*.out1 1 =
start
1500 .setboy store
stop

' GENERAL ANT part
' 4 Follow genes
cond
*.eye1 *.eye9 >
*.eye1 *.eye5 >
*.numties 0 =
*.out1 3 =
start
-102 .aimdx store
stop

cond
*.eye9 *.eye1 >
*.eye9 *.eye5 >
*.numties 0 =
*.out1 3 =
start
102 .aimdx store
stop

cond
*.eye4 *.eye6 >
*.eye4 *.eye5 >
*.numties 0 =
*.out1 3 =
start
-26 .aimdx store
stop

cond
*.eye4 *.eye6 >
*.eye4 *.eye5 >
*.numties 0 =
*.out1 3 =
start
-26 .aimdx store
stop

' Edge control
cond
*.edge 0 !=
*.eye5 0 =
start
157 .aimdx store
stop

' Move
cond
*.numties 0 =
*.out1 3 =
*.hitup 0 =
start
40 *.vel sub .up store
stop

' WORKER ANT part
' Get energy
cond
*.refshoot 0 =
*.eye5 30 >
*.out1 3 =
*.refnrg 100 >
start
-1 .shoot store
stop

' Feed the Queen
cond
*.eye5 50 >
*.in1 1 =
*.nrg 2000 >
*.robage 100 >
start
1 .tie store
stop

cond
*.numties 0 >
*.tiepres 1 =
*.nrg 1950 >
*.robage 100 >
start
1 .tienum store
-1 .tieloc store
500 .tieval store
stop

cond
*.numties 0 >
*.tiepres 1 =
*.nrg 1950 <
start
1 .deltie store
stop

' Waste disposal 1: give to plants
cond
*.waste 10 >
*.eye5 40 >
*.refshoot 0 =
*.out1 3 =
*.refnrg 100 >
start
-3 .shoot store
*.waste .shootval store
stop

' Turn away from queen if I don't have enough energy to feed her
cond
*.eye5 0 >
*.in1 1 =
*.nrg 2000 <
*.out1 3 =
start
314 .aimdx store
stop

' go to queen depth when I'm ready to feed her
' The queen floats at about 8000 depth
cond
*.depth 8000 %=
*.rdboy 0 !=
*.out1 3 =
*.nrg 10000 >
start
0 .setboy store
stop

cond
*.depth 8000 <
*.rdboy -2000 !=
*.out1 3 =
*.nrg 10000 >
start
-2000 .setboy store
stop

cond
*.depth 8000 >
*.rdboy 1000 !=
*.out1 3 =
*.nrg 10000 >
start
2000 .setboy store
stop

' no bouy when searching
cond
*.nrg 10000 <
*.rdboy 0 !=
*.out1 2 >
start
0 .setboy store
stop

' turn when I see another of my kind(but not the queen)
cond
*.refeye *54 =
*.eye5 0 >
*.in1 1 !=
*.aim 942 !%=
start
314 .aimdx store
stop


' BATTLE ANT part

' Out2:
' 0=I feel fine.
' 1=I am hungry
' 2=I see an enemy and I'm ready to fight (combat bot only)
' 3=I am still searching for food (Worker only
' 4=I see food
' 5=I have a lot of waste

' STATUSSES ID
cond
*.nrg 2000 <
*.out2 1 !=
start
1 .out2 store
stop

cond
*.eye5 0 =
*.out1 3 =
*.out2 3 !=
start
3 .out2 store
stop

cond
*.eye5 0 >
*.refshoot 0 =
*.refnrg 100 >
*.out2 4 !=
start
4 .out2 store
stop

cond
*.waste 500 >
*.out2 5 !=
start
5 .out2 store
stop
end
If you try and take a cat apart to see how it works, the first thing you have in your hands is a non-working cat.
Douglas Adams