Darwinbots Forum

Code center => Bugs and fixes => Topic started by: shvarz on April 22, 2005, 06:10:13 PM

Title: Is this a bug?
Post by: shvarz on April 22, 2005, 06:10:13 PM
Here is something weird I noticed.  Just to re-cap, I am evolving Dom. Inv. to conditions with high friction and running food.  I started with Alga grexa as running food, but I was modifying it a bit to adjust for increasing friction.  Mostly I was increasing it's speed.  Now I am at friction 7.0 and I noticed something weird about the way Alga grexa is behaving: it often sits in one place, almost not running.  PY suggested that it is because veggies get body points when fed and that Grexa accumulates those body points and becomes so fat that it can't move.
So I added a gene that converts body into energy when body exceeds 5000, but that did not seem to help.  And about the same time I noticed that the whole energy flow in my sim started toget messed up: slight changes to amount of energy given to veggies led to huge variations in bot populations.  And another strange thing: Veggies would grow like crazy, yet I saw some of them simply go "puff!" and disappear as if from not geting enough energy.  Crazy stuff!!!

So I went to console and started poking around: What I see is that two veggies are almost identical, they have tons of energy (they are maxed out at 32000) and they have somewhere around 5000 body points (of course).  Yet one of them runs at pretty high speed, but the other one can barely move.  I am attaching the settings file and the new grexa.  Take a look and see if you can spot something weird or if you can explain what is going on.
Title: Is this a bug?
Post by: Shen on April 22, 2005, 07:05:05 PM
YES! I thought I was going nuts! In my evo sims ive been noticing the same thing!

It shell, absurd amounts of it, like 5000. Your bots get more mass than there .up genes input so they cant move. I figured it was some wierd mutations spraying random values around the place but ruled that out. You sometimes get poison and venom as well.

At least I do, check yours and report back so I know im not going insane.
Title: Is this a bug?
Post by: Numsgil on April 22, 2005, 07:35:40 PM
Definately check shell.  Shell really screws with speed, way more than body ever could.  And since the limit on shell has been eliminated, it's possible for bots to accumulate enough shell to not be able to move at all.
Title: Is this a bug?
Post by: shvarz on April 23, 2005, 02:08:03 AM
Hmm, how would they get shell?  These are just veggies, there is no shell-making genes.  A bug? I'll check later, too drunk right now.
Title: Is this a bug?
Post by: PurpleYouko on April 23, 2005, 10:50:34 AM
There is actually one small bug that I am aware of that relates to mutations.

Since the major changes in the mutations code recently, somehow a setting of zero in "Rate of mutation of mutations" doesn't get fixed properly.
In other words it mutates.
It takes a lot of iterations to move it away from zero due to the nature of the gaussian shift in rates. However it does eventually become one or two in some bots and then other rates begin to change.
I have seen a population of non-mutating bots produce major mutations occasionally. These mutations rarely survive though so they don't spread through a population like regular mutations.

It is possible that one of your sysvars has mutated in some of these veggies.
Title: Is this a bug?
Post by: shvarz on April 23, 2005, 12:21:23 PM
No, my veggies are not mutated and I see this behavior almost immediately after I start the sim.
Title: Is this a bug?
Post by: Shen on April 23, 2005, 04:49:24 PM
One thing might be waste. If your pushing your friction right up it takes huge amounts of nrg to move so the waste builds up quickly, then you get alzhiemers throwing large numbers into .mkshell etc. I only noticed this same thing when I put KE mode on so it could be that.
Title: Is this a bug?
Post by: shvarz on April 23, 2005, 11:08:49 PM
Hmm, that's an idea.  I have KE mode ON.  So, can that be balanced by increasing the "Waste threshold"?  What does it do anyway?
Title: Is this a bug?
Post by: Numsgil on April 24, 2005, 02:29:12 AM
Waste threshold increases the level of waste you need before bad things happen :P
Title: Is this a bug?
Post by: PurpleYouko on April 24, 2005, 10:11:38 AM
Except that these are Alga we are talking about.
They should metabolize their waste to energy every cycle unless that has been changed recently or is broken.
Title: Is this a bug?
Post by: Numsgil on April 24, 2005, 10:44:43 AM
But if they can't mebo it fast enough...

And pwaste levels slowly rise too.
Title: Is this a bug?
Post by: PurpleYouko on April 24, 2005, 11:34:37 AM
Veggies were designed to never, ever build up either waste or pwaste. Unless something has been changed or broken with "feedveg2" or calls to it, this should not be possible.

