I've been evaluating the Lua Programming Language at work for some embedded project. I really like this scripting language, if for nothing else other than it is so small and lightweight, yet almost as expressive as Ruby.
Anyway, I've created a small 'learning lua' project on github and collected a bunch of useful resources for developers to get started. I also made an attempt to use the language in anger and wrote a simple genetic algorithm in lua. If there are any Lua pro's out there, I'd love to hear about tweaks and idioms I could use to improve the example. I've copied the code into a gist and embedded it below, enjoy:
The genetic algorithm uses tournament selection, one-point crossover, point mutations and a binary string representation. The algorithm is applied to the classical OneMax problem. Some exercises for the reader my include changing the bitstring representation to tables, and to change the organization of the algorithm to use objects in a strategy pattern (for the problem and the algorithm).
Thursday, December 3, 2009
A Genetic Algorithm in Lua
Subscribe to:
Post Comments (Atom)



2 comments:
I fixed a small bug where crossover occurred all the time rather than probabilistically based on the crossoverRate parameter. I've updated both the github project and gist versions.
Github really needs the ability to embed project files, not just gists. Also, the embed strategy does not work with RSS readers like google reader.
Nice post, not only is Lua very expressive but it has a lightning fast JIT now. Thanks to Mike Pall!
http://luajit.org/
Ryan
Post a Comment