Robot Tutorial

From WikiManual
Revision as of 18:41, 16 September 2005 by 66.91.138.34 (talk)
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.


Tie Feeder Tutorial

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