It is possible that waste could very briefly cross the waste threshold in an alga that actively spends energy (like Grexa).

I have noticed that for some reason, .fixpos often gets set to non-zero in robots that are suffering from Altzheimer's. his means they can't move no matter how hard they try. This quite often happens in sims with older (pre-waste) robots like I-Flamma.
Title: Is this a bug?
Post by: Shen on April 24, 2005, 12:40:41 PM
I've done a bit of testing and waste does indeed cause bots to make large amounts of shell. However Ive also seen bots accumulate large amounts of waste in very short periods, like 1000 in a few dozen cycles. So something is broken there me thinks.

Hmm, related bug. It seems collisions move fixed bots.
Title: Is this a bug?
Post by: PurpleYouko on April 24, 2005, 05:58:38 PM
Quote
Hmm, related bug. It seems collisions move fixed bots.

Already noted this in a different thread and I have already fixed it in the latest release of 2.36.5 on the old FTP. Also allows my Inchworm bot to work properly again.
Title: Is this a bug?
Post by: shvarz on April 25, 2005, 04:13:59 PM
Update:  Here is what I noticed: The "slow" bot can be turned into "fast" bot if it's speed is increased artificially.  I make a "fast" bot to crash into a slow bot and give it some momentum.  After that the "slow" bot runs fine on its own.

My guess is it has something to do with the way acceleration/decelaration/friction are calculated, becasue I started to see this problem when firction got pretty high.
Title: Is this a bug?
Post by: PurpleYouko on April 26, 2005, 08:55:28 AM
Which exact version are you using?
I recently fixed a problem with acceleration and friction but I don't remember if it made it into the "official" version on the DarwinBots.com server.
I definitely uploaded it to the old FTP site. If you are not running that version then I suggest you change over to it. Might fix your problem and if it doesn't then at least we have identified an area to look at.
Title: Is this a bug?
Post by: shvarz on April 26, 2005, 01:49:21 PM
OK, that fixed the problem! I don't see the slow buggers anymore!

One suggestion though is to change the version number even if you fixed something small.  First, that let's everyone know that this is a new version with another bug fixed.  Second, if you fixed something and broke something at the same time, then we can easily roll back to previous, more stable, version.  You and Nums being the only two programmers - any version that comes out can be called "official" :)

Here is another mistery for you:  Take those settings and the Alga grexa that are attached to my first post in this thread and remove all the hunters (just add alga minimalis as a hunter).  Now you can just look at what happens with veggies.  Start the sim and this is what you should see: The first generation of Alga grexa are actually spending more energy then they are getting, so they die within 100 cycles or so.  The program reseeds and they die again.  But after a couple of reseeds there appears an Alga that actually spends less than it gets and that one flourishes and starts dividing and such.  So what's the deal with that?  Mutations are disabled, so it's not a mutant.  

My guess is that it has something to do with how much bots are charged for movement.  First bots are running very fast and are charged a lot.  Then through some chance there appears a bot that accumulated enough body to slow it down.  Since it is slowed down by body, it will be charged less - therefore, it will survive.  All it's children will get a portion of its body, so they are also not running as fast.

If this is true, then I think that costs of movement should be adjusted.
Title: Is this a bug?
Post by: Numsgil on April 26, 2005, 02:03:50 PM
I couldbe wrong, but I think movement cost is equal to:

actual movement * mass

so I don't think that's the problem.
Title: Is this a bug?
Post by: shvarz on April 26, 2005, 02:10:44 PM
Yes, but if the "actual movement" is a function of mass, then that may lead to the weirdness I described.

Example.  Two bots, one is light and the other is heavy:
mass1=1,000
mass2=5,000
.up=10
cost1 (in whatever units)=1,000x10=10,000
cost2= 5,000x10=50,000

Your adjusted case:
mass1=1,000
mass2=5,000
.up=10
Adjusted .up1=10
Adjusted .up2=2
cost1=1,000x10=10,000
cost2=5,000x2=10,000
Title: Is this a bug?
Post by: shvarz on April 26, 2005, 02:16:14 PM
I think we should consider .up to be the force applied by the bot and charge based on that force alone.

Consider this scenario:  you have 1000-pound rock and two people try to move it in turn.  First one pushes it very slightly, the second one makes an honest effort.  Neither of them moves the rock, yet the energy they spend is very different.  Same with bots, we should not charge by end result, we should charge by the effort.  

