Shatranj

Shatranj is an bitboard-based, Open-Source, interactive chess programming module.
Download

Shatranj Ranking & Summary

Advertisement

  • Rating:
  • License:
  • GPL
  • Price:
  • FREE
  • Publisher Name:
  • Sam Tannous
  • Publisher web site:
  • http://www.employees.org/~stannous/shatranj/

Shatranj Tags


Shatranj Description

Shatranj is an bitboard-based, Open-Source, interactive chess programming module. Shatranj is an bitboard-based, Open-Source, interactive chess programming module which allows manipulation of chess positions and experimentation with search algorithms and evaluation techniques. Shatranj's goal is to write a toolkit to aid in implementing Shannon Type B chess programs.As such, execution speed becomes less important then code clarity and expressive power of the implementation language. Having been written in an interpreted language, this module allows the chess programmer to manipulate bitboards in a natural, interactive manner much like signal processing toolkits allow communication engineers to manipulate vectors of sounds samples in MATLAB.The module currenly implements a simple recursive minimax search with alphabeta pruning, iterative deepening, uses short algebraic notation, handles repetition check, and the 50 move rule. Features lacking are quiescent checks, transition tables, negascout and MTD searching.The chess programming toolkit is available in the form of a Python module called shatranj.py. You will also likely need the opening book as well as some of the pre-built hash tables that are used throughout the module (these will be recalculated if the module cannot find the data file).Place all three file in the same directory and simply run python on the python module ("python shatranj.py"). As far as requirements, all that is needed is a recent version of the interpreted, high level language called Python (anything after version 2.3 should work fine). If you would like a little bit of a speed boost, shatranj looks for the module Psyco and will use it if it is installed.Until more documentation becomes available, here is a short sample session: stannous% python>>> from shatranj import *...reading startup data...total time to read data 0.0774528980255...found opening book shatranj-book.bin with 37848 positions>>> position = Position("r1bqk2r/pppp1ppp/2n5/5N2/2B1n3/8/PPP1QPPP/R1B1K2R")>>> all_pieces = position.piece_bb | position.piece_bb>>> other_pieces = position.piece_bb>>> from_square = c4>>> wtm = 1>>> mask = position.pinned(from_square,wtm)>>> ne_pieces = diag_mask_ne & all_pieces>>> nw_pieces = diag_mask_nw & all_pieces>>> moves = ((diag_attacks_ne & other_pieces) | ... (diag_attacks_ne & ~all_pieces) | ... (diag_attacks_nw & other_pieces) | ... (diag_attacks_nw & ~all_pieces)) & mask>>> >>> moves1275777090846720L>>> >>> tobase(moves,2)'100100010000101000000000000010100000000000000000000'>>> display(moves) +---+---+---+---+---+---+---+---+ 8 | | . | | . | | . | | . | +---+---+---+---+---+---+---+---+ 7 | . | | . | | . | 1 | . | | +---+---+---+---+---+---+---+---+ 6 | 1 | . | | . | 1 | . | | . | +---+---+---+---+---+---+---+---+ 5 | . | 1 | . | 1 | . | | . | | +---+---+---+---+---+---+---+---+ 4 | | . | | . | | . | | . | +---+---+---+---+---+---+---+---+ 3 | . | 1 | . | 1 | . | | . | | +---+---+---+---+---+---+---+---+ 2 | | . | | . | | . | | . | +---+---+---+---+---+---+---+---+ 1 | . | | . | | . | | . | | +---+---+---+---+---+---+---+---+ a b c d e f g h >>> position.show_moves(1)>>> >>> # now play a game!>>> play()Shatranj version 1.10 g: switch sides m: show legal moves n: new game l: list game record d: display board b: show book moves sd: change search depth (2-16) default=5 q: quitShatranj: d +---+---+---+---+---+---+---+---+ 8 | r | n | b | q | k | b | n | r | +---+---+---+---+---+---+---+---+ 7 | p | p | p | p | p | p | p | p | +---+---+---+---+---+---+---+---+ 6 | | . | | . | | . | | . | +---+---+---+---+---+---+---+---+ 5 | . | | . | | . | | . | | +---+---+---+---+---+---+---+---+ 4 | | . | | . | | . | | . | +---+---+---+---+---+---+---+---+ 3 | . | | . | | . | | . | | +---+---+---+---+---+---+---+---+ 2 | P | P | P | P | P | P | P | P | +---+---+---+---+---+---+---+---+ 1 | R | N | B | Q | K | B | N | R | +---+---+---+---+---+---+---+---+ a b c d e f g h


Shatranj Related Software