Tie Tutorial

From WikiManual
Revision as of 20:36, 14 February 2014 by PhiNotPi (talk | contribs) (Fixed typos)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Meet Animal Minimalis

Note that this tutorial refers to 2.4X and prior. An entirely new interface is presently being worked on for the next version.

This is Animal Minimalis: (He's been slightly modified to produce offspring with more energy, but otherwise he's the same)

'Animal Minimalis
'by Nums

cond
 *.eye5 0 >
 *.refeye *.myeye !=
start
 *.refveldx .dx store
 *.refvelup 30 add .up store
stop

cond
 *.eye5 50 >
 *.refeye *.myeye !=
start
-1 .shoot store
 *.refvelup .up store
stop

cond
 *.eye5 0 =
 *.refeye *.myeye = or
start
 314 rnd .aimdx store
stop

cond
 *.nrg 15000 >
start
 30 .repro store
stop
end

We're going to be using him to demonstrate some cool things using ties.

Ties

Ties are connections between bots that can be fired by putting a positive number into .tie.

Tie ID

The number that you put into .tie will be the tie's ID, sometimes called its port or (more rarely) phase.

If you want to delete a tie, you will need to put the tie's ID into .deltie. If you want to change or fix the angle of a tie, or change or fix it's length, or if you want to feed through a tie or use it to alter another bot's memory values you will need to store the tie's ID into .tienum.

Tiepres

You can read back the value of the last tie created by using *.tiepres. For example:

*.tiepres .tienum store

Will select the last tie created.

Deleting ties

To delete a tie simply store the tie ID into .deltie. Forgotten it? - simply use *.tiepres

*.tiepres .deltie store

Will delete the last tie created.

Deleting the Birth Tie

If you're a combat bot then efficiency counts. You definitely don't want to be mucking about with an umbilical cord for the first few cycles of your life.

Combat bot programmers use a neat trick to remove that pesky birth tie.

First, fire a tie at your parent when you are born:

cond
 *.robage 0 =
start
 .tie inc
stop

Since only one tie can exist between two bots this will replace the birth tie.

You can then delete the new tie on the next cycle:

cond
 *.robage 1 =
start
 .deltie inc
stop

Note the use of inc and dec to save energy.

Put an anti-birth tie gene into Animal Minimalis and see how much better he does.

In this forum thread Nums comes up with a few very concise anti-birth tie genes.

Selecting a Tie

The easiest method to select a tie is with:

*.tiepres .tienum store

This will select the most recently formed tie, which is usually the one you're interested in anyway. Remember that this will automatically select any tie to your bot, including those accidentally attached by family members.

You can select other, older ties if you remember the 'tie phase'. That is, the number you used for .tie.

4 .tie store

will create a tie with port 4.

4 .tienum store

will select a tie with port 4, whether you made it yourself or not.

Feeding through a tie

To feed trough a tie you must first tie to another bot, address the tie number(.tienum), then use .tieloc and .tieval to transfer nrg.

cond
*.refeye *.myeye !=
*.eye5 45 >
start
13 .tie *.robage sgn mult *.refage sgn mult store
stop

cond
*.tiepres 0 >
*.tienum 0 =
start
*.tiepres .tienum store
stop

cond
*.tienum 0 >
start
-1 .tieloc store
-1000 .tieval store
stop

For a basic tie feeder that's all there is to it.

The bot ties to non-family(normally), that's the reason the robage and refage check is there to prevent parent and child from tieing to one another. The next part is that the bot will store the number of the latest tie into tienum. Next it will attempt to feed. The -1 stored into tieloc initiates nrg transfer. The -1000 specifies the bot attempt to take the maximum allowed level.

Leaching and Counter-Leaching

A leach is a bot that makes use of another bot's attempt to tie feed to reverse the nrg flow and take nrg without doing the work of hunting. This gene:

cond
*.tiepres 0 >
start
.tieval .tieloc store
1000 .tieval store
stop

Stores 1000 into an enemy's tieval location reversing the nrg flow.

When our basic tie feeder ties to feed from a bot with these genes, it will begin giving nrg to the bot rather than taking it.

Fortunately there is a number of ways we can thwart these nasty leaches. The best course overall is to simply better distinguish between your feeding tie and another's.

cond
*.robage 0 =
start
31999 rnd 1 add 50 store
.tie inc
stop
cond
*.refeye *.myeye !=
*.eye5 45 >
start
*50 .tie *.robage sgn mult *.refage sgn mult store
stop
cond
*.tiepres 0 >
start
*.tiepres .tienum store
stop
cond
*.tienum *50 =
start
-1000 .tieval store
*.tieval sgn .tieloc store
stop

cond
*.tiepres *50 !=
*.tiepres 0 >
start
*.tiepres .deltie store
stop

This time the tie feeder uses a random number to store it's ties to. This allows it to rapidly distinguish between its ties and those of friends or foes. It also prevents rapid deletion of it's ties by causing enemies to have to wait at least one cycle for .tiepres to read back the number of the tie.

The number stored into tieloc has also been modified to change with tieval. If tieval is changed (nasty leaches) the bot will stop tie feeding and begin messing with the enemy's .up command.

Last the bot will attempt to delete any tie that's not it's own. This both prevents accidental family feeding and enemies from tie feeding for greater than one cycle.

Communicating Through a Tie

You can use .tieloc and .tieval like you would use .shoot and .shootval to alter the memory locations of the bot you are tied to.

Just set the memory location you want to write to into .tieloc and then set the value you want written to that memory location into .tieval - simple as that

Remember to have .tienum set to the tie phase of the tie you want to use

Reading Through a Tie

The sysvars .tmemloc and .tmemval are similar to .memloc and .memval, only rather than reading the memory locations of the bot you are facing, they read back the memory locations of the bot you are tied to.

Hard Ties

The sharing sysvars, and the sysvars to change the length and angle of ties, only work on ties that have hardened. A tie will harden 20 cycles after it is created.

Sharing

As nice as sharing nrg sounds, it can also be used to take up to 99% of another's nrg. It's best to design even combat bots to take advantage of the occasional share situation that may arise from the hardening of ties.

cond
start
99 .sharenrg *.multi mult store
.sharewaste *.multi mult inc
stop

This gene's benefits are two-fold nrg is transferred at a rate even higher than during normal tie feeding and harmful waste is transferred to the other bot. This gene is SG'ized (*.multi mult) causing the bot to automatically start share-feeding as soon as it becomes available without spending any nrg repetitively checking for multi-bot status.

Multibots

(Work in progress)

Batterybots

(Work in progress)

Changing the Angle and Length of Your Tie

The Tie Ports

(Work in progress)

The Tie-Reference Variables

(Work in progress)