Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

Clever Algorithms: A Free Book of Nature-Inspired Ruby Recipes

By Peter Cooper / January 26, 2011

cleveralgorithms.pngClever Algorithms is a newly released book by Jason Brownlee PhD that describes 45 algorithms from the Artificial Intelligence (AI) field with Ruby-based examples. It's well produced and, notably, free in its PDF and online formats. A print copy is available at a small cost.

The book kicks off with a chapter of background regarding AI and its problem domains and moves on to an array of algorithms in the probabilistic, neural networking, stochastic, swarm, and evolutionary spaces.

Ruby purists will note that even though the demonstrations are in Ruby, they're not very Ruby like. Classes are rarely defined and using methods defined in the main context as functions is the order of the day. Nonetheless, the book remains well written and interesting and the Ruby code - as generic as it is - will nonetheless help Rubyists get the idea behind many of the processes demonstrated.

This book provides a handbook of algorithmic recipes from the fields of Metaheuristics, Biologically Inspired Computation and Computational Intelligence that have been described in a complete, consistent, and centralized manner. These standardized descriptions were carefully designed to be accessible, usable, and understandable.

Most of the algorithms described in this book were originally inspired by biological and natural systems, such as the adaptive capabilities of genetic evolution and the acquired immune system, and the foraging behaviors of birds, bees, ants and bacteria. An encyclopedic algorithm reference, this book is intended for research scientists, engineers, students, and interested amateurs.

Jason Brownlee

Check out Jason's book at and the content and code are in this GitHub repository.

[ad] Jaconda is a chat system designed for teams working on projects. It works from the browser, your IM app, or your phone, and lets you chat, share files, and keep up with tickets and project activity you can have sent automatically to your rooms.


  1. Edward J. Stembler says:

    I’m perusing the free PDF now… I feel as though the demonstrations are enough Ruby-like; I mean you really wouldn’t be using classes in an algorithm book anyway. He makes use of lambda-style block-notations, reverse conditions etc...

  2. marcus says:


    This book looks interesting, but a bit advanced perhaps for me at this point. I'm enjoying *your* book on Ruby, and was wondering if you had recommendations for a kind of "beginning algorithms" book that might use Ruby in its examples.

    Thanks for all you do, both here and on twitter, and wherever else.


Other Posts to Enjoy

Twitter Mentions