A tie feeder
Step by step: a bot that finds a prey, ties to it, drains its energy through the tie, lets go when it runs dry and reproduces with what it gained.
In A bot that looks for food you stole energy from vegetables with shots, and in A vegetable you raised the algae that make energy out of light. This tutorial builds the third contender: a bot that neither hunts nor photosynthesizes, but ties to its food and drains it. Each step adds genes to the DNA and tells you what you should see.
A tie instead of a shot
Hunting with shots (A bot that shoots) means running after your food. With a tie (Ties and multicellular bots) you tie on once and the tie does the work by itself: it pins the prey down (it is a spring: the prey is not going anywhere while you eat) and it drains it (through the tie you transfer energy every cycle, straight from its reserve to yours — Ties and multicellular bots).
The price: out of every 100 you take from it, you keep 70 as energy, almost 3 as body and 1 as waste. That pays less than a good shot; the upside is that the command goes through every cycle, for free and with no aiming.
Step 1 · The prey
You need something with energy that does not defend itself. In Observe → Seed, seed the alga you built in A vegetable marked as Vegetable (photosynthesizes), or a few copies of a motionless target like the one in A bot that shoots:
' Practice target: does nothing
cond
start
stopWe are going to watch the target die little by little; the alga, with the sun behind it, lasts longer. For the measurements in this tutorial we use the motionless target, a 1200×900 field and bots with 3000 energy.
Step 2 · Finding it and getting close
The tie only reaches the bot you are looking at, and only up close: the engine does not tie across more than about 480 from edge to edge, and less if the bots are small. So first comes the usual hunt: turn while searching, aim, get closer. Two genes are enough, because the focus eye already describes the one you have best in front of you: its position in .refxpos and .refypos, its energy in .refnrg and its species in .refeye (Vision).
' Hands free and what's ahead isn't food: turn at random and move forward
cond
*.tiepres 5 !=
*.refnrg 100 <
*.refeye *.myeye =
or
start
314 rnd .aimdx store
10 .up store
stop
' Hands free and prey in sight: aim at it and get closer
cond
*.tiepres 5 !=
*.refnrg 100 >
*.refeye *.myeye !=
start
*.refxpos *.refypos angle .setaim store
10 .up store
stopThree new decisions in those conditions:
.refnrgabove 100 means “this has energy and is alive”: corpses, which show their real energy, 0, are left off the menu..refeyedifferent from.myeyeis the species test from A bot that recognizes its own species: it doesn't run after your own kind..tiepresdifferent from 5 means “I'm not eating”: 5 is the port we are going to use to call the tie in the next step, and this check keeps the bot from tying to two prey at once.
The first gene uses or: it turns if what it sees is not food or is a relative, and it always moves forward, pushing whatever is in the way.
What you should see: the bot pivots and walks at random until the prey enters the fan of eyes; then it locks its heading with .setaim and goes straight for it. In our run it had the prey in focus at cycle 2 and touched it at 11.
Step 3 · Tying to it
' Prey close and ahead: tie to it with port 5
cond
*.tiepres 5 !=
*.refnrg 100 >
*.refeye *.myeye !=
*.eye5 50 >
start
5 .tie store
stopAn .eye5 of 50 is about 200 units from edge to edge: as the bot crosses that line, it writes 5 to .tie and, at the end of the actions phase, the engine ties it to the bot it is looking at. The 5 is the port: the name you will use to pick that tie; the prey will call it 1, by its order of arrival (Ties and multicellular bots). The command is always cleared, whether it works or not, and every attempt charges the cost of tying (Tie): 0 in the built-in simulations except the league matches, 2 in the F1 league.
The prey can still get away: its slime deflects the attempt (.slime — above 92 no tie is possible) and every attempt, whether it works or not, costs it 20 (Defenses).
What you should see: in the app, a thin line between the two, bluish while the tie is soft. In the inspector's memory (The inspector): the feeder with .numties at 1 and .tiepres at 5; the prey with .tiepres at 1.
Step 4 · Draining its energy
' Tied prey that isn't mine: read it and drain its energy
cond
*.tiepres 5 =
*.trefeye *.myeye !=
start
5 .readtie store
5 .tienum store
-1 .tieloc store
-1000 .tieval store
stopFour commands: .readtie points the tie's senses (the tref* cells) at port 5; .tienum picks tie 5 for everything else; .tieloc at −1 says “transfer energy” and a negative .tieval says “take”. You can take up to 3000 per cycle; we ask for 1000, and the engine trims it to whatever the prey has left.
The transfer happens in the movement phase of that same cycle, and by the next one you are already eating. What we measured against the motionless target:
| Cycle | Prey | Feeder (energy / body / waste) |
|---|---|---|
| 12 | 3000 (tied) | 3000 / 1000 / 0 |
| 13 | 2000 | 3700 / 1029 / 10 |
| 14 | 1000 | 4400 / 1058 / 20 |
| 15 | 0: corpse | 5100 / 1087 / 30 |
Each cycle the prey loses 1000 and you gain 700 energy, 29 body and 10 waste (.waste): the remaining 30% is lost along the way. The condition with .trefeye is the same species test, now looking at the tied bot instead of the seen one.
Step 5 · The spring: pinning the prey
Tying on the run has its own physics. The tie is born with whatever length it had when it formed and tolerates a difference of 20 units without doing anything: outside that dead zone it is a spring that pulls on both. Since you arrive pushing, the length ends up short, the prey ends up almost stuck to you, and the pair keeps sliding together about 200 units before settling — dragging works the same the other way around, corpse included. One thing, though: a vegetable loaded with chloroplasts is far more massive than a bot made of pure body (Physics).
After 19 cycles the tie stiffens: in the app the line turns ocher and thicker, and the two bots become multicellular (.multi is 1 in both). By then you can send it geometry: .fixlen fixes the length and .fixang the angle, and the prey ends up hanging off you on a short arm, in front of your nose.
' Stiffened tie: carry it close and in front
cond
*.multi 1 =
*.tiepres 5 =
start
100 .fixlen store
0 .fixang store
stopIn our run, from the stiffening on, .tielen went down gradually to about 40 from edge to edge and .tieang kept getting closer to 0: the prey ended up within arm's reach, dead ahead. With a small prey the feast lasts less than those 19 cycles, so the gene only shines with fat prey. Being multicellular with your own food has side effects —costs are split and your shots hit harder (Ties and multicellular bots)— and it is exactly the mechanism A multibot uses for good.
Step 6 · Letting go when it runs dry
The dried-up prey doesn't disappear: it stays as a corpse and stays tied, and a bot that doesn't let go ends up dragging its empty pantry around. The missing gene:
' The prey dried up: let go
cond
*.tiepres 5 =
*.trefbody 0 >
*.trefnrg 100 <
start
5 .deltie store
stop.trefnrg is the tied bot's energy, read through the tie one cycle late. With less than 100 there is nothing left to drain: .deltie cuts tie 5 and the bot is free. The condition with .trefbody avoids a false positive: in the tie's first cycle the tref* cells are still empty, and without that check the bot would cut a freshly tied prey.
What you should see: one cycle after the prey reaches 0, the two have .numties at 0 and the feeder turns to look for another. It doesn't tie to the corpse again: the .refnrg test from step 2 already leaves it off the menu.
The complete bot
What's left is the usual: when energy is left over, children. The gene asks for 30% with .repro starting at 6000, and only with hands free: the birth needs free room ahead, and while you eat, the prey is covering that room. This is the whole bot, just as we ran it:
' A tie feeder
' Looks for prey, ties to it with port 5, drains its energy,
' lets go when it runs dry and, with the gain, has children.
' Hands free and what's ahead isn't food (or is one of mine):
' turn at random and move forward
cond
*.tiepres 5 !=
*.refnrg 100 <
*.refeye *.myeye =
or
start
314 rnd .aimdx store
10 .up store
stop
' Hands free and prey in sight: aim at it and get closer
cond
*.tiepres 5 !=
*.refnrg 100 >
*.refeye *.myeye !=
start
*.refxpos *.refypos angle .setaim store
10 .up store
stop
' Prey close and ahead: tie to it with port 5
cond
*.tiepres 5 !=
*.refnrg 100 >
*.refeye *.myeye !=
*.eye5 50 >
start
5 .tie store
stop
' Tied prey that isn't mine: read it and drain its energy
cond
*.tiepres 5 =
*.trefeye *.myeye !=
start
5 .readtie store
5 .tienum store
-1 .tieloc store
-1000 .tieval store
stop
' Stiffened tie: carry it close and in front
cond
*.multi 1 =
*.tiepres 5 =
start
100 .fixlen store
0 .fixang store
stop
' The prey dried up: let go
cond
*.tiepres 5 =
*.trefbody 0 >
*.trefnrg 100 <
start
5 .deltie store
stop
' Energy to spare and hands free: a child
cond
*.nrg 6000 >
*.tiepres 5 !=
start
30 .repro store
stopAgainst two motionless targets, in a 1200×900 field: it emptied the first one in ten cycles (ending at 5100), took about seventy more to find the second, emptied it just the same, and at cycle 90 the first child was born — the parent ended at 5037, the child started with 2157 and the same DNA. After that the two wandered without finding anything: the field was clean.
The Bestiary has real tie feeders. The Hybrid of a tiefeeder and Alga Chloroplastus is a leaner version of this bot: it ties with .tie to whoever isn't its species, takes 1000 per cycle from it with .tieloc at −1 and cuts the tie if the tied bot turns out to be a relative. We ran it against a motionless target: it emptied it in about ten cycles, but kept dragging the corpse around. Letting go of the dried-up prey is the improvement we added.
What to try next
- Fat prey. Against a vegetable that photosynthesizes while you eat, raise the extraction: the cap is 3000 per cycle, not 1000. And try letting go before it dries up completely: the threshold is in the step 6 gene.
- Eating the corpses. The −1 only takes energy; with
.tielocat −6 you take body, and the tied corpse's body is the after-dinner treat. In a long run against a field full of algae, our bot ended up buried among the corpses of its own prey: they are walls — and by default they don't even rot, because Body decay per cycle comes at 0. Emptying them with the −6 is the cure. - Keeping it from being stolen. Another feeder can tie to your prey, or to you. Slime is the specific defense: above 92 nobody can tie to you, and each failed attempt costs them 20. Poison punishes the one who drains. And since
.deltiecuts from either end, a gene that cuts the ties you didn't ask for cleans you of parasites — careful: it would also cut the birth tie with your child (Ties and multicellular bots, Defenses). - Paralyzing the prey. Venom also travels through the tie:
.tielocat −3 leaves it still with your.strvenom, so it doesn't drag itself along with you anywhere (.tieloc). - The same mechanism, for good. Everything you used here to drain someone else, a multibot uses to feed its own: a positive
.tievalpasses energy to your partner, and.sharenrgshares it out evenly. Go on with A multibot and, for tournament tactics, Multibots.