Categories
A* in Clojure: Part Two - January 24, 2010 by pardsbane

Today, I decided to flush out and clean up my A* implementation in Clojure. I cleaned up the namespaces, removed some cruft, got the Java integration working (which required by-passing RT.loadResourceScript() since it seems to be broken), and moving my graph structure definition out of code and into a separate XML file (which is read and parsed directly in Clojure).

I’m still not sold on functional programming, these minor changes took me more hours than I care to admit and gave me a crazy headache, but that could just be because I’m unfamiliar with the language.

I also uploaded the code to GitHub, because I figured where’s the fun in learning a new algorithm in a new language without tossing in the risk of losing all your code to an silly mistake with an unfamiliar version control system?

Luckily no data was lost, and if you have any interest in Clojure, Clojure-Java integration, or A-Star search, check it out here:

http://github.com/jbcpollak/AStar-Clojure

My next steps are going to be more rigorous unit testing and perhaps some benchmarking. I’d like to see how this implementation does against a large graph.

A-Star Search in Clojure - October 16, 2009 by pardsbane

I wanted to refresh my knowledge of functional programming, A-Star search, and I figured learning Clojure at the same time couldn’t hurt. I figured I’d do all three at once, and throw in a health dose of Maven and Java at the same time.

This project was intended to:

  1. Refresh myself on how to do functional programming
  2. Refresh my knowledge of A* search
  3. Help me learn Clojure
  4. Demonstrate Java interoperating with Clojure
  5. Demonstrate Maven as a viable build system for Clojure


Download The Demo Here

Once downloaded, unzip the zip file and open a terminal.

You now have three options:

Review the Source Code

The meat of the code is all in Clojure, here:

src/main/resources/com/example/clap/astar.clj

There is a bit of boot-strap Java code in the following file, but I can’t say its all that interesting:

src/main/java/com/example/clap/App.java

Running from Source

If you are on a Mac, or you already have Maven and Java installed, just run the following:

cd astar && mvn test

Maven will download all the needed packages and then compiled and execute the demo.

Running from Binary

If you are on Linux, or have cygwin installed on Windows, you can run the following:

cd astar/bin/ && ./run-astar

Post Archive