When I did the first version - before the improvements above - I showed it to my professor. He wanted me to add the spreading of the algorithm in every step. In this way, we are able to see how the algorithm works. To do this, I had to sleep the algorithm for awhile in every step. And I added sleep into the function which finds the path. But it didn't work as I expected. Because GUI slept, too. After a little search, I found that I had to make thread programming to fix that problem. My program was executing in a single thread, when I sleep a function, GUI was sleeping, too. The thing that I have to do was dividing the program into two pieces, first is the piece that shows the GUI elements and the second is the piece that does calculations for algorithm.
I know a little bit of thread programming from my Operating Systems course. We also did a lab to learn better. We were using C, you can find the code for that here. In Java, thread programming was easier than I thought. After doing that, program was working correctly.
Now, I have to study to understand algorithm better. I am little bit confused because of heuristic part of algorithm. The heuristic is directly affecting the algorithm, choosing the right heuristic is the main issue of A*.
Here is some images from the project;
When I finish this project, I'm planning to open the source code. I will probably share the codes on Github.
I know a little bit of thread programming from my Operating Systems course. We also did a lab to learn better. We were using C, you can find the code for that here. In Java, thread programming was easier than I thought. After doing that, program was working correctly.
Now, I have to study to understand algorithm better. I am little bit confused because of heuristic part of algorithm. The heuristic is directly affecting the algorithm, choosing the right heuristic is the main issue of A*.
Here is some images from the project;
Initial position of starting and destination nodes. Later, users will be able to change their positions.
Spreading of algorithm. Light gray nodes are in closedList. Dark blue nodes are in openList. Calculating g value of neighbors is like this:
currentNode.g + 10 for horizontal and vertical neighbors
currentNode.g + 14 for diagonal neighbors
And Manhattan heuristic is used.
And Manhattan heuristic is used.
When I finish this project, I'm planning to open the source code. I will probably share the codes on Github.
No comments:
Post a Comment