Monday, August 06, 2007

Javascript Genetic Algorithm

The other evening I was looking to play around with QScript. I have done a handful of JavaScript and know that there are a number of very interesting features that the language possesses. I have also been looking to hack on a Genetic Algorithm project. Putting the two together I made a Genetic Algorithm example written in JavaScript. It was quite a lot of fun to make and is quite a small amount of code in the end. I included an example that tries to find the shortest path between a set of points (the travelling salesman problem). You are free to type in any problem you want and it will attempt to solve it with the genetic algorithm. After it runs it will generate a graph showing the progress as its gets a better and better solution (using the canvas tag, sorry it doesn't work in Konq 3.x). And it will paint the final solution that it finds to the problem. Although it ended up being a little website rather then a Qt app it was fun learning more JavaScript and more about GA's. If you are interested in learning about GA's I have a number of links including some to Google books at the bottom.

No comments:

Popular Posts