docker: add build/run Dockerfile
The image builds Vatu and can run it on Lichess.
This commit is contained in:
parent
a426e2f777
commit
c0ff3a9794
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "external/lichess-bot"]
|
||||||
|
path = external/lichess-bot
|
||||||
|
url = https://github.com/ShailChoksi/lichess-bot.git
|
76
README.md
76
README.md
|
@ -1,13 +1,81 @@
|
||||||
Vatu
|
Vatu
|
||||||
====
|
====
|
||||||
|
|
||||||
Dumb chess engine written in Rust for fun. Supports UCI.
|
Dumb chess engine written in Rust for fun.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Features
|
||||||
|
--------
|
||||||
|
|
||||||
|
- [UCI][cpw-uci]
|
||||||
|
- Barely optimized board, position and moves representations
|
||||||
|
- Simple [negamax][cpw-negamax] for node evaluation
|
||||||
|
- [Alpha-beta][cpw-ab] search tree pruning for speeding searches
|
||||||
|
|
||||||
|
[cpw-uci]: https://www.chessprogramming.org/UCI
|
||||||
|
[cpw-negamax]: https://www.chessprogramming.org/Negamax
|
||||||
|
[cpw-ab]: https://www.chessprogramming.org/Alpha-Beta
|
||||||
|
|
||||||
|
Last time I checked it ran approximately at 10000 nps.
|
||||||
|
|
||||||
|
Thanks to UCI the bot can run with most compatible software; [Cutechess][cc] has
|
||||||
|
been used for testing.
|
||||||
|
|
||||||
|
[cc]: https://github.com/cutechess/cutechess
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Usage
|
||||||
|
-----
|
||||||
|
|
||||||
|
### Build
|
||||||
|
|
||||||
|
With Cargo:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo build --release
|
||||||
|
```
|
||||||
|
|
||||||
|
With Docker, to avoid setting up a Rust toolchain:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker build -f res/docker/Dockerfile -t vatu-builder --target builder .
|
||||||
|
docker create vatu-builder # Returns a container ID.
|
||||||
|
docker cp <id>:/src/target/release/vatu .
|
||||||
|
docker rm <id>
|
||||||
|
docker rmi vatu-builder
|
||||||
|
```
|
||||||
|
|
||||||
|
### Run
|
||||||
|
|
||||||
|
If you built it with Cargo, the binary is in `target/release`.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./vatu
|
||||||
|
```
|
||||||
|
|
||||||
|
To run your own instance of the bot on Lichess (why would you do that?), create
|
||||||
|
a bot account and get an OAuth token. Then using the full Docker image:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Fetch the lichess-bot submodule.
|
||||||
|
git submodule update --init --recursive
|
||||||
|
# Copy the config.yml template to your own copy and modify it.
|
||||||
|
cp external/lichess-bot/config.yml.example /tmp/vatu-config/config.yml
|
||||||
|
# Build the image. Make sure config.yml is not there to not embed it!
|
||||||
|
docker build -f res/docker/Dockerfile -t vatu .
|
||||||
|
# Run with the config folder mounted at /config.
|
||||||
|
docker run -v /tmp/vatu-config:/config -ti vatu
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TODO
|
TODO
|
||||||
----
|
----
|
||||||
|
|
||||||
- Support time constraints on "go" commands.
|
- Support time constraints
|
||||||
- Precompute knight and maybe other pieces moves.
|
- Proper unmake mechanism instead of allocating boards like there is no tomorrow
|
||||||
- Some Alpha-beta in terribly slow best move calculation.
|
- Precompute knight some pieces moves, maybe
|
||||||
|
- Transposition table that does not actually slows search down
|
||||||
|
- Multithreading (never)
|
||||||
|
|
1
external/lichess-bot
vendored
Submodule
1
external/lichess-bot
vendored
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 72d5eb1431e24935aad4cf12b86ca7af27d0491a
|
14
res/docker/Dockerfile
Normal file
14
res/docker/Dockerfile
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# Build engine.
|
||||||
|
FROM rust:1 AS builder
|
||||||
|
COPY . /src
|
||||||
|
WORKDIR /src
|
||||||
|
RUN cargo build --release
|
||||||
|
|
||||||
|
# Run on a Lichess account.
|
||||||
|
FROM python:3
|
||||||
|
COPY . /vatu
|
||||||
|
WORKDIR /vatu/external/lichess-bot
|
||||||
|
RUN ls -l
|
||||||
|
RUN pip install -r requirements.txt
|
||||||
|
COPY --from=builder /src/target/release/vatu engines/
|
||||||
|
ENTRYPOINT ["bash"]
|
19
src/main.rs
19
src/main.rs
|
@ -1,6 +1,4 @@
|
||||||
use std::process;
|
use clap::{App, Arg};
|
||||||
|
|
||||||
use clap::{App, AppSettings, Arg, ArgMatches, SubCommand};
|
|
||||||
|
|
||||||
pub mod analysis;
|
pub mod analysis;
|
||||||
pub mod board;
|
pub mod board;
|
||||||
|
@ -14,27 +12,16 @@ pub mod stats;
|
||||||
pub mod uci;
|
pub mod uci;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let matches = App::new("Vatu")
|
let args = App::new("Vatu")
|
||||||
.setting(AppSettings::ArgRequiredElseHelp)
|
|
||||||
.subcommand(SubCommand::with_name("uci")
|
|
||||||
.about("Start engine in UCI mode")
|
|
||||||
.arg(Arg::with_name("debug")
|
.arg(Arg::with_name("debug")
|
||||||
.help("Enable debug mode")
|
.help("Enable debug mode")
|
||||||
.short("d").long("debug").takes_value(false).required(false))
|
.short("d").long("debug").takes_value(false).required(false))
|
||||||
.arg(Arg::with_name("log_file")
|
.arg(Arg::with_name("log_file")
|
||||||
.help("Log file path (default is stderr)")
|
.help("Log file path (default is stderr)")
|
||||||
.long("log-file").takes_value(true).required(false)))
|
.long("log-file").takes_value(true).required(false))
|
||||||
.get_matches();
|
.get_matches();
|
||||||
|
|
||||||
process::exit(match matches.subcommand() {
|
|
||||||
("uci", Some(a)) => cmd_uci(a),
|
|
||||||
_ => 0,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn cmd_uci(args: &ArgMatches) -> i32 {
|
|
||||||
let debug = args.is_present("debug");
|
let debug = args.is_present("debug");
|
||||||
let output = args.value_of("log_file");
|
let output = args.value_of("log_file");
|
||||||
uci::Uci::start(debug, output);
|
uci::Uci::start(debug, output);
|
||||||
0
|
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue