Robot Tutorial

From WikiManual
Revision as of 17:18, 16 September 2005 by 66.91.138.34 (talk) (The 2 values are equal. != The 2 values are not equal. > The first value is greater than the second value. < The first value is less than the second value. %)
Jump to: navigation, search

A complete tutorial for Version 2.36

(please bear with me as I convert this help file from its older format to the newer version as many of the older controls will not work in quite the same way.)



What is a Command? A command is a memory location into which a value is stored in order to make the robot perform a certain operation. They are addressed via labels.

What is a label? A label is a name preceded by a period. Each command and function can be addressed either by a label or by using their numerical address. Examples of labels are .refeye or .up.














(=) The 2 values are equal. != The 2 values are not equal. > The first value is greater than the second value. < The first value is less than the second value. (%=) The two values are almost equal (within 10%)

How do I create a robot?

In order to make a good robot, you need to give him three things.

The ability to find food. 2. The ability to eat the food. 3. The ability to reproduce.







end Available as Simplebot1.txt








The NON-Spinning approach. OK then. How do we stop Simplebot from spinning? We need to make sure that the new gene that makes him spin is only activated under certain circumstances and not all the time. We put the gene in to make him turn away from his family members so I guess we need to make sure he only turns when he is actually looking at one of them and not at a permanent afterimage.

Try adding the following line to the condition section of gene 6.

  • .eye5 0 >

You will also need to change the value of the other line in this gene from.

  • .refeye 5 = to *.refeye 6 = Available as Simplebot3.txt

This is because we have added another eye cell to the genome. Save the file and restart the simulation again. Let it run for a couple of thousand cycles to see what the robot population reaches. It should max out at around 115 if the veg reseed value is set to 10. That is a little worse but still pretty respectable.



  • .vel 30 < Available as simplebot4.txt


So how do we improve him still further?

Maybe there is some way we can use the value in .vel to calculate a suitable acceleration automatically. That would let Simplebot accelerate really hard when he needs to and cruise effortlessly once he reaches a good speed.

Try changing the action line in gene 3 from..

5 .up store to 30 *.vel sub .up store Available as simplebot5.txt

What does this line do? Well first we need to remember the order in which these calculations are carried out in Reverse Polish Notation. First we place 30 onto the top of the stack just by typing in the number 30. next we place the value stored in the memory location pointed at by the label .vel onto the stack. The * in front of the label means that we are using the value in the location rather than the number of the location. So now the stack has 2 numbers in it. First there is 30 then there is whatever value *.vel represents. The next thing we see in the code is the word sub. This tells the program to subtract the top number in the stack from the next number in the stack. In doing so both numbers are removed from the stack. The result of the subtraction is then placed on top of the stack again. So in effect we could have written something like a = 30 - *.vel if we had been using algebra. Next we take the number on top of the stack and move it to the .up memory location by using the store command.


No? Well here is one possible way to address the problem. We just stop the acceleration while ties are present. Luckily we have an easy way to detect the presence of ties with the new .numties function. This function automatically places a value into the .numties memory position every cycle so all we have to do is read it.

Try adding this line to the condition part of gene 3, right underneath the *.vel 30 < line.

  • .numties 0 = Available as simplebot6.txt


There are a number of ways to substantially improve Simplebot6. These include improving his food finding genes, possibly by adding an extra 2 genes to look at wider angle eyes such as *.eye1 and *.eye9. Look at the chart in appendix 2 to see where the eyes are able to see and which course changes to apply to .aimdx or .aimsx. You could also experiment with his acceleration genes by dividing the acceleration amount by 2 or 3 so he expends less energy.



  • .refeye 5 != Available as simplebot9.txt



Just load up I_Flamma. Give him a different color than Simplebot9 and 5 individuals at 3000 starting energy. Disable his mutation and start the simulation. Now let them fight it out for a while.




' Gene 7 wide search 1 cond *.eye1 *.eye5 > start -100 .aimdx store stop

' Gene 8 wide search 2 cond *.eye9 *.eye5 > start 100 .aimdx store stop Available as simplebot11.txt






ADVANCED PROGRAMMING!



The answer is simple too. He still expends too much energy, a lot of the time, just to keep living. He is also fraught with inefficiencies.




null null null null sure that if simplebot is already facing food then he does not turn at all. null nullnullnull 2. Avoid conspecifics. If this is overwritten then simplebot will just chase his family around and waste energy. 3. Turn toward food near to the center of his field of vision. 4. Turn toward food at the outer edges of his field of vision.





Change.

' Gene 7 wide search 1 cond *.eye1 *.eye5 > start -100 .aimdx store stop

into

' Gene 7 wide search 1 cond *.eye1 *.eye5 > start mult -100 stop





I am beginning to feel a little sorry for poor old I_Flamma. He is just getting his butt kicked up and down the screen all the time. So how is our population doing this time? It got up there around 170-180 pretty quickly but still seems to be rising a little bit. Looks like it topped out around 195. Not bad.

