Advertisement

Autonomous Entities

Started by June 04, 2005 02:43 AM
3 comments, last by Anidem 19 years, 8 months ago
Ok, I'm a little stuck creating my autonomous entity, in visual basic. It's nothing special really, I just want it to avoid collision better. Right now, my algorithm is flawed, in that it allows the agent to cross over a boundry too often. I really just need theory, my current algoritm checks with an invisable line (probe) from the outside radius of the agent to the agent's velocity*25 (a number I choose because it estimates well). It does this in a loop, and checks each pixel in front of the agent. if there is a collision between this line and a boundry, the velocity is lowered and the heading is changed (+15 degrees). This isn't producing the results I wanted, perhaps it has something to do with timing the braking properly, and/or changing the heading in the right direction /w the right ammount of change. Or maybe I shouldn't check each pixel, and there is a better method? One last thing, is there a specific formula for determining the + or - number of degrees from an object with a position and heading (x,y @ heading) and a point (x,y). Basically for turning to a goal. Thanks!
Ok, so I'm having a little trouble with this because there are from what I see multiple equations. First being A @ B = AX*BX + AY*BY (let @ be the dot product). So that is the dot product, but from that the following equation can be satisfied A @ B = |A| * |B| * Cos(Theta). I can further derive it to this form:

(AX*BX + AY*BY) <-The dot product
ArcCos -------------- = Theta (The angle difference)
|A| * |B| <-The multiplied lenght of vector a & b

So it got screwed up, but so far is that right? To the angle take the ArcCosine of the dot product divided by the multiplied lenght of vector a and b? Then after I find the angle, I find if I should turn left of right with help from the cross product? Then I just turn left or right until I reach that angle? I'm also having trouble with the cross product, from what I understand it is A X B = AX*BX - AY*BY, however, do I use that or this equation
A X B = |A| * |B| * Sin(Theta), to determine to turn left or right?

[Edited by - Anidem on June 5, 2005 1:53:09 PM]
Advertisement
Cool! Thanks!

This topic is closed to new replies.

Advertisement