Very basic functionality

This commit is contained in:
Kris Lamoureux 2023-03-15 00:52:32 -04:00
commit 2a405850e3
Signed by: kris
GPG Key ID: 3EDA9C3441EDA925
7 changed files with 78 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
env
bin

12
Dockerfile Normal file
View File

@ -0,0 +1,12 @@
FROM debian:11-slim
ARG STOCKFISH_VERSION=sf_15.1
RUN apt-get update && apt-get install -y \
git make curl g++ \
&& rm -rf /var/lib/apt/lists/*
RUN git clone --quiet https://github.com/official-stockfish/Stockfish.git
RUN cd Stockfish/src \
&& git checkout --quiet ${STOCKFISH_VERSION} \
&& make -j build ARCH=x86-64-modern

12
LICENSE Normal file
View File

@ -0,0 +1,12 @@
Copyright (C) 2023 by Kris Lamoureux <kris@lamoureux.io>
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.

22
README.md Normal file
View File

@ -0,0 +1,22 @@
# ChessCLI
ChessCLI is a simple hobby command-line interface (CLI) chess program written
in Python that lets you play against chess engines such as Stockfish, or any
other engine that supports the Universal Chess Interface (UCI) protocol. The
CLI will prompt you for moves in standard algebraic notation (SAN) to play the
game. You would typically use this with a physical chessboard for visualizing.
Therefore, if you are looking for graphics, this will not be the software for
you.
### Docker
A `Dockerfile` and a `docker-compose.yml` file are included to aid in compiling
the desired version of Stockfish and to place the resulting binary in an
adjacent bin directory for use by the application.
#### Copyright and License
Copyright (C) 2023 Kris Lamoureux
This project is licensed under the 0BSD License - see the LICENSE file for
details.

18
chesscli.py Normal file
View File

@ -0,0 +1,18 @@
import chess
import chess.engine
board = chess.Board()
engine = chess.engine.SimpleEngine.popen_uci("bin/stockfish")
count = 1
while not board.is_game_over():
if board.turn == chess.WHITE:
move = input(str(count) + " ")
board.push_san(move)
else:
result = engine.play(board, chess.engine.Limit(time=2.0))
print(str(count) + "...", board.san(result.move))
board.push(result.move)
count += 1
engine.quit()

11
docker-compose.yml Normal file
View File

@ -0,0 +1,11 @@
version: "3.7"
services:
stockfish:
build:
context: .
dockerfile: Dockerfile
command: sh -c "cp /Stockfish/src/stockfish /output"
volumes:
- ./bin:/output

1
requirements.txt Normal file
View File

@ -0,0 +1 @@
chess==1.9.4