Skip to content

linrock/ruby-stockfish

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 }

Look at multiple variations by setting a multipv option

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

Communicating with the engine

You can also send UCI commands to Stockfish directly

engine = Stockfish::Engine.new
engine.execute "position fen q3r3/3r4/p2p2p1/1p2p1b1/8/P6k/1PP1Q2P/4BRK1 b - - 8 36"
engine.execute "setoption name MultiPV value 3"
engine.execute "go depth 10"

Requirements

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

$ which stockfish

Or you can load a Stockfish binary directly

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

About

A ruby client for the Stockfish chess engine

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages