In A Row

Get your ducks there!

home :: development :: ruby :: rubyknight

:: RubyKnight - Chess Engine in Ruby

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

Show Related Articles

Comments

Add a Comment:
 
Name:
URL/Email: [http://... or mailto:you@wherever] (optional)
Comment:
Please verify that you are human, or a good AI/OCR combo:
  Add to Technorati Favorites   Copyright 2008, Chris Moyer