Ruby Stockfish

A ruby client for the Stockfish chess engine

Installation

$ gem install stockfish

Or add it to your application's Gemfile and install via bundler

gem 'stockfish'

Analyzing positions

Load a position in FEN notation that you want to analyze

fen = "3qr3/1b1rb2Q/p2pk1p1/1p1np3/4P3/P2BB3/1PP3PP/4R2K w - - 2 24"

Set the search depth (in number of half-moves) you want to use

Stockfish.analyze fen, { :depth => 12 }

And request multiple variations if you'd like

Stockfish.analyze fen, { :depth => 6, :multipv => 3 }

Requirements

Stockfish 6+ must be installed and available in your $PATH

$ which stockfish

If Stockfish is not in your $PATH, you can pass the path to the Stockfish binary directly

engine = Stockfish::Engine.new("/usr/local/bin/stockfish")
engine.multipv(3)
engine.analyze fen, { :depth => 6 }