![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Newbie
Join Date: Jul 2005
Posts: 7
Rep Power: 0
![]() |
that right there is a good thought... I'll see if I can work with that. keep the ideas coming if anyone else thinks of something different though
![]() |
|
|
|
|
|
#12 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
It's called Dijkstra's shortest path algorithm - Google it if you want more information.
|
|
|
|
|
|
#13 |
|
Newbie
Join Date: Jul 2005
Posts: 7
Rep Power: 0
![]() |
It's working, but it is extremely inefficient.
![]() The problem is that I have to call the GetPath function which contains this algorithm every pass through the main loop (many times per second) in order to adapt the path to moving obstacles, which slows my computer down to a crawl until I get very close to the target and the number of calculations gets smaller. Not sure if there are other algorithms out there, but you really gave me a wide open area in which to search for my answer. Thanks so much! |
|
|
|
|
|
#14 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
I presume your target point is fixed? If so, calculate just one time. Each point in the grid then has its value, which doesn't change. Whether or not it's occupied is subject to movement during the game. That's a separate datum. Place your pieces, take into consideration whether or not a point is safe to occupy, but use your one-time data for the distance calculations. Actually, you could accomodate a moving target with relative measurements.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|