Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pathfinding #5

Open
dabbertorres opened this issue Jun 26, 2015 · 0 comments
Open

Pathfinding #5

dabbertorres opened this issue Jun 26, 2015 · 0 comments
Assignees

Comments

@dabbertorres
Copy link
Owner

Just took a look at some of the code in swift::Path.

Holy crap. I'm kinda surprised it works.

So, need to do a clean up. This looks scary

Could be done more efficiently too probably.

Now, if I want to try out my new multithreading skills on it... This would be perfect for parallel work.
Current idea:
Create PathMaker class (name TBD).
It contains a std::queue
and a thread pool. Let's say a max size of 4 (3? 2?).
So we have max 4 threads calculating paths at any given time.
We hit a branch, if we have an empty thread, great, we create it with our current data, tell it where to go, and let it run. If we don't have an empty thread, then we push it to the queue.
Once a thread finishes, we check if we have any paths in our queue. If so, we give the thread that data, pop the path off the queue, and let the thread run.

Once the queue is empty, we're done.
Also, instead of storing all possible paths like before, we can simply hold one - the current shortest one. If a path ever gets longer than the shortest, we terminate calculating it. If we find a shorter one, we throw away the old shortest, and make set the variable to the new one.

Less memory usage, less calculation, less iteration, less time. What could go wrong? (Don't answer that.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant