Author Topic: Chloroplasts  (Read 23869 times)

Offline Panda

  • Global Moderator
  • Bot Destroyer
  • *****
  • Posts: 476
  • Computer Science Undergraduate (nerd)
    • View Profile
Chloroplasts
« on: August 08, 2013, 09:27:38 AM »
From reading http://forum.darwinbots.com/index.php/topic,3487.50.html, it's just got way too complicated. I've come to it from after a few years and I have NO idea what's going on and how anything is happening.

I've a few questions, anyway:

What's happened to chloroplasts?
Should we rethink it?
Is any help needed? (I've had another 3 years of programming experience (1/3 of which is at University), I might not fuck it up as badly as I did last time.)

P.S. HEY GUYS! :D

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Re: Chloroplasts
« Reply #1 on: August 08, 2013, 10:57:38 AM »
I am on top of it Panda, I'll like to go with Shvarz logic, he is a Biologist after all.
I had a lot of more minor updates to grind trough and I started work so everything ended up being delayed.

http://forum.darwinbots.com/index.php/topic,3721.0.html

I can send you an excel file of what I was working on (statistically speaking)

(I'll trust that you can program it in, but some concepts you may not like, such as, we need to make chloroplasts as part of the DNA file, We can go step by step and figure it out. TY for your offer to help, I need it right about now :) )

Let me know, I'll upload my most resent updates on the weekend. And If you are not too busy you should be able to knock it out in a week.

There is also http://forum.darwinbots.com/index.php/topic,3816.0.html check out reply #5

This is done so robots do not get free energy with repopulating chloroplasts when they are not supposed to. Once again this is following Shvarz logic. I am getting a lot of heat on this specific topic. (We can discuss further :) )
« Last Edit: August 08, 2013, 11:08:58 AM by Botsareus »

Offline Panda

  • Global Moderator
  • Bot Destroyer
  • *****
  • Posts: 476
  • Computer Science Undergraduate (nerd)
    • View Profile
Re: Chloroplasts
« Reply #2 on: August 08, 2013, 12:00:10 PM »
From reading through this, I cannot work out exactly what you want from chloroplasts. I know it would take time but if you could put down in here what you want, in sudo code or in words, it would make it a lot more clear for me.

If not, I'll try to work out what is wanted but it'd take me quite a while.

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Re: Chloroplasts
« Reply #3 on: August 08, 2013, 12:50:52 PM »
I am at work now, I'll get you my excel file and an explanation on Saturday.

Please tell my you have excel? If no, not a big deal, I'll write up a little vb progy that crunches the data.

Offline Panda

  • Global Moderator
  • Bot Destroyer
  • *****
  • Posts: 476
  • Computer Science Undergraduate (nerd)
    • View Profile
Re: Chloroplasts
« Reply #4 on: August 08, 2013, 12:51:50 PM »
I don't have excel but I can upload it to google, I'm sure it can show it for me! :D

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Re: Chloroplasts
« Reply #5 on: August 08, 2013, 12:53:08 PM »
k, will do.

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Re: Chloroplasts
« Reply #6 on: August 10, 2013, 11:05:36 AM »
I want to go over some pointers before I get into the good stuff. First, you will see me use square and square-root at places. There are two reasons why I do that:

1.)   I need to convert from Area (2D) to value (1D)

2.)   It just looks and feels better. We may need to play with these further though.

Second, I want to make changes to the Options Form layout as little as possible. In fact, if we go with my system we will not need to touch options form at all.

Finally, this is not what I want to see from chloroplasts, In fact, my views on chloroplasts where completely different. But, after talking to Shvarz, his system is actually pretty good.

Ok, here we go:

Attached is an excel file that shows visually all formulas described herein:

In an ideal world for plants, the amount of light they receive should be a constant. It is not. The two main factors that affect the amount of light a plant gets are

1.)   Is it night or day?

2.)   How much light is left available in the system?

The first one is easy to code for, we just base it on the current code. We need to start modifying the current code to code for the second.

Let us take a look at feedvegs in vegs.bas. I want to keep that subroutine and modify it. If we do that we can use the existing vegy options (Figure 1) and also we don't have to modify night and day options or even the pond mode options.

1.)   We have to reprogram that subroutine so it works on all robots. Any robot can have chloroplasts after all. We still need to keep the veg distinction in the species structure so the system knows what robot to repopulate. I'll talk about that in detail later.

2.)   Here is where it gets tricky. We have to start modifying after tok is calculated. The line you are looking for is:

