help needed with vehicle movement algorithm/code
John Nagle
nagle at well.sf.ca.us
Wed Dec 5 07:19:20 AEST 1990
Try this:
- Simulate an attractive force between the tanks. The
strength of the attractive force is constant, or may
increase slightly as the distance decreases.
- Simulate a repulsive force between tanks and obstacles.
This force falls off with an inverse-square law.
- Compute the force resultant of all these forces on each
tank, and move in that direction.
Sometimes a tank will get stuck. This occurs when every possible move
leads to a worse position, that is, one where the magnitude of the
sum of the forces is higher. There are various ways out of this problem,
an interesting one being to inject some noise into the force calculation,
thus adding some randomness to the movement. Increase the noise level
slowly until the tank is unstuck. Note that this may result in panicky
appearing activity.
This won't solve mazes. But it will get you around.
John Nagle
More information about the Comp.lang.c
mailing list