Some friends of a friend of mine created a great game called Clockwords. What can I say? Words + deck building == I’m hooked.
Oh yeah, of course I’m going to do some programmatic analysis.
class Clockword < String
VALUES = Hash.new(0)
VALUES.merge!({"a" => 1, "b" => 3, "c" => 3, "d" => 2,
"e" => 1, "f" => 4, "g" => 2, "h" => 3,
"i" => 1, "j" => 5, "k" => 4, "l" => 2,
"m" => 3, "n" => 2, "o" => 2, "p" => 3,
"q" => 5, "r" => 1, "s" => 1, "t" => 2,
"u" => 3, "v" => 4, "w" => 4, "x" => 5,
"y" => 4, "z" => 5})
def top_letters
# there are no duplicate letters in the chamber
top = self.downcase.scan(/./).uniq
# 8 chambers, so only count the top 8 letters
top.sort{|x, y| y <=> x}[0..7]
end
def score
return VALUES[self.downcase] if self.length == 1
return self.top_letters.inject(0){|sum, curr| sum + curr.score}
end
def <=>(other)
return -1 if self.score < other.score
return 1 if self.score > other.score
# if the raw score is the same, let's further
# differentiate by the length (more points)
return -1 if self.length < other.length
return 1 if self.length > other.length
return 0 if self.length == other.length
end
end
Posted on Sunday October 25th