Darwinbots Forum
Code center => Darwinbots Program Source Code => Topic started 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.
-
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.
-
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.
-
- Yes exactly.
- Brownian motion will choose a random value between 1/10 of the value on the slider X -1 and 1/10 of the value on the slider, then apply that acceleration to the robot.
A value of 8 will result in a random acceleration between -0.8 and + 0.8
This is applied seperately to x and y directions using a different random number for each
- Friction. The robots current velocity is reduced by an amount equal to current velocity minus 1/10 of the value set in the friction slider.
Velocity = 10
Friction = 3
new Velocity = 10 - (10 X (3/10)) = 7
- Gravity is again applied at 1/10 of the value of the slider.
A gravity of 10 will result in a downward acceleration of 1
- Bouyancy is zero by default.
Its effects are cumulative with gravity but do not depend on it since in pond mode it is assumed that there must be gravity and also that that gravity will impart no acceleration on any creature that has neutral bouyancy with respect to the liquid in which it is currently swimming. Hence the reason why Bouyancy was unavailable outside of pondmode. (may not be true any more)
- Moving. You are right. It does have an effect. I just went in search of it and found a little one liner that multiplies all applied accelerations by a factor of slider value/100.
-
what are the movement relative to?
-
They are relative to your PC screen which may or may not be moving.
-
rofl
-
Maybe he's running DB on a laptop in his car while travelling at the legal speed limit down the highway.
-
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.
-
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?
-
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.
-
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?
-
Yes it is. I am going to make a new section for wiki called "TechDetails" - we can post info for advanced users there.