Wednesday, August 8, 2007

A* Pathfinding Program - v1.0

So I finally made a release! I didn't totally fix the "Unknown protocol c" error, but it is something to do with DTD validation, something for fixing another day.

Anyway, if you are interested, you can grab the installer here. Please be aware that if you open one of the premade grids, you'll probably get some errors, but you can click through them and the grid will open. I know I shouldfix it, but sometimes you have to know when to just make a release and see if anybody ever uses the thing, if someone cares enough to email me that it bugs them then I will fix it ;-).

Friday, August 3, 2007

Package level JavaDoc

I have wondered for a while if there was an easy way to create package level JavaDoc without having to set up the appropriate HTML file. Well, I discovered a way, courtesy of Florent Guillaume:

Original post: http://lists.nuxeo.com/pipermail/ecm/2006-November/000268.html

The basic idea is that you create a java file in your package without a class definition. This file must be name 'package-info.java' and contain the correct package statement.

This is a real easy way, I tend to use the 'Generate JavaDoc' option in NetBeans IDE and it picks up the file. This is only usable from Java 5+.

Wednesday, August 1, 2007

A* Pathfinding Program

I have been making a small application in the past few weeks in practice for my Java exam and also to get a decent Java & OpenGL demo together. The result is a program called A* Pathfinder.

For the initiated, A* is a pathfinding algorithm found in many of todays games, such as Age of Empires or Command & Conquer. The algorithm searches for the best path from point A to point B, taking terrain into consideration. In my program, I have kept things simple in terms of the terrain:



Impassable terrain is shown in black. The user can change a node to be impassable by clicking on it ('node' is the term used in A* literature, but in this case it means a square). The user can also set a start point and an end point with a right-click pop-up menu.

I have also built in the ability to save and reload grids that have been created. I made this mainly for my benefit, so that during debugging I didn't need to create the grid each time!

When the user is ready to evaluate a path, they can click on the 'Calculate path' button and the result is shown below:



The path is highlighted in blue and evaluated nodes are shown in yellow.

I still have some bugs to solve, such as:

- Under Windows Vista, the help file doesn't open with out downloading WinHelp32.exe from the update site as Microsoft decided to ditch it from Vista. I am going to try and make a .chm file instead.

- Under Windows Vista, the menu screens display icons correctly until the user clicks on something. Then it just renders a tick. I have to say, there are a few 'issues' with using native look & feel in Java on Vista...

- An error is thrown when trying to open a grid file outside of the NetBeans IDE environment that I used to make the program. I get an "Unknown protocol c" exception and with a bit of Googling it seems I'm not the only one. Hopefully I can debug this.

Once I have worked these out, I will make a download available.