Xref: utzoo comp.lang.c:34519 comp.lang.c++:10682 comp.lang.pascal:4765 comp.lang.misc:6224 Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!usc!julius.cs.uiuc.edu!apple!well!nagle From: nagle@well.sf.ca.us (John Nagle) Newsgroups: comp.lang.c,comp.lang.c++,comp.lang.pascal,comp.lang.misc Subject: Re: help needed with vehicle movement algorithm/code Message-ID: <21959@well.sf.ca.us> Date: 4 Dec 90 20:19:20 GMT References: <1990Nov29.124312.1924@desire.wright.edu> Lines: 24 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 Brought to you by Super Global Mega Corp .com