Basic Bot Tutorial

From WikiManual
Jump to: navigation, search

Basic Bot

This simple tutorial uses Animal_Minimalis as a way to introduce new players in the DB Universe to a relativly simple bot. This deceptivly simple bot also showcases several new logical operators and refvars.

This tutorial assumes the reader knows the basics of how the DNA works. This means understanding genes and the stack.

Complete Bot

'Animal_Minimalis
'By: Nums
'Good for mutation sims and for
'newbies to see how a basic bot works.
'Contains everything necessary for it
'to survive and reproduce.

' Gene 1 Food Finder
cond
 *.eye5 0 >
 *.refeye *.myeye !=
start
 *.refveldx .dx store
 *.refvelup 30 add .up store
stop

' Gene 2 Eat Food
cond
 *.eye5 50 >
 *.refeye *.myeye !=
start
-1 .shoot store
 *.refvelup .up store
stop

' Gene 3 Avoiding Family
cond
 *.eye5 0 =
 *.refeye *.myeye = or
start
 314 rnd .aimdx store
stop

' Gene 4 Reproduce
cond
 *.nrg 20000 >
start
 10 .repro store
stop

end

Gene 1, the Food Finder

The conditionals

eye5 will be greater than 0 if another bot is in front of you. Thus we're instructing the gene to only fire if there's actually a target.

*.refeye *.myeye != is the classic conspec recognition system, used by bots since the beginning of time. If the other bot doesn't have the same number of .eyeX's you do, it probably isn't your parent or your kids, and so it's food. What if the real world were like that.

The gene itself

refveldx and refvelup return the velocity of another bot relative to you. If this confuses you, read (Link to refvel functions).

*.refveldx .dx store tells the bot to match the sideways motion of it's target. Without this the food could escape by 'strafing' quickly to either side of you. If this confuses you, try removing the line are running a sim. Watch to see when the bot loses its prey.

*.refvelup 30 add .up store is a neat bit of programming. *.refvelup is the speed of another bot relative to you along your eye's vector (the direction you're looking). *.refvelup .up store would make you match the food's velocity. We want to get closer to it, so we add another 30 to .up.

It could also be written as:

*.refvelup .up store
*.up 30 add .up store

Gene 2, Eat Food

The condition

Identical to the food finding condition, but this time we check if the food is close to our bot or not with *.eye5 50 > . Note that eye5 equals 50 about when it's a good time to start feeding. The reason for this isn't terribly important for the first tutorial, so just remember it as a fact of the DB universe.

The gene

Remember in the last gene where we set .dx? This gene always fires if the last one does, so there's no need to write another *.refveldx .dx store statement.

However, we don't want to get any closer to the food, or we'll ram it and possibly lose it, wasting time and energy. Obviously *.refvelup 30 add .up store isn't appropriate anymore. We can overwrite the old .up command with our new one, telling the bot to just stay close. Hence *.refvelup .up store.

The second part of this gene instructs the bot to start feeding. -1 .shoot store is all you need to start feeding if you're near food and pointed at it.

Gene 3, Avoiding Family

The condition

This one is a bit more involved

*.eye5 equals 0 whenever there's nothing visible. If the bot can't see anything, we want it to spin around until it does see something. I know, that sounds like a recipe for cyber barf all over your computer screen, but bots don't get dizzy.

We also want the bot to start spinning if it sees a family member, so it doesn't start eating it.

However, we don't want to do this only when both are true, we want to do this when either are true. We could write two seperate genes, but that would be wasteful. A better solution is to use the logical operator or.

The gene

314 rnd makes a random number between 0 and 314 (or 90 degrees). Why random? This way there isn't any holes to how we check new locations. We could just as easily do 314, but then there would be several holes in where we're checking. We could do something small, like 1, but then our spin speed would suffer a little bit, making us less able to respond to new food sources.

314 rnd is not the only solution. Feel free to replace this with anything else you want. Experiment. You don't even have to spin randomly. You could try testing the different eye values for other bost and turn in that direction.

.aimdx store instructs the bot to spin to the right that many units.

This is a classic method of conspec avoidance, if not the standard.

Gene 4, Make new family

The condition

Here we check to see if we have enough energy to reproduce. 20000 was picked arbitrarily. You can chose any number you like. The lower the number, the more often the robot will reproduce, but the weaker each child will be. Also, there is a very real correlation between bot size and shot strength, so you want the parent to be strong enough that it can withstand the birthing process.

The gene

10 .repro store instructs the bot to produce a baby with 10% of its own resources. Some bots do 50%, but in my experience any kind of baby is something of a risk. It's usually better to only give your potentially mutated offspring a fraction of your own energy.

After all, if you've made it this far, you must be pretty good at surviving. Your baby hasn't proven itself yet. If there's one thing kids today don't understand...

But that's hardly the only opinion on the matter. Feel free to pick a value that you feel comfortable with.

Ending thoughts

The strength of this bot lies in it's power and brevity. This is a good basic bot to experiment with things like poison, storing body, and ties. You can easily add genes to the beginning or end of the bot to change its behavior without having those genes cause undesirable side effects.

If you're new to the program, and feel you have a basic understanding of how the DNA works and would like to try making a bot for the leagues or just for fun, Animal Minimalis gets most of the grunt work like reproducing and finding food out of the way. You can concentrate on more important things, like adding a really cool virus.

If you just like to run some mutation simulations, Animal Minimalis is a good bot to start with. It's strong, but not that strong. Meaning there's lots of room for improvement. Also, the DNA is very simple, so mutations are much less likely to really hurt it than something like Light's Helios or PurpleYouko's Dominator Invincibalis.

If you have any questions, visit the new forum and ask. Everyone there would be just delighted to help you.