If I remember correctly, the KE mode was very-very harsh before you changed it to "charge for effect".  I was glad at first, but now I think it is a bad idea.  So, maybe we should go back to "charge for effort".  To make it less harsh, maybe we can charge less for that effort than before.
Title: Is this a bug?
Post by: PurpleYouko on April 26, 2005, 02:49:28 PM
Quote
I think we should consider .up to be the force applied by the bot and charge based on that force alone.

That is exactly how it works now.

The net acceleration change (from up dn sx dx) in the direction the robot is facing is first calculated.
This is the value that is charged for.

Additions of other accelerations (such as those caused by collisions) are added after costs are calculated, then adjustments to acceleration due to mass considerations are applied at the end.

This means that a fat robot with a mass of 2 storing 10 into .up will be charged 10 but will only acrue 5 extra speed.
A really skinny bot with a mass of 1/2 storing 10 into .up will be charged 10 but will acrue 20 extra speed

I have no idea where this strange behaviour of your robots is coming from. I will see if I can check it out as soon as my present F2 league run finishes.
I am currently up to 37 rounds in a battle between a new Hunter species and Light's Icarus. Hunter is up by 21 to 15 but that is still a statistical draw. A typical round lasts about 10,000 cycles so it is likely to take a while.  :(
Title: Is this a bug?
Post by: Shen on April 26, 2005, 02:56:12 PM
Just wondering how maxvel figures into this? If I just write a gene that is constantly on with 50 .up store, will the bot get charged for the 50 or will it be decreased because of the velocity cap?
Title: Is this a bug?
Post by: shvarz on April 26, 2005, 03:08:58 PM
Quote
This means that a fat robot with a mass of 2 storing 10 into .up will be charged 10 but will only acrue 5 extra speed.
A really skinny bot with a mass of 1/2 storing 10 into .up will be charged 10 but will acrue 20 extra speed


Well... see, I seem to remember that Numsgil changed that at some point.  

Shen's question is good too.  Because Alga grexa almost constantly stores 16 (or 17) in .up  Will that bring it to high velocity and then allow it to stay there at little cost?
Title: Is this a bug?
Post by: Numsgil on April 26, 2005, 03:30:09 PM
Here's how it works:

Calculate how fast the robot wants to go.

cost = Sqr((Newaccelx / .mass) ^ 2 + (Newaccely / .mass) ^ 2)

Normalize speed so the bot isn't going too fast.  Ie:

If tvel > Maxspeed Then       'limits speed to maxspeed
        Reduce = tvel / Maxspeed
        .ax = .ax / Reduce
        'Newaccelx = Newaccelx / Reduce
        .ay = .ay / Reduce
        'Newaccely = Newaccely / Reduce
        tvel = Maxspeed
      End If

Does that answer any questions?  My brain is tired right now

 :D  :D
Title: Is this a bug?
Post by: PurpleYouko on April 26, 2005, 05:23:02 PM
Quote
cost = Sqr((Newaccelx / .mass) ^ 2 + (Newaccely / .mass) ^ 2)

The two Newaccel variables represent the x and y vectors of the acceleration applied only by up, dn, sx and dx

This is done before we calculate the actual change in velocity

Quote
Well... see, I seem to remember that Numsgil changed that at some point.

He changed some of the code in that part of the program but this is the way the code is right now in th ecurrent version. I just checked. And the bits that Num just posted are directly out of 2 different parts of the source code.
Title: Is this a bug?
Post by: PurpleYouko on April 26, 2005, 05:27:17 PM
Quote
Just wondering how maxvel figures into this? If I just write a gene that is constantly on with 50 .up store, will the bot get charged for the 50 or will it be decreased because of the velocity cap?

Only the velocity will be decreased by the cap
The cost will be exactly which acceleration you asked for, up to a maximum value of 100.

This is not true of KE mode however. In that mode you get charged for exactly what you receive. (unless that is different now. Num changed something in there too)
The KEs (1/2MV^2) for before and after the acceleration are calculated and you are charged for the difference.
Title: Is this a bug?
Post by: shvarz on April 26, 2005, 05:33:12 PM
And I am running KE mode!
That's what I was talking about!  Yay!

This needs to be fixed, really.  It should work just like in regular mode.  As I said, it used to be very touch, but we can compensate for that by charging less in the first place.