Code for my MSc dissertation (converted to Ruby!)