contour tracing obstacle avoidance question

Started by
2 comments, last by jimywang 20 years ago
ive learnd a technique which is mentioned in windows game programming guru called contour tracing.it is basically said that when object hits a obstacle then trace around the edge of the obstacle until a clear path is found.i tried it in my game but found a serious problem with it.image the suitation is like this

-------------------
        |  *     |
        |        |
        ----  ----
        A
 
where * is the player and A is the place AI got stuck on.how on earth the AI gonna know the right way of doing it is to trace the wall around the right rather than to the left and trace forever?i would be really appreciated if anyone can give me an advie.thanks. [edited by - jimywang on April 14, 2004 5:51:37 PM] [fixed the code box -Si] [edited by - SiCrane on April 14, 2004 6:33:43 PM]
Advertisement
You could make a maxiumum trace amount, and then trace the other way. Just say like,

int traceLeft()
{
...
if pixelsTraced > maxTrace then
{
traceRight;
return 0;
}
...
return openPoint;
}

Or something along those lines.
or check both ways simulatneously, and use whichever gets there first.
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
"how on earth the AI gonna know the right way of doing it is to trace the wall around the right rather than to the left…."

WHO told it to trace to the left??



Stevie

Don''t follow me, I''m lost.
StevieDon't follow me, I'm lost.

This topic is closed to new replies.

Advertisement