Not exactly sure why. I decided to make the home page of inarow.net something else (which isn’t done yet.) So, I started shopping around for blogging options. I see too much of wordpress on the clock, so I wrote that off. I ended up on tumblr because I liked their API, flexibility and capabilities.
Speaking of API, it was about an hour to import all my posts from bloxsom.
I wrote this a while ago, while reading Behind Deep Blue (which is a great book). It’s a chess engine written in ruby. The actual engine is implemented as a move generator, positional evaluator and a board class which handles the state as a set of bitboards and undoable move events.
Included are a command-line client and an xboard interface. The command-line interface accepts coordinate notation and a few commands:
e2e4 – coordinate notation, move a pawn
!play – tell the engine to play as the current color
!undo – roll back a move
!dump filename – store the current board state
!load filename – load a stored board
!reset – start a new game
!quit – end the game
You can cut the verbosity of the generator engine by editing line 121 of evaluator.rb:
@@ -118,7 +118,7 @@ module RubyKnight
def time_it label
start = Time.now
res = yield
- puts "TIMING( '#{label}=>#{res}'): #{Time.now - start} seconds"
+ #puts "TIMING( '#{label}=>#{res}'): #{Time.now - start} seconds"
res
end
end
The evaluator is very primitive, and only thinks one move ahead. Some sort of breadth-first time thinking mode was next on the to-do list.
You can grab the code via git:
git clone http://darkwing.inarow.net/git/rubyknight.git
So, after giving Allan some feedback about the latest less project, Get More Honey, we chatted a bit and it came out that I’m a PHP guy, with a bit of a leaning towards CakePHP. But, I’ll fully admit that I love the ruby language, have played with it quite a bit, but simply never had an opportunity to write a rails app. People pay me to write PHP code. ;)
But, it did inspire me to fire up vim and write something in ruby. (Some day I’ll dust off RubyKnight, the chess engine I wrote in ruby after reading Behind Deep Blue) Here it is:
#!/usr/bin/ruby
# Written by Chris Moyer (chris@inarow.net // http://inarow.net/)
# Do with it whatever you want. That's public domain, right?
require ‘readline’
require ‘rubygems’
require ‘twitter’
if !user or !pass then
puts ‘usage: tweet username password’
exit
end
$0 = “tweet #{user} xxxxxxxx”
twitter = Twitter::Base.new(user, pass)
while line = Readline::readline(’(tweet)> ’) do
Readline::HISTORY.push(line)
if line.length > 140 then
puts “#{line.length – 140} characters too long, try again.”
else
begin
twitter.post(line)
puts “Tweeted!”
rescue
puts “Failed to tweet! (#{$!})”
end
end
end
puts “\nBye!”
It solves my problem of reading twitter via gtalk, and not wanting to open twitter.com to post… while hating when I underestimate the length of my message and being trunctaed. I can just let this run in window of my screen session, and tweet away.
So, I’d love to hear from the rubyists out there: