Sunday, November 7, 2010

Ha! A new approach

figure 1
I started working on my path finding algorithms again. I have yet to do any coding, however I've come to an epiphany of how to solve my problem that I was running into before, this problem is shown in figure 1. In my previous recursive algorithm, I treated each obstacle line as that, a line. Instead of considering the entire object as one obstacle.

Of course this means reworking an obstacle class to be more like a system of equations instead of just using an array of lines to increment through the obstacles to bypass. By comparing obstacle endpoints and startpoints with each other. The ones that are shared will then be considered one object. Thus, a solution path around that object involves skirting the edges of the lines of the obstacle themselves, and then computing the shortest path. I don't know why I didn't think of doing something along these lines before in all honesty.

I'll set up the class to have a flag to be checked if the obstacle is more than a simple line or not. If it's not, then a simple startpoint to obstacle end or start point and then to destination will suffice. If it's flagged, than the line of the other obstacle parts will be copied and shifted by X closer to the start position, and a little bit longer than the obstacle line so it moves past it.

I'm so excited to code this and fix it!

No comments:

Post a Comment