Simple Bot

From WikiManual
Revision as of 17:07, 31 January 2006 by Ollj (talk | contribs)
Jump to: navigation, search


cond
*.eye3 *.eye5 >
start -25 .aimdx store
stop


cond *.eye7 *.eye5 >
start
25 .aimdx store
stop

cond
start
5 .up store
stop

cond *.eye5 40 >
start
-1 .shoot store
stop

cond
*.nrg 5000 >
start
50 .repro store
stop

end

Available as Simplebot1.txt




Simplebot2.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.

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.




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.


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.





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.


Simplebot10.txt


' 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

Simplebot12.txt


Simplebot13.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




..at the end of the genome. It has to be after every one of our modified genes for it to work. Finish off the modifications and start up the simulation again. Of course you could always just load up Simplebot14.txt

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 <

Simplebot15.txt and save yourself the trouble of changing it all. Go on. I know you want to.



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.