In an effort to learn more about AI programming techniques, I'm trying to port M. Tim Jones' AI Application Programming examples from C to Ruby. I'm planning to port these (porting notes are here) in no particular order.

The errata for the book is posted on Tim's web site.

This project is hosted by RubyForge, forums and such-like are here.


Chapter 2 - Simulated Annealing

Updated 10/23/03: Done with translation of the n-Queens solver, code is here. Here's a solution to a 16 queen board (took about 15 hours (!!) to run):

. . . . . . Q . . . . . . . . .
. . . . . . . . Q . . . . . . .
. . Q . . . . . . . . . . . . .
. . . . . . . . . . . . . Q . .
. . . Q . . . . . . . . . . . .
. . . . . . . . . Q . . . . . .
. . . . . . . . . . . . . . . Q
. . . . Q . . . . . . . . . . .
Q . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . Q .
. . . . . . . . . . . . Q . . .
. . . . . . . Q . . . . . . . .
. Q . . . . . . . . . . . . . .
. . . . . . . . . . . Q . . . .
. . . . . Q . . . . . . . . . .
. . . . . . . . . . Q . . . . .

Chapter 3 - Adaptive Resonance Theory

Updated 4/24/04: Done with the translation of the "Customer Personalization" example; code is here. Not too tricky a translation; only about 450 lines of C code.

Here's some sample output:

For customer 0, the best recommendation is 2 (Snickers)
Owned by 2 out of 3 members of this cluster
Already owns: Kit-Kat Heath-Bar
For customer 1, the best recommendation is 4 (Pen)
Owned by 1 out of 2 members of this cluster
Already owns: Paper Pencil Binder
For customer 2, the best recommendation is 0 (Hammer)
Owned by 2 out of 3 members of this cluster
Already owns: Screwdriver Wrench Tape-Measure

Chapter 4 - Ant Algorithms

Updated 10/22/03: Traveling Salesman via ant algorithm is done, code is here.


Chapter 5 - Neural Networks and the Backpropagation Algorithm

Updated 03/11/04: Game neurocontroller translation is done, code is here. This was a fairly easy one to translate, and some sizeable duplicate chunks were easy to refactor away.


Chapter 6 - Genetic Algorithms

Updated 04/23/04: Done, code is here.


Chapter 7 - Artificial Life

Updated 11/14/03: About 30% done, code is here. This is going to take a while; there are about 1050 lines of code to translate, while other chapters had much less - simulated annealing, for example, was only 280 lines of code. On the other hand, a lot of the code is just disappearing and being replaced with calls to Array.collect and the like. Yay!


Chapter 8 - Expert Systems

Updated 7/13/04: Working on rule parser, can parse antecedents and consequents now.


Chapter 9 - Fuzzy Logic

Updated 10/16/03: Battery charger and predator prey examples complete, code is here.

Battery charger example: below is a graph (thanks gnuplot!) showing the relationships between the battery's voltage and temperature - you can see when the fast charger kicks in and when it falls back to trickle charge mode.

Predator/prey example: below is an image of the predator seeing the prey and turning towards it.


Chapter 10 - The Bigram Model

10/30/03: Done, code is here. Here's a sample run (I used some quotes from C. S. Lewis as the corpus):

 It is always something couldn't guessed That's one reasons I suppose must conclude.
 It's Badness is idle talk any final victory over materialism No Christian indeed no good game without rules In.
 Safety happiness can only cobblers to say whether teeth were being well governed Everything except some natural inferior.
 When humans should have need of the reasons It's a real Right and the percentage cannot increased.
 Perfect humility dispenses with the first sketch As long as judging value result Who can be found to the.

TODO: Refactor some of those arrays into classes - especially bigram_array.


Porting notes