Code center > Darwinbots Program Source Code

Movement

(1/3) > >>

shvarz:
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.

PurpleYouko:
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.

shvarz:
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.

PurpleYouko:

* 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.

Zelos:
what are the movement relative to?

Navigation

[0] Message Index

[#] Next page

Go to full version