Code: [Select]
If tok < 0 Then tok = 0
We need to figure out how much light we have available in the system. Acording to shvarz this is done by calculating the ratio of total available space in the current simulation (based on simulation dimensions) to the total area of all robots in the simulation.

Code: [Select]
Area Inverted = Total robot area / Screen area
Now we figure out the actual area to correct chloroplasts by.

Code: [Select]
Area correction = ( 1 - Area Inverted) ^ 2 * 4
Now we figure out how much chloroplasts the robot has based on 1 unit. I think 16000 chloroplasts should be equal 1 unit.
Code: [Select]
Chloroplast correction = Chloroplasts the robot has / 16000
Now we figure out the actual rate the robot is being fed. We multiply by 1.25 to offset the amount of energy lost for sustaining chloroplasts. 'tok' already exists in the subroutine as the feeding rate. We simply use it here.

Code: [Select]
Add energy rate = Area correction * Chloroplasts correction * tok * 1.25
Now we have to figure out how much energy it costs for sustaining chloroplasts:

Code: [Select]
Subtract energy rate = (Chloroplasts the robot has / 32000) ^ 2 * tok
Now we figure out the actual feeding rate. Let us cal acttok for simplicity:

Code: [Select]
acttok = Add energy rate - Subtract energy rate
The rest of the code should now use acttok instead of tok.

And that should be all the changes required for feeding vegys. Let us quicly take a look at mass and robot radios.
Shvarz has recommended to me that we apply chloroplast mass to the robot more gradually we square it here.

Code: [Select]
Added mass = (Chloroplasts the robot has / 32000) ^ 2 * 31680
We are not going to touch robot radios because there are limits to the distance ties can stretch and ties are calculated from the robots center. I think we should have an indicator for chloroplasts like the indicator for shell or energy. Look into DrawRobPer.

Now let us talk about how the system will keep track of how much chloroplasts a robot has. I don't want a label in robot info to display the chloroplasts. I want an actual value in the DNA. This way we do not need to modify the vegy code to make the system recognize them as vegys. We just put the value on top of the dna, example:

Code: [Select]
'#chlr: 16000
cond
  *.nrg
  6000
  >
start
  50
  .repro
  store
  15
  .aimdx
  store
stop
end

The value will be displayed in the dna when you click show dna and when you extract dna to file. When you set robots to 'repopulate' (called vegys in version 2.45.01) the system should ask you if you want to reset their chloroplasts to 16000.

The other reason is, there is a good chance some robots do not update their chloroplasts each cycle. I need a way of knowing how much chloroplasts a robot has at all times, this should not be epigenetic.

As far as the command, I think all we need is a simple .chlr variable in the 900s range that differentiates between read and write. Look at how I differentiate for tielen...tieang 1...4 in Update_Ties in Ties.bas. There are three stages:

1.)   Input: Only change chloroplasts if flag was triggered (this cycle)

2.)   Clear Input: Reset flag (this cycle)

3.)   Output: current chloroplast levels stored back into memory (this cycle)

Also, look at the changes in DNAstore in the DNAexecution.bas to get the complete picture of this method.

I don't think we need share chloroplasts or anything like that because according to Shvarz it is not important to change energy when creating or destroying chloroplasts. Also, a baby will have exactly the same amount of chloroplasts as its mama.

Also make sure you add chloroplasts to SaveRobotBody and LoadRobotBody in HDRoutines.bas so that chloroplasts are saved as part of the simulation file if anyone wants to resume a simulation later and for debugging purposes.

Now let us talk about the robot repopulation. I want to keep it the same as it currently is (Figure 2) for the options form. What it does however, will be a little different.

We need to calculate the total amount of chloroplasts across all robots / 16000. Let us call this 'allchlr'

sudo:
Code: [Select]
If allchlr > Max avg. vegys Then do not let vegys reproduce
Code: [Select]
If allchlr < Repopulation threshold avg. vegys Then the repopulate vegys using current repopulation rules. (Robots per repopulation event and repopulation cool down period)
(edit: By 'vegys' here, I mean repopulating robots, sorry for the small confusion)

The main change here is that repopulation is no longer a static value. It depends on how much total chloroplast is on the screen. Hopefully, this will lead to robots evolving their own chloroplasts and not being depended on 'repopulating' robots at all because the system only repopulates when non-repopulating robots do not use chloroplasts.

I tried to make my explanation as clear as possible, if you have any further questions let me know. Please, if you decide to code this stuff in, use the revision currently in the trunk in the svn, I submitted all my latest updates this morning.
« Last Edit: August 10, 2013, 11:13:11 AM by Botsareus »

