SUNFISH(6)

NAME
Sunfish - A 111 line Chess Engine in Python

SYNOPSIS
sunfish

DESCRIPTION
Sunfish is a simple, but strong chess engine, written in Python, mostly for teaching purposes. Without tables and its simple interface, it takes up just 111 lines of code! The great clarity of the Sunfish code provides a great platform for experimenting, be it with evaluation functions, chess heuristics or search. Fork it today and see what you can do!

GAMEPLAY
Sunfish presents chess board as a simple grid
  r n b q k b n r
  p p p p p p p p
  . . . . . . . .
  . . . . . . . .
  . . . . . . . .
  . . . . . . . .
  P P P P P P P P
  R N B Q K B N R
 Your move: You make your move by typing source and destination coordinates. Coordinates are represented by letters A through H on X-axis and numbers 1 through 8 on Y-axis, where bottom-left corner represents coordinate A1
 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 Player always begins. Player controls capital letters on the bottom. To move Pawn on E2 to E4, player would type e2e4 on the "Your move:" prompt and press return key.

FEATURES

•   Build around the simple, but deadly efficient MTD-bi search algorithm.

•   Filled with classic as well as modern 'chess engine tricks' for simpler and faster code.

•   Easily adaptive evaluation function through Piece Square Tables.

•   Uses standard Python collections and data structures for clarity and efficiency.

LIMITATIONS
Sunfish supports castling, en passant, and promotion. It doesn't however do minor promotion or draws of any kind. All input must be done in simple 'two coordinate' notation, as shown in the screenshot. On the technical side there are a lot of features that could be interesting to add to Sunfish. For performance, the most important might be a piecelist to save the enumeration of all board squares at every move generation. Other performance optimizations include a reduced use of hashtables and a mutable board representation. Perhaps based on bitboards. The evaluation in Sunfish is not very sophisticated. E.g. we don't distinguish between midgame and endgame. The search is limited in that no quince search is performed and so we can have horizon effects. Null move pruning is not done, and it is debatable wether it would be safe given our choice of MTD search. Finally Sunfish might benefit from a more advanced move ordering, including such things as killer move and SEE.

COPYRIGHT
Copyright (C) 2014 Thomas Ahle This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

AUTHOR
Thomas Ahle