Hey! I just realized that simplebot is way up there on the Formula 2 league table by now. Perhaps we need to move on to the next rung. Try deleting I_Flamma and putting in I_Venia instead then run the simulation again.

Well that was a bit more of a battle. I_Venia came out on top eventually but simplebot put up a good fight.



  • .eye5 40 <




We are going to start by adding two new genes. Place them anywhere you like.




mult 628 50 inc

Why? You ask. Well the first line should be obvious by now. We are making simplebot rotate by a value of 628 (or 180 degrees). Since reproduction, shooting, tie firing and just about everything takes place after rotation on each cycle, this means that simplebot will rotate 180 degrees then pop out a baby. The 50 inc line is a bit less obvious. What we are doing is setting a reference value that will be used next cycle to turn simplebot back the way he was originally facing and carry right on feeding. We use inc instead of store to save energy.

We also have to go into the condition step of the reproduction gene and take out the line that we added in the last step. You know. The one that only allows simplebot to reproduce when his eye5 cell is almost empty. We have to get rid of this or the whole improvement would be pointless. We want simplebot to reproduce while he is still actively feeding. Go ahead and delete that line now.






What are ties? That is a good question. Ties are a feature of DarwinBots that was added in order to enable multiple individual DarwinBots to join up and form a multi cellular organism. A tie represents a defined relationship between two robots and is seen in DarwinBots as a thick line joining the two robots together. The tie keeps the robots in a fixed but flexible orientation to each other but only after a certain number of game cycles have passed. For the first 20 cycles the ties allow for free rotation of both robots.


For the time being we are not interested in hardened ties. If we wish to feed from the tie then we need to act fast, not wait 20 cycles before doing anything. The only thing we need to do is to utilize the energy transfer function to drain energy from the robot on the other end of the tie.


Here is Tie bot 1

' Tie-Bot 1

cond *.eye4 *.eye6 != start *.eye4 *.eye6 sub .aimsx store stop

cond *.vel 40 < start 40 *.vel sub .up store stop

end Available as Tie Bot 1.txt




I will eventually use a similar method to that employed by Simplebot but for the moment I will leave reproduction the way it is. You will see why a little later on.



Cond Start

.tie store stop This is a really stupid gene but demonstrates some of the difficulties associated with tie feeders.


Obviously we need to be a little more careful about when and where we shoot ties. We also need a way to feed through the ties once they are attached. First we need to add a condition or two to the gene that fires the ties. Change the gene to this. Note that we now have 10 eye cells so you will also need to change the other instances of .refeye to 10 as well.

cond *.eye5 30 > *.refeye 10 != start

.tie store stop


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

.tienum store stop The condition *.numties tells the DNA how many ties are currently attached to the robot. In this instance no attempt is made to feed unless at least one tie is detected.


? .refeye


The console output window should now read

? .refeye 708-> 0


cond *.robage 0 = start 50 rnd 55 store stop



  • .refeye 0 !=


  • .refeaimdx 0 !=


This is a real problem. Hey here is a thought. Those eye cells are always equal to 77 when a new robot is born so we could add this line.

  • .eye5 77 !=



.tie store and then to add an entirely new gene to follow it..

cond *.robage 1 = start

.deltie store stop



We can stop this either by making the targeting routine more accurate or by deleting the tie if it is attached to a friend. Lets try both.


  • .eye4 *.eye6 =


  • .eye5 30 <


14 56 store


Well Tie Bot 9 seems to work pretty good but it still does the same thing as before. We need to delete those ties I think.


  • 55 .readtie store

This will allow us to read the tref variables from the robot that we are tied to. We only need to use this line once since the value is never reset until we set it ourself. We will now be able to read values through the tie that corresponds to the value in *55. Next we will add a new gene..

Cond *.trefeye *56 = start *55 .deltie store stop





cond *.slime 90 < start 100 .mkslime store stop


Slime actually reduces the overall efficiency but gives a tie feeder a much better fighting chance when facing others of similar persuasion. We fan now only reach a population of around 320.

As before with simplebot, there are still a number of things that we could do to make Tie Bot even stronger. I will leave you to figure out what they are. A robot that can beat Devincio Eversor is quite good enough for a tutorial. There are many ways to create a tie-feeding robot as good as Tie Bot 11 This tutorial follows but a single path that was chosen for its differences from the methods used in Simplebot. As you can see from this tutorial, the possibilities are almost endless. I expect to see a whole bunch of new and stronger robots out there in the F1 league soon.

In the next part of this tutorial we will begin to delve into the complexities of creating stable Multi-Bots. If you think that the lessons you have learned this far have been complex then you are sadly mistaken. In order to make a Multi-Bot work properly we will need to learn a whole new set of rules.

Happy coding

Purple Youko