1 Attachment(s)
Maze Solver - A-Star Path Finding
Hello All,
I've been pretty quiet lately because I've been busy learning thinBasic and how to develop a module. I now have something to show, as my first attempt. I will welcome your criticism of it, as I will learn from what you have to say. Perhaps others will learn from your comments as well.
This is a very simple application. You draw a maze on the screen, pick starting and ending points, and let the computer try to find a path through the maze. There are some sample maze files included to get you started.
The path-finding is accomplished using the A* (A-Star) algorithm, which is provided in a module for speed reasons. The module was coded in "C" using the DevC++ IDE.
To install, uncompress the zip file into your thinBasic UserScripts folder, and copy the thinBasic_ASTAR.dll file to your LIB folder. The SDK folder has the source files the module was compiled from.
I'm not a "C" programmer, so please let me know if I did something wrong in my module.
Known Problems:
I developed this application at home on a Windows 2000 Pro OS, I just ran it at work on XP, and it seems to act a little differently.
I'm having problems with the fonts in the Help About dialog box. Sometimes they render correctly, othertimes they do not.
I'm also not clear on how to handle the WM_PAINT message. I tend to get multiple repaints of the screen when I only want one.
The module is not very well developed. If there is sufficient interest, I will develop it further and make it more useful. I'm not a game developer, so I'm not sure what you guys would want.
Thanks for taking a look!
Randall
Updates:
- 2007.10.06 main window is now resizable and mazes will adapt to winwow client area
Re: Maze Solver - A-Star Path Finding
Hi Randall,
what a shock ! :o
This is absolutely incredible script and module!
Profi layout, fast execution, even helpfile !
I will check the repaint / font problems ... but this are just details comparing to work you did.
Terrific!,
Petr
Re: Maze Solver - A-Star Path Finding
Regarding fonts,
it seems to me like some resource leak or something.
It should be correct to do something like
[code=thinbasic]
DeleteObject(hFont2)
DeleteObject(hFont3)
[/code]
... when exiting about proc. Maybe something similar for painting, but I am not very good at raw SDK paint functions, so maybe somebody else will know better :)
I must play with your script again and again. Really nice !
Petr
2 Attachment(s)
Re: Maze Solver - A-Star Path Finding
Randall,
what a present :o
Nice idea, perfect module, professional script complete and well written in all parts. You have spent a lot of time on it, I'm pretty sure about that. I have no words because you have showed to me once again the many possibilities thinBasic and especially thinBasic modules can have.
Regarding refresh rate and some strange %WM_PAINT firing, I'm quite sure it is a problem in UI (User Interface) module. In today released thinBasic preview 1.4.0.1 I have changed some code on how internal UI Windows message pump handle %WM_PAINT message. It makes some positive difference for example with previous one version when window goes outside screen and return, covered area does not get repaint while with current online one it des. But I need some time to understand what I'm doing wrong with %WM_PAINT. So for the moment do not worry about that or at least not too much. I will use this script for testing.
Regarding fonts, I need some more time to study your script and see how things are done.
Thanks again for this present.
I'm sure it will focus the attention for some big time :D
Be prepared to implement thinBasic_ASTAR module ;)
Ciao
Eros
Re: Maze Solver - A-Star Path Finding
Randall,
as we are used to do for interesting complete projects like this one, I have created a dedicated forum named AStar and moved your posts into it.
You are also moderator in this forum. Being a moderator doesn't mean anything other than you have some more forum power over posts. So feel free to do what you prefer with your new creature here.
Ciao
Eros
Re: Maze Solver - A-Star Path Finding
Great man! I will still release my path module, the more the better. I will have a close look at yours. Again thank you very much!
Re: Maze Solver - A-Star Path Finding
Excellent looking program Randall, really interesting. :)
Re: Maze Solver - A-Star Path Finding
Randall, I am just amazeD :)
It is so quick and clever. I couldn't fool it yet, probably won't but I will keep trying. Very cool idea for a game and also of course what looks like a neat module to study!!
THanks so much!! Really really neat!!!
Re: Maze Solver - A-Star Path Finding
Thank you all so very much for your kind comments!
I was only able to create it because of all the sample code and forum posts you all have so graciously supplied. Anytime I wasn't sure how to code something, I could either find a sample program or code snippet in the forums that showed me the way. My thanks go out to all of you for unselfishly sharing your code and expertise. I am honored to add my code alongside the excellent code already posted on this forum site.
Thanks again,
Randall
Re: Maze Solver - A-Star Path Finding
Quote:
Originally Posted by Michael Hartlef
Great man! I will still release my path module, the more the better. I will have a close look at yours. Again thank you very much!
Thanks Michael,
If you would like to incorporate my code into your path module, please feel free to do so.
Randall