Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 2nd, 2005, 11:55 PM   #11
CodeCaster
Newbie
 
Join Date: Jul 2005
Posts: 7
Rep Power: 0 CodeCaster is on a distinguished road
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
CodeCaster is offline   Reply With Quote
Old Jul 3rd, 2005, 6:54 AM   #12
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
It's called Dijkstra's shortest path algorithm - Google it if you want more information.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Jul 4th, 2005, 12:29 AM   #13
CodeCaster
Newbie
 
Join Date: Jul 2005
Posts: 7
Rep Power: 0 CodeCaster is on a distinguished road
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!
CodeCaster is offline   Reply With Quote
Old Jul 4th, 2005, 8:07 AM   #14
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:36 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC