Darwinbots Forum

Code center => Darwinbots Program Source Code => Topic started by: shvarz on April 06, 2005, 11:40:24 AM

Title: Movement
Post by: shvarz on April 06, 2005, 11:40:24 AM
Can someone tell me how the movement is calculated for bots?  I know that .up and .down provide acceleration, but how do "movement factor" and "friction" are applied?  How are the values on "options" panel relate to the speed?

I assume that "gravity" and "brownian motion" simply adjust the position of a bot, without actually affecting it's speed, but I also would like to get some idea on how the values in "options" relate to the actual bot movement.

Thanks.
Title: Movement
Post by: PurpleYouko on April 06, 2005, 01:20:39 PM
Actually your assumption is wrong

Gravity and brownian motion both apply an acceleration to the robot, as does bouyancy in pond mode. Friction simply reduces the present velocity by a factor.

.up, .dn, .sx and .dx all apply an acceleration in the specified direction. This acceleration is split up (by the program) into x and y vector acceleration such that the net effect is to accelerate the bot relative to the direction it is facing.

In the program loop, all accelerations from all sources are added together then if they exceed 100 (magnitude) in either x or y direction they are capped at 100.

Next, these accelerations are applied to the robots (added to the present velocity) in directional vectors (the direction the robot is facing) and compared with the robot's current maximum velocity (calculated by its size and mass and available to the DNA via *.maxvel). If the new velocity is greater than *.maxvel then it is capped at that value.
maximum velocity is unrelated to anything in the options panel

Next the robots are actually moved.


Swimming factor is only designed to allow MBs to swim by girating around. For regular sims you should just ignore it.
As for Moving factor?  :blink:
I have no idea what it does. I have never come across any code that references it in any way. I haven't ever actually gone looking for it but I just haven't encountered any in the physics modules.
Title: Movement
Post by: shvarz on April 06, 2005, 01:44:54 PM
OK, just to simplify things, let's consider just one direction (vertical)

then to get new velocity program sums up accelerations (or decelarations) from 5 sources:

1. .up and .down.  The values are directly related to speed, 10 .up means velocity will increase by 10

2. brownian motion.  How are values from option screen relate to speed?  What would 4 do, what would 8 do?

3. Friction.  Same question - what do values in the option screen mean?  Does it depend on bots' size?

4. Gravity. Same question.

5. Bouyancy.  Is it 0 by default (meaning no effect)?  Can it be negative (pull bot down)?  Does it depend on value of "gravity"?  In theory it should, but I don't know if that was implemented?


About moving factor - it certainly is somewhere in the program - I can see the effects of it.  Set it too small and bots don't move at all, set it very high - they run like crazy.
Title: Movement
Post by: PurpleYouko on April 06, 2005, 02:15:05 PM
Title: Movement
Post by: Zelos on April 06, 2005, 03:08:58 PM
what are the movement relative to?
Title: Movement
Post by: PurpleYouko on April 06, 2005, 03:50:27 PM
They are relative to your PC screen which may or may not be moving.
Title: Movement
Post by: Botsareus on April 06, 2005, 03:51:52 PM
rofl
Title: Movement
Post by: PurpleYouko on April 06, 2005, 03:56:01 PM
Maybe he's running DB on a laptop in his car while travelling at the legal speed limit down the highway.
Title: Movement
Post by: Numsgil on April 06, 2005, 04:44:46 PM
Movement factor is the percentage of any accelerations that actually make it to movement.  I guess it represents imperfect cilia and stuff.  Set it to zero and the only way to move is with ties(I think), so it certainly has some uses.
Title: Movement
Post by: shvarz on April 06, 2005, 05:30:55 PM
So, you are saying that "10 .up store" actually is not directly converted to velocity of 10, but to velocity of 8 at most, when moving factor is 80?

And what do you mean by "any" acceleration?  Is it applied after ALL accelerations are calculated?  Or it only refers to .up and .down commands?
Title: Movement
Post by: Numsgil on April 06, 2005, 07:42:30 PM
I can't remember for sure, but I think it's just for applied acceleration using .up, .dn, etc.

Yep, if you store 10 in up the best speed you can get it 8.  That was one of the first things I figured out when I got the program.  If you look, Ymir tries to compensate for this.
Title: Movement
Post by: PurpleYouko on April 06, 2005, 11:01:09 PM
Then again though, if your robot is really skinny and has a body mass of 0.5 then you will get a speed of 16 from an up value of 10 (actual 8)

Is this getting confusing or what?
Title: Movement
Post by: shvarz on April 06, 2005, 11:04:18 PM
Yes it is.  I am going to make a new section for wiki called "TechDetails" - we can post  info for advanced users there.