moonfish's logo

a simple chess bot

about moonfish

moonfish is a simple chess bot written in C89 (using just a few POSIX and C11 APIs).

contributing to moonfish

Contributions to moonfish are always welcome! Whether you have thoughts or ideas to share or complaints to make, any kind of help is very appreciated!

Please feel free to reach out!

compiling from source

You’ll need a C compiler (like GCC or Clang) and also POSIX Make (like GNU Make or BSD Make or PDP Make).

make moonfish

You may instead run your compiler manually if you prefer.

# (replace 'cc' with your compiler of choice)
cc -O3 -o moonfish chess.c search.c main.c -lm -pthread -latomic

compilation configuration

Note: Consult the makefile for more configuration options.

notes for MacOS

MacOS usually lacks -latomic and C11 <threads.h>, so you may need to compile with -Dmoonfish_pthreads and LIBATOMIC=.

# (configuring the compilation for MacOS)
make CPPFLAGS=-Dmoonfish_pthreads LIBATOMIC= moonfish

using moonfish’s tools

moonfish also has a few tools to use UCI bots in various ways.

To compile them, simply run make followed by the name of the tool you want to compile.

make analyse
make chat
make lichess

Each of them has fairly good --help documentation, so you may use that to learn more about them!

./analyse --help
./chat --help
./lichess --help

Note that some of them have external dependencies!

compiling on 9front

You’ll need NPE. After that, you should be able to just compile moonfish and some of its tools with mk. (They have no further dependencies on 9front.)

compiling on Windows

Clone the repository, then open moonfish.vcxproj with Visual Studio.

porting moonfish

Porting moonfish to a different platform should be a matter of simply providing a “mostly C89‐compliant” C implementation. Of course, moonfish doesn’t make use of all C89 features, so it is not necessary to have features that it doesn’t use. For example, compiling on 9front works through NPE, which provides something close enough to C89 for moonfish to work.

It is possible to compile moonfish within a strict C89 implementation by defining the moonfish_no_threads and moonfish_no_clock macros.

license

moonfish is released under the 0BSD license:

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.

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.