Offline Panda

  • Global Moderator
  • Bot Destroyer
  • *****
  • Posts: 476
  • Computer Science Undergraduate (nerd)
    • View Profile
Re: Chloroplasts
« Reply #7 on: August 10, 2013, 11:27:21 AM »
Quote
I don?t think we need share chloroplasts or anything like that because according to Shvarz it is not important to change energy when creating or destroying chloroplasts. Also, a baby will have exactly the same amount of chloroplasts as its mama.

Does this mean that a robot can create and destroy chloroplasts without expending or gaining energy and that the only cost of chloroplasts is that of the upkeep? I think this is my only question. :)

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Re: Chloroplasts
« Reply #8 on: August 10, 2013, 11:32:16 AM »
Pretty much, yea.

The upkeep is a constant based on chloroplasts and tok.

And the actual profit is based on total robot area and tok and chloroplasts.

The cool part about that (in my view) is the fact that we need to add just one more sysvar called .chlr

Offline Panda

  • Global Moderator
  • Bot Destroyer
  • *****
  • Posts: 476
  • Computer Science Undergraduate (nerd)
    • View Profile
Re: Chloroplasts
« Reply #9 on: August 10, 2013, 11:44:00 AM »
I will do this for now. However, to balance chloroplasts, I think we may need to add another cost on top of the upkeep of them. I can see a few consequences of not doing this. There will be an optimum number of chloroplasts for a robot to have and still move and to gain energy. It may become a tool for non-veggies to get some extra energy. Just a thought.

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Re: Chloroplasts
« Reply #10 on: August 10, 2013, 12:01:03 PM »
Yes, let's do this for now.

If it is very ugly we can always add rules for getting or losing chloroplasts, and change the mass formula from ^ 2 to ^ 1.5 or something like that.

Offline Panda

  • Global Moderator
  • Bot Destroyer
  • *****
  • Posts: 476
  • Computer Science Undergraduate (nerd)
    • View Profile
Re: Chloroplasts
« Reply #11 on: August 10, 2013, 12:06:30 PM »
Yeah, it does mean a lot less work. :D

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Re: Chloroplasts
« Reply #12 on: August 10, 2013, 01:10:19 PM »
Quote
If it is very ugly we can always add rules for getting or losing chloroplasts

Wait a minute, following my own logic, this will not work because robots can be loaded in with some chloroplasts.

I have a better idea, if robot has like under 4000 chloroplasts their chloroplasts are not active and does not count to 'allchlr'
« Last Edit: August 10, 2013, 01:13:44 PM by Botsareus »

Offline Panda

  • Global Moderator
  • Bot Destroyer
  • *****
  • Posts: 476
  • Computer Science Undergraduate (nerd)
    • View Profile
Re: Chloroplasts
« Reply #13 on: August 10, 2013, 02:07:21 PM »
I don't think that's a fair limit exactly. We can leave it for a while anyway and discuss it after running a few trials. I'm sure we will have to tweak anyway!

Offline Panda

  • Global Moderator
  • Bot Destroyer
  • *****
  • Posts: 476
  • Computer Science Undergraduate (nerd)
    • View Profile
Re: Chloroplasts
« Reply #14 on: August 11, 2013, 05:37:23 PM »
Quote
As far as the command, I think all we need is a simple .chlr variable in the 900s range that differentiates between read and write. Look at how I differentiate for tielen...tieang 1...4 in Update_Ties in Ties.bas. There are three stages:

1.)   Input: Only change chloroplasts if flag was triggered (this cycle)

2.)   Clear Input: Reset flag (this cycle)

3.)   Output: current chloroplast levels stored back into memory (this cycle)

Why is this necessary? If the number of chloroplasts is different then shouldn't it just change the number of chloroplasts or am I missing something, rather than using flags?

Quote
Now we have to figure out how much energy it costs for sustaining chloroplasts:

Code: [Select]
Subtract energy rate = (Chloroplasts the robot has / 32000) ^ 2 * tok


There won't be a cost if it's not daylight because it's written in that way. Unless there's not meant to be a cost overnight?



I believe I have done everything but:

Quote
We just put the value on top of the dna, example:

Code: [Select]
'#chlr: 16000
cond
  *.nrg
  6000
  >
start
  50
  .repro
  store
  15
  .aimdx
  store
stop
end

The value will be displayed in the dna when you click show dna and when you extract dna to file. When you set robots to 'repopulate' (called vegys in version 2.45.01) the system should ask you if you want to reset their chloroplasts to 16000.
« Last Edit: August 11, 2013, 06:48:40 PM by Panda »