Darwinbots Forum

Code center => Bugs and fixes => Topic started by: Testlund on June 22, 2006, 04:18:38 PM

Title: No gain or loss of energy in 2.42.6c
Post by: Testlund on June 22, 2006, 04:18:38 PM
I think I have found a bug here. Despite that the sun is up no one gains or loses any energy unless they are hit by a shot. The veggies are really tiny.
Title: No gain or loss of energy in 2.42.6c
Post by: Testlund on June 22, 2006, 04:23:51 PM
Oh, I just remembered! I have set it so there should be no costs when bots drop below 50! Bot it's still weird they are not gaining any energy.
Title: No gain or loss of energy in 2.42.6c
Post by: EricL on June 23, 2006, 01:04:41 AM
Testlund, you did it again!  How you find these things....

This is indeed a real bug, a rather old one I suspect, most likely has been there since the different veggy feeding methods were added.

Bascially, in the routine FeedVegs(), the tempory variables "energy" and "body" are used to calculate the amount of nrg and body to give each veg, depending upon the feeding method being used and other things, specifically their body size for kilobody feeding.  They are defined as type "long", which while capable of storing really large numbers, has a lot less decimal precision then the type "single", which is how nrg and body are usually stored for each bot.  

Because your veggies are small and because your were giving them a small amount of enery per kilobody per cycle, what was happening is that the energy calculated to add each cycle, while non-zero was pretty  small, say perhaps something like 0.003, too small for a long to handle.  The long-typed variables were getting rounded to 0 when VB coerced them to singles.  Your small veggies got nothing.

So, basically, ever since the feature has existed, kilobody feeding has not worked for small per cycle amounts for very small body veggies.

Very very nice find.  Bug of the week for sure.  Amazing.

Fixed in 2.42.7.
Title: No gain or loss of energy in 2.42.6c
Post by: Numsgil on June 23, 2006, 02:24:55 AM
*shakes fist*

Untold numbers of bugs from type conflicts.
Title: No gain or loss of energy in 2.42.6c
Post by: Testlund on June 24, 2006, 10:21:03 AM
Quote from: EricL
Testlund, you did it again!  How you find these things....

It's because of my bad luck with things, but I guess it serves a purpose here.  
Title: No gain or loss of energy in 2.42.6c
Post by: Numsgil on June 24, 2006, 12:41:14 PM
You should really market your skills Testlund.  You're like the ultimate software tester.