ref: 4d8547ddd37c51e447c2aa947b82157360be36ab
dir: /README.md/
<!-- moonfish is licensed under the AGPL (v3 or later) --> <!-- copyright 2023, 2024 zamfofex --> moonfish === [](https://builds.sr.ht/~zamfofex/moonfish/commits/main) [](https://lichess.org/@/munfish/perf/classical) [](https://lichess.org/@/munfish/perf/rapid) [](https://lichess.org/@/munfish/perf/blitz) **moonfish** is a simple chess bot written in C89. You may [play moonfish on Lichess]! You don’t need a Lichess account, just make sure to choose “real time” and select a fast enough time control. [play moonfish on Lichess]: <https://lichess.org/?user=munfish#friend> table of contents --- - [features](#features) and [limitations](#limitations) - [download](#download) - compiling from source - [compiling on UNIX](#compiling-from-source) (and UNIX clones) - [compiling on Plan 9](#compiling-on-9front) (specifically 9front) - [compiling on Windows](#compiling-on-windows) - [compiling on other systems](#porting-moonfish) - using moonfish’s tools - [using “analyse”](#using-analyse) - [using “chat”](#using-chat) (for integrating UCI bots with IRC) - [using “lichess”](#using-lichess) (for integrating UCI bots with Lichess) - [helping improve moonfish!](#contributing-to-moonfish) - [license](#license) features --- - simple evaluation based on PSTs - MCTS (Monte Carlo tree search) - cute custom UCI TUIs - custom Lichess integration - custom IRC integration limitations --- These are things that might be resolved eventually. - the TUIs do not let you underpromote - no support for `go depth`, `go infinite`, `go mate`, or `go nodes` - no FEN validation (may lead to potential exploits) download --- Pre‐compiled executables for Linux of moonfish (and some of its tools) may be found at <https://moonfish.neocities.org> (Windows binaries are also provided.) contributing to moonfish --- Contributions to moonfish are always welcome! Whether you just have thoughts to share, or you want to improve its source code, any kind of help is vastly appreciated! Contributions (complaints, ideas, thoughts, patches, etc.) may be submitted via email to <zamfofex@twdb.moe> or shared in its IRC channel ([#moonfish] on [Libera.Chat]). - Note: The IRC channel is also bridged to Discord. (Please ask on IRC for a Discord invite.) - Note: There is also a [#moonfish-miscellany] channel for general off‐topic conversations. [Libera.Chat]: <https://libera.chat> [#moonfish]: <https://web.libera.chat/#moonfish> [#moonfish-miscellany]: <https://web.libera.chat/#moonfish-miscellany> compiling from source --- Compiling on UNIX (and clones) should be easy. Make sure you have GNU Make and a C compiler like GCC, then run the following command. ~~~ make moonfish ~~~ Conversely, you may also invoke your compiler by hand. (Feel free to replace `cc` with your compiler of choice.) ~~~ cc -ansi -O3 -D_POSIX_C_SOURCE=199309L -o moonfish chess.c search.c main.c -lm ~~~ using “analyse” --- ~~~ make analyse ~~~ “analyse” is a TUIs that allows you to analyse chess games with UCI bots. After compiling and running it, you may use the mouse to click and move pieces around. (So, they require mouse support from your terminal.) To analyse a game with a UCI bot, use `./analyse` followed optionally by the UCI options you want to specify, and then the command of whichever bot you want to use for analysis. (Though note that moonfish currently does not have analysis capabilities.) ~~~ # (analyse a game using Stockfish) ./analyse stockfish # (analyse a game using Stockfish, showing win/draw/loss evaluation) ./analyse UCI_ShowWDL=true stockfish # (analyse a game using Leela) ./analyse lc0 # (analyse a game using Leela, showing win/draw/loss evaluation) ./analyse lc0 --show-wdl ~~~ using “chat” --- ~~~ make chat ~~~ moonfish’s IRC integration, called “chat” may be used to play with a UCI bot through IRC. The bot will connect to a given network through TLS and then start responding to move names such as “e4” written on given channels. ~~~ # have moonfish play on a given channel ./chat -N irc.example.net -C '#my-channel' ./moonfish # have Stockfish play on the given channels with the given nickname "chess-bot" ./chat -N irc.example.net -C '#my-channel,#other-channel' -M chess-bot stockfish ~~~ It is only possible to connect to networks using TLS. The default nickname is “moonfish”, and it will connect by default to #moonfish on [Libera.Chat]. using “lichess” --- ~~~ make lichess ~~~ In order to integrate a UCI bot with [Lichess], it is possible to use “lichess”. Simply write `./lichess` followed by your bot’s command. The Lichess bot token may be specified with the `lichess_token` environment variable. [Lichess]: <https://lichess.org> ~~~ # (use Stockfish as a Lichess bot) lichess_token=XXX ./lichess stockfish # (use moonfish as a Lichess bot) lichess_token=XXX ./lichess ./moonfish ~~~ compiling on 9front --- After installing [NPE], each file may be compiled and linked as expected. (Note: A `mkfile` isn’t provided.) [NPE]: <https://git.sr.ht/~ft/npe> ~~~ # (example for x86-64) 6c -I/sys/include/npe chess.c search.c main.c 6l -o moonfish chess.6 search.6 main.6 moonfish ~~~ compiling on Windows --- Clone the repository, then open `moonfish.vcxproj` with Visual Studio. Only the UCI bot will be compiled, not its tools. (You may use a GUI like [cutechess] to try it.) Note that [MinGW] compilation is also supported. [cutechess]: <https://github.com/cutechess/cutechess> [MinGW]: <https://mingw-w64.org> porting moonfish --- The only piece of functionality the moonfish depends on that is not specified entirely in C89 is `clock_gettime`. Porting moonfish to a different platform should be a matter of simply providing a “mostly C89‐compliant” environment alongside `clock_gettime`. Of course, moonfish doesn’t make use of *all* C89 features, so it is not necessary to have features that it doesn’t use. [Compiling on 9front](#compiling-on-9front), for example, works through NPE, which provides something close enough to C89 for moonfish to work. license --- [AGPL] ([v3 or later]) © zamfofex 2023, 2024 [AGPL]: <https://gnu.org/licenses/agpl-3.0> [v3 or later]: <https://gnu.org/licenses/gpl-faq.html#VersionThreeOrLater>