Skip to content

andrewharabor/simPLY_chess

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 

Repository files navigation

simPLY_chess

Introduction

A simple chess engine written in Python. This project was heavily inspired by Sunfish, including some of its ports to faster languages as well as other engines based around Sunfish. The Chess Programming Wiki was of great help since it explains nearly every chess programming concept in detail.

How to play against simPLY_chess

I initially planned to use the official API to put the engine on Lichess but until then, just import the engine in a UCI GUI if you want to play against it.

simPLY_chess1.0-vs-simPLY_chess3.3.webm

Features

  • NegaMax search with alpha-beta pruning and quiescence search within an iterative deepening loop

  • Piece square tables, king tropism, mop-up evaluation, and tapered evaluation

  • Transposition table with Zobrist hashing along with built-in PolyGlot opening book reader

  • Communicates through standard UCI protocol

    • Standard commands:
      • uci: Tell engine to use the uci (universal chess interface), this will be sent once as a first command after program boot to tell the engine to switch to uci mode.
      • isready: This is used to synchronize the engine with the GUI. When the GUI has sent a command or multiple commands that can take some time to complete, this command can be used to wait for the engine to be ready again or to ping the engine to find out if it is still alive.
      • ucinewgame: This is sent to the engine when the next search (started with position and go) will be from a different game. This can be a new game the engine should play or a new game it should analyze but also the next position from a testsuite with positions only.
      • position [fen <fenstring> | startpos] moves <move1> .... <movei>: Set up the position described in fenstring on the internal board and play the moves on the internal chess board. If the game was played from the start position, the string startpos should be sent
      • go: Start calculating on the current position set up with the position command. There are a number of commands that can follow this command, all will be sent in the same string. If just go is sent, go depth 5 movetime 10000 is run by default.
        • wtime <x>: White has x milliseconds left on the clock.
        • btime <x>: Black has x milliseconds left on the clock.
        • winc <x>: White increment per move in milliseconds if x > 0.
        • binc <x>: Black increment per move in milliseconds if x > 0.
        • depth <x>: Search x plies only.
        • movetime <x>: Search exactly x milliseconds.
      • quit: Quit the program as soon as possible.
    • Custom commands:
      • board: Display the current position in a textual representation.
        • unicode: Optional argument to use unicode characters for the pieces instead of ASCII.
      • eval: Display the static evaluation of the current position.
      • flip: Flips the side to move.

Limitations

  • Relies on a GUI for features like time control and stalemate/checkmate detection

  • Written in Python meaning that it can't search past a depth of 4-ply in a reasonable amount of time for most positions, especially in the middlegame

  • Does not take 3-fold repetition or the fifty-move-rule into account meaning that those rules can be exploited when the engine has a winning position

  • Lacks various other search techniques that could improve its speed and strength

My Thoughts

I decided to program this engine because I enjoy playing chess and I figured it would be a challenging project. Despite all of its limitations, the engine plays better than I had initially thought it would. There are many ways I could improve the playing strength and speed and while I will likely come back and implement some of them, my original goal with this project has been fulfilled. Overall, I'm happy with the result and I really enjoyed the process.

About

A simple chess engine written in Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages