A chess engine written from scratch in Rust ♞

Overview

Walleye

Walleye is a chess engine written completely in rust.

tests

Walleye is a UCI-compatible engine written using the classical alpha-beta style AI. It supports loading board positions from arbitrary FEN strings, Unicode pretty printing to the console, and UCI communication logs to help with debugging.

Originally this project was meant as a first introduction to rust and chess programming, but it got a bit carried away.

Example Usage

By default, the engine launches in UCI mode and expects to be loaded into a chess GUI. However, you can also run some commands from the terminal, such as -P to watch the engine play against itself.

demo

Type ./walleye --help for a complete list of commands.

Play Against It

The engine should be able to be loaded into any chess GUI that supports UCI, at this time though it has only been tested with Cute Chess. It is recommended you compile the engine with the --release option for the best performance.

Resources

Some resources I found helpful when creating this engine.

License

Walleye is under the MIT license.

Comments
  • Ideas

    Ideas

    Hi Mitchel,

    Nice job on the engine!

    Just starting to get familiar with the code. New to rust so it will take some time. So far it looks great!

    No specific issue. Is thier anything you need help on?

    On my initial review it does not appear that you support using any sort of opening book moves. I'm looking at another another github project that could act as a source to provide a set of opening book moves. See https://github.com/niklasf/chess-openings

    I have cloned and built Walleye.

    Cute chess does not seem to install as documented. But that issues will go to them.

    A few other ideas:

    • break out the fen functions from board
    • record moves
    • add AI to the engine
    question 
    opened by mcoolin 12
  • Losing most games on time

    Losing most games on time

    Hi Mitchel,

    Author of Rustic here :) ( https://github.com/mvanthoor/rustic )

    Your engine was mentioned on Talkchess.com, so I tried running a test against Rustic, version Alpha 1.1 (CCRL Blitz 1675). An often used time control for testing is 10s + 0.1s (so you can test 1000's of games without waiting a week). With this time control, WallEye 1.2.0 loses most games on time, often taking at least 5-6 seconds for the first move out of the opening book.

    Because the time controls don't yet work correctly, the engine is essentially un-testable.

    I hope you can spend some time fixing the time controls; I look forward to have another Rust engine in my testing pool.

    Kind regards, Marcel

    enhancement 
    opened by mvanthoor 11
  • no output in CuteChess (but plays ok)

    no output in CuteChess (but plays ok)

    while Walleye is calculating i see no pv line output in the CuteChess panel .. i have no troubles using Walleye on Linux, but it seems Walleye is simple ?

    enhancement 
    opened by tissatussa 9
  • Problems with running the engine

    Problems with running the engine

    For me it does not move at all under Arena. Under Cute Chess it does move but exceeds time soon. Both with traditional and Fischer clock.

    Here is a debug from Arena:

    2021-09-11 10:38:33,932-->1:quit 2021-09-11 10:38:34,3231-------------------Starting engine 1 Walleye 1.1.0 64-bit------------------- 2021-09-11 10:38:34,3231Configured Engine 1 Type: UCI 2021-09-11 10:38:34,3231Engine 1 dir: E:\Sakk\UCI-engines\Walleye 2021-09-11 10:38:34,3231Engine 1 commandline: E:\Sakk\UCI-engines\Walleye\Walleye_1.1.0-x64.exe 2021-09-11 10:38:34,4321Child Process Prio Adj: PID 1216 conhost.exe 2021-09-11 10:38:34,4321Engine 1 ProcessID: 7064 2021-09-11 10:38:34,4321Engine 1 Prio:32 ThreadPrio:0 2021-09-11 10:38:34,463-->1:uci 2021-09-11 10:38:34,463<--1:id name Walleye 2021-09-11 10:38:34,463<--1:id author Mitchel Paulin 2021-09-11 10:38:34,463<--1:uciok 2021-09-11 10:38:34,4631Child Process Prio Adj: PID 1216 conhost.exe 2021-09-11 10:38:34,463-->1:isready 2021-09-11 10:38:34,526<--1:readyok 2021-09-11 10:38:38,729**----------New game---2021-09-11 10:38:38,729 Szo ------------- 2021-09-11 10:38:38,729**Loading book: E:\Sakk\Arena2\Books\IM_4mvs.abk 2021-09-11 10:38:44,9621Start calc, move no: 1 2021-09-11 10:38:44,9621Main Book Move IM_4mvs.abk: c7c5 2021-09-11 10:38:45,9471Start calc, move no: 3 2021-09-11 10:38:45,947-->1:ucinewgame 2021-09-11 10:38:45,947-->1:isready 2021-09-11 10:38:50,056-->1:position startpos moves e2e4 c7c5 e4e5 2021-09-11 10:38:50,056-->1:go wtime 121484 btime 121000 winc 1000 binc 1000

    At this point I checked with Process Explorer and the engine was not even in memory.

    bug 
    opened by SzotsGabor 7
  • can not compile v1.4.0 on Linux

    can not compile v1.4.0 on Linux

    here is the terminal log :

    $ cargo build --release --verbose
           Fresh cfg-if v1.0.0
           Fresh lazy_static v1.4.0
           Fresh unicode-width v0.1.9
           Fresh bitflags v1.3.2
           Fresh vec_map v0.8.2
           Fresh ansi_term v0.11.0
           Fresh strsim v0.8.0
           Fresh textwrap v0.11.0
           Fresh libc v0.2.103
           Fresh log v0.4.14
           Fresh atty v0.2.14
           Fresh thread-id v3.3.0
           Fresh colored v2.0.0
           Fresh clap v2.33.3
           Fresh simple-logging v2.0.2
       Compiling walleye v1.4.0 (/home/tissatussa/Compiled/Walleye_v1.4.0)
         Running `rustc --crate-name walleye --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C opt-level=3 -C lto -C codegen-units=1 -C metadata=c0314d45e350ab32 -C extra-filename=-c0314d45e350ab32 --out-dir /home/tissatussa/Compiled/Walleye_v1.4.0/target/release/deps -L dependency=/home/tissatussa/Compiled/Walleye_v1.4.0/target/release/deps --extern clap=/home/tissatussa/Compiled/Walleye_v1.4.0/target/release/deps/libclap-92b2ce1d83fefcb6.rlib --extern colored=/home/tissatussa/Compiled/Walleye_v1.4.0/target/release/deps/libcolored-af5d305c32b4ddbc.rlib --extern log=/home/tissatussa/Compiled/Walleye_v1.4.0/target/release/deps/liblog-f28a7c1eb8fddef7.rlib --extern simple_logging=/home/tissatussa/Compiled/Walleye_v1.4.0/target/release/deps/libsimple_logging-d9170c4c5c5a3ed5.rlib`
    error[E0277]: `[Option<(board::Point, board::Point)>; 100]` is not an iterator
       --> src/engine.rs:214:16
        |
    214 |     for mov in search_info.pv_moves {
        |                ^^^^^^^^^^^^^^^^^^^^ borrow the array with `&` or call `.iter()` on it to iterate over it
        |
        = help: the trait `Iterator` is not implemented for `[Option<(board::Point, board::Point)>; 100]`
        = note: arrays are not iterators, but slices like the following are: `&[1, 2, 3]`
        = note: required because of the requirements on the impl of `IntoIterator` for `[Option<(board::Point, board::Point)>; 100]`
        = note: required by `into_iter`
    
    error: aborting due to previous error
    
    For more information about this error, try `rustc --explain E0277`.
    error: could not compile `walleye`
    
    Caused by:
      process didn't exit successfully: `rustc --crate-name walleye --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C opt-level=3 -C lto -C codegen-units=1 -C metadata=c0314d45e350ab32 -C extra-filename=-c0314d45e350ab32 --out-dir /home/tissatussa/Compiled/Walleye_v1.4.0/target/release/deps -L dependency=/home/tissatussa/Compiled/Walleye_v1.4.0/target/release/deps --extern clap=/home/tissatussa/Compiled/Walleye_v1.4.0/target/release/deps/libclap-92b2ce1d83fefcb6.rlib --extern colored=/home/tissatussa/Compiled/Walleye_v1.4.0/target/release/deps/libcolored-af5d305c32b4ddbc.rlib --extern log=/home/tissatussa/Compiled/Walleye_v1.4.0/target/release/deps/liblog-f28a7c1eb8fddef7.rlib --extern simple_logging=/home/tissatussa/Compiled/Walleye_v1.4.0/target/release/deps/libsimple_logging-d9170c4c5c5a3ed5.rlib` (exit code: 1)
    
    bug 
    opened by tissatussa 4
  • [Question] What terminal do you use to produce

    [Question] What terminal do you use to produce

    Hey! I've started implementing a chess engine in Rust and I was looking at the others for debugging/interface infrastructure, so I found yours! I really liked how you print the board using colored: this looks really cool and I wanted to implement something similar to have easier time looking at the positions in the engine (right now I have basic ASCII printing a-la python-chess/shakmaty). My question is: what terminal/fonts do you use? Any advice to make the output look like the one on your demo? This is what I currently get from running Walleye in my terminal:

    Screenshot 2021-12-30 at 10 50 35 question 
    opened by kirillbobyrev 3
  • Walleye not running

    Walleye not running

    Heya! 😄

    I compile the app and ran it, but it gave no outputs (I think it should output some info and an readyok when you run it.

    I then passed through a isready command, and the application exited.

    It doesn't seem to comply with the UCI Protocol? Or is not functioning? Or I'm doing something wrong?

    Here's what I ran:

    image
    opened by chase-manning 1
  • 50 move rule does not seem to be implemented

    50 move rule does not seem to be implemented

    For the following command: 4k3/8/8/8/8/8/8/4K2R w - - 99 1 The engine should only play 1 move and then draw in accordance to the 50 move rule, but it keeps playing anyway. I've checked the code and it doesn't seem to have this rule implemented anywhere.

    enhancement 
    opened by Dopplerian 1
  • Drawing by 3-fold repitition in winning positions

    Drawing by 3-fold repitition in winning positions

    Right now the engine does not know about the draw by 3-fold repetition rule (or any rules about draws for that matter). This means the engine will happily repeat moves even if its in a winning position.

    Update the engine so, if the engine is in a winning position, it will not repeat moves.

    enhancement 
    opened by MitchelPaulin 1
  • Use types and structure for pieces and squares

    Use types and structure for pieces and squares

    This replaces the existing bitwise arithmetic with structures and many of the top-level board functions with type methods.

    There is no change to the chess logic here -- this is just a refactor.

    I won't be hurt if you don't want to merge this! The refactor was a nice way for me to understand the code, and IMHO makes it more "idiomatic".

    opened by djmitche 0
  • Walleye is not able to checkmate with king and rook and gets into a loop

    Walleye is not able to checkmate with king and rook and gets into a loop

    For the following input command: ./walleye -P -f '4k3/8/8/8/8/8/8/4K2R w - - 0 1' The engine is unable to checkmate and also gets into an infinite loop where the threefold repetition rule seems not to apply.

    enhancement 
    opened by Dopplerian 1
  • Bug when trying to checkmate

    Bug when trying to checkmate

    For the following input command: ./walleye -P -f '7k/4Q3/6K1/8/8/8/8/8 w - - 0 1' It first does a search to depth 99, which is unneeded since it is clearly a mate in 1, and then prints the same board over and over instead of terminating program execution.

    bug 
    opened by Dopplerian 1
Releases(1.6.0)
Owner
Mitchel Paulin
Mitchel Paulin
An easy-to-use, 2D GUI library written entirely in Rust.

Conrod An easy-to-use, 2D GUI library written entirely in Rust. Guide What is Conrod? A Brief Summary Screenshots and Videos Feature Overview Availabl

PistonDevelopers 3.3k Jan 1, 2023
Idiomatic, GTK+-based, GUI library, inspired by Elm, written in Rust

Relm Asynchronous, GTK+-based, GUI library, inspired by Elm, written in Rust. This library is in beta stage: it has not been thoroughly tested and its

null 2.2k Dec 31, 2022
SwiftUI Inspired UI Library written in rust

Mule (Definitely a Work in Progress) The night I started this project I was on the couch drinking a Moscow Mule.

null 40 Jun 22, 2022
A floating, tag-based window manager written in Rust

worm worm is a floating, tag-based window manager for X11. It is written in the Rust programming language, using the X11RB library. Install cargo buil

null 627 Jan 4, 2023
D3D9 Window overlay written in Rust

win-overlay (-rs) DirectX overlay written in Rust for various projects, wanted to easily create overlays across projects so decided to write my own im

Zor 18 Dec 28, 2022
Highly customizable finder with high performance. Written in Rust and uses GTK

Findex Highly customizable finder with high performance. Written in Rust and uses GTK Installation Automatic Binary Clone from https://aur.archlinux.o

MD Gaziur Rahman Noor 442 Jan 1, 2023
GUI based tool to sort and categorize images written in Rust

ImageSieve GUI based tool to sort out images based on similarity, categorize them according to their creation date and archive them in a target folder

Florian Fetz 67 Dec 14, 2022
A simple note taking application written in Rust and GTK4

Rnote A simple note taking application written in Rust and GTK4. Rnote aims to be a simple but functional note taking application for freehand drawing

Felix Zwettler 3.4k Jan 5, 2023
Cross-platform GUI toolkit written in Rust

Tuix is a cross-platform GUI toolkit written in Rust. The driving principle behind tuix is to be a self-contained, small-as-possible, but still fast,

George Atkinson 166 Dec 13, 2022
Winsafe-examples - Examples of native Windows applications written in Rust with WinSafe.

WinSafe examples This repo contains several examples of native Win32 applications written in Rust with WinSafe. All examples follow the same program s

Rodrigo 40 Dec 14, 2022
A GUI for NordVPN on Linux that maintains feature parity with the official clients, written with Rust and GTK.

Viking for NordVPN This project aims to provide a fully usable and feature-complete graphical interface for NordVPN on Linux. While it attempts to clo

Jacob Birkett 2 Oct 23, 2022
Neovim GUI written in Rust, using relm4 and gtk4-rs

Reovim Neovim GUI written in Rust, using relm4 and gtk4-rs. Thanks Neovide Configuration To setup font add next line to init.vim set guifont=Cascadia\

songww 70 Dec 13, 2022
Modular FFXIV data toolkit written in rust.

ironworks Modular FFXIV data toolkit written in rust. ironworks is pre-1.0, and as such its API should be considered unstable. Breaking API changes wi

Saxon Landers 10 Oct 21, 2022
skyWM is an extensible tiling window manager written in Rust

skyWM is an extensible tiling window manager written in Rust. skyWM has a clear and distinct focus adhering to the KISS and Unix philosophy.

Chadano 74 Dec 28, 2022
An Anime Game Launcher variant written on Rust, GTK4 and libadwaita, using Anime Game Core library

An Anime Game Launcher GTK The launcher variant written on Rust, GTK4 and libadwaita, using Anime Game Core library You could also try the main branch

An Anime Team 77 Jan 9, 2023
Honkers Launcher variant written on Rust, GTK4 and libadwaita, using Anime Game Core library

You could also try the main branch Development Folder Description ui Blueprint UI files ui/.dist UI files compiled by the blueprint src Rust source co

An Anime Team 9 Nov 2, 2022
A fast, zbus-based, permissively licensed AT-SPI library written in pure Rust!

AT-SPI for Rust Higher level, asynchronous Rust bindings to AT-SPI2, using zbus. Part of the Odilia screen reader project. Design Fully documented, wi

Odilia 12 Dec 31, 2022
GTK 4 front-end to ChatGPT completions written in Rust

ChatGPT GUI Building git clone [email protected]:teunissenstefan/chatgpt-gui.git cd chatgpt-gui cargo build --release Todo Connect insert_text to only al

Stefan Teunissen 6 Mar 12, 2023
A small dice roller app with GUI written in Rust 🦀🎲

?? Mini Dice A small dice roller written in Rust and using the egui library. Demo ?? A short introduction... I started creating Mini Dice with the goa

Angelica Raborar 4 May 16, 2023