Author Topic: Dna reading question  (Read 3909 times)

Offline Nosta

  • Bot Neophyte
  • *
  • Posts: 7
    • View Profile
Dna reading question
« on: November 04, 2013, 01:32:05 PM »
I am reading the WikiManual but there are things that I am not sure. One of them is the very important understanding of stacks and DNA reading.

It says, somewhere on the Wiki, that the stack is clean after reading all the DNA...So how does that works? 
Imagine the following DNA (described in english, not in code):

- Gene 1: If I dont see any organism, I will move forward (something like " 10 .up store").

- Gene 2: If I see an enemy I will eat it. (use shoot function)

- Gene 3 If I see a friend I will do nothing

Now I start a simulation with such organism. The DNA will Run: first it will check Gene 1, then Gene 2, then G3. Then, the memory will be  clean and the DNA starts reading again:  gene 1, gene 2 and so on. Correct? Is that the way it works?

Second question: if thats the way DNA works, I dont understand how is it possible for a bot to increase speed. Example with DNA reading: Gene 1 is read, then the speed increases 10 units (the speed goes from zero to 10), then gene 2 and 3, memory clean and then, a new cycle begins and Gene 1 is read (and so on). But since the memory was clean, the bot doesnt have the information that the last speed was 10, so it will start again from zero...

I am scracthing my head lol, because I am new to this stuff and I would like to understand some basic stuff before starting. I hope you can understant my questions because my english is not very good.

Thanks!

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Re: Dna reading question
« Reply #1 on: November 04, 2013, 02:41:22 PM »
10 .up is the increase in speed, not the actual speed. Think of how a rocket engine works.

 :thinkey: I am actually going to change the way buoyancy is stored for consistency.
« Last Edit: November 04, 2013, 02:47:43 PM by Botsareus »

Offline Testlund

  • Bot God
  • *****
  • Posts: 1574
    • View Profile
Re: Dna reading question
« Reply #2 on: November 05, 2013, 08:30:53 AM »
Now I start a simulation with such organism. The DNA will Run: first it will check Gene 1, then Gene 2, then G3. Then, the memory will be  clean and the DNA starts reading again:  gene 1, gene 2 and so on. Correct? Is that the way it works?

As I understand it Darwinbots will read the dna from top to bottom, but if gene 2 and 3 reports a "no" it will continue doing the gene 1 command.

Let's say it stops to eat another bot. Once the bot is eaten then the gene 2 will report a "no" and the code reading continues until the cycle is completed and it starts over with the gene 1 instruction again.

In my opinion the wiki is not clear on details. Some more examples exactly how and where to put the various code would be nice.

So the best way to learn Darwinbots is to experiment with different values and see what happens. Some dna commands are to hard for me to even guess how to use so I'll just stay away from those.  :P
The internet is corrupt and controlled by criminally minded people.

Offline Nosta

  • Bot Neophyte
  • *
  • Posts: 7
    • View Profile
Re: Dna reading question
« Reply #3 on: November 05, 2013, 05:46:53 PM »
Thanks for the answers :)

In fact wikimanual is not perfect for newbies like me, but its a good help.

As you said, the best way to learn is trying and I am already doing that :), tough some things are not easy to see at first. I remember that when I was learning a little about Blitzbasic language, I used text functions a lot so I could check when something would happen. For example, if I wanted to see when a specific function happens, I would replace it by some text ("Function XYZ happening now", whatever). Here, in Darwinbots, there is not the possibility to see text appearing on screen as the result of a gene execution, as the result of a function. If that was possible, I think I could explore even further the work of DNA.


Offline Nosta

  • Bot Neophyte
  • *
  • Posts: 7
    • View Profile
Re: Dna reading question
« Reply #4 on: November 05, 2013, 06:29:55 PM »
I made a bot just to try some things:
' GENE 1 - Move until reaching the speed of 40 (from what I could see, 60 is max speed)
cond
*.velup 40 <
start
5 .up store
stop


' GENE 2 - Rotate 90 degrees
cond
start
314 .aimdx store
stop
End

Then i tested the bot.
What I was expecting: the bot would walk some time forward (until reaching the speed of 40) and only then would rotate; since it would take somewhile to reach such speed, I was expecting to see the bot only walking forward for a few cycles (I suppose a cycle is reading the DNA once), then, after some cycles, it would rotate for the first time.

What happened: in a metal surface the bot will just rotate; in the standard (no fluid resistence) surface, you will see him globally moving more or less in one direction, while rotating 90 degrees every cycle; maximum speed will be something like 7 or 8. On any case, it seems that is not doing what I expected. Why?

Offline Testlund

  • Bot God
  • *****
  • Posts: 1574
    • View Profile
Re: Dna reading question
« Reply #5 on: November 06, 2013, 07:21:17 AM »
in a metal surface the bot will just rotate;

That's odd. It means the program is not checking if the bot has actually achieved 40 velocity.  :huh:

I prefer to have Viscosity and Density set to 1. It gives the most realistic movement imo. I imagine the DB environment is a square shaped dish seen from above with a thin layer of water.  :)
The internet is corrupt and controlled by criminally minded people.

Offline Nosta

  • Bot Neophyte
  • *
  • Posts: 7
    • View Profile
Re: Dna reading question
« Reply #6 on: November 06, 2013, 08:42:18 AM »
The only reason I see for not achieving 40 is due to the nature of how DNA works:
1) first it reads Gene 1, giving the "order" to increase the speed up to 10  IF the speed is not 40; so, the speed will increase, but just a little; it wont have the time to increase further because, in the next moment/second the DNA will read the second gene.

2) the bot rotates, but now is not accelerating, just rotating, and because of that speed will naturally decrease a little bit;

3) DNA reads again gene 1, and so on.

This means that the bot will have an erratic movement, not reaching the desired behavior: move straight forward, them turn 90?, move forward again and so on.

This is my explanation.

The only way I found to turn that problem around (in fact is not a problem, just me checking how things work on Darwinbots) was the insertion of a condition on gene 2: *.velup 40 >; it will rotate only if the speed is forty or more. Then I checked and it seems more like the expected behavior. Even so,
I think that the rotation will not happen exactly at 40, sometimes 43, and sometimes even 50. Maybe thats something related to the surface. I dont know.