Simple chess engine implemented in Clojure
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src/tursas
test/tursas/test
.gitignore
README.org
project.clj

README.org

Tursas

Tursas is a chess engine implemented in Clojure. It tries to follow functional programming style throughout the code. This is my first project using either Lisp or functional programming style and this will reflect in the code too.

Currently Tursas is somewhat playable. I’ve used it with the XBoard program as UI but the engine can also be played from the console. To make the console interface more usable I’ve included some utility commands in Tursas. These commands can print the board in ASCII or list available moves to user. There are also some undocumented commands but these are little use to casual user and are used mostly for debugging the engine from the console. I’m planning to add full XBoard protocol support to Tursas eventually.

The engine itself uses alphabeta algorithm to search moves and uses 0x88 as board representation. The move generation is still problematic as it generates all the moves eagerly instead of using laziness. Laziness would help making few constructs easier in the code but I haven’t yet figured out a way to get to work in a good way.

ChangeLog:

I’ll try to update here the major points in each version of the chess engine. For detailed list check the commits.

Version 0.1

  • Subset of Chess Engine Communication Protocol implemented so engine can be played.
  • Working alphabeta algorithm
  • Game state representation with 0x88 board
  • Working evaluator which playes according to rules and can win weakest of players

Roadmap

These are some of my ideas what could be done in the Tursas project. I’m not planning to blindly follow these but I think it gives nice rough idea what to except and in what point.

Version 0.2

  • add unit tests to detect regressions and such
  • add more error detection to repl commands

Version 0.3

  • More functional version of alphabeta search
  • Repetition rule for draws and making AI avoid it

Version 0.4

  • Iterative deepening
  • Quiescence search

Version 0.5

  • NPS command
  • Transposition table?

Version 0.6

  • Analyse mode

Version 0.7

  • AI Pondering mode

Version 0.8

  • Time controls

Version 0.9

  • Core/Mem limits for engine

Version 1.0

  • Clean up and testing

Possibly added in later versions

  • UCI protocol interface
  • Bitboard state representation
  • Negascout replacement for alphabeta

Installation

The Tursas uses Leiningen to build the project. After setting it up you can build the project with command “lein uberjar”.

Running

After making the jar file you can run the engine with java -jar tursas-0.2-standalone.jar

Its recommeded to run the engine with some external program to get more visual appearance. I recommend using XBoard (WinBoard). With XBoard you can use tursas by starting xboard with command: “xboard -fcp ‘java -jar tursas-0.2-standalone.jar’”

Usage

The game tries to support the XBoard protocol with some custom extensions. Once the engine is started you should start by giving the “xboard” command. This command makes the engine use xboard protocol. For more information type “help” in the repl or see the XBoard protocol definition.

Here are the currently supported commands:

Available general commands:

help
display this help
load
load the last saved game from file
save
store the current game to file
bd
display the board on the screen
fd
display current game state in FEN
lm
print a list of all available moves
xboard
enable xboard mode
quit
quite the Tursas engine

Available XBoard commands:

protover N
change engine to use protocol version N
accepted
Accept last feature
reject
Reject last feature
variant VARIANT
change to use VARIANT rules. Only ‘normal’ supported
random
Tursas doesn’t support this so this does nothing
force
Disable engine AI
go
Enable engine AI
sd DEPTH
set search depth to DEPTH
usermove MOVE
make given MOVE if legal
ping N
Pings the engine for pong reply
result RESULT {COMMENTS}
give the game RESULT to engine.
setboard FEN
Set the game board to given FEN.
undo
tell engine to undo last move
remove
tell engine to undo last two moves
name X
tell engine its opponents name
rating
ask engine its rating, simply prints out 100.
computer
tell engine that its playing against cpu
option NAME[=VALUE]
tell engine to use new option

Known issues

The perft calculation seems to be incorrect.

The option command doesn’t work as intended

Signals aren’t handeled at all, ^C should exit nicely.

License

Copyright (c) 2010, Timo Myyrä

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.