TiynGER
fa05c87cb1
|
4 years ago | |
---|---|---|
art | 4 years ago | |
src | 4 years ago | |
tests | 4 years ago | |
.gitignore | 4 years ago | |
LICENSE | 4 years ago | |
README.md | 4 years ago | |
TODO.md | 4 years ago |
README.md
ychess
ychess is a chess implementation and engine written in nim.
Quick Setup
To play chess in the commandline simply download the code (or clone the
repository) and run nim c -r game.nim
.
You can either play the 1v1 hotseat mode or a single player mode vs the engine.
Additionally ychess uses the lichess api to make playing more convenient. An instance of the engine occasionally plays on lichess. To get into the whitelist just write a ingame message to the account.
Project Structure
art
- contains pictures and arts not used in the code.bin
- is not pushed to the git repository but contains all binaries and will be created if you compile a program.htmldocs
- is not pushed to the git repository but contains all automatically generated documentation.src
- is the root folder for all programs except tests.tests
- contains all tests.
Documentation
Documentation is written into the code via DocGen.
For this reason it is not saved in this repository.
To extract it into html (assuming you want the documentation for game.nim
)
run nim doc --project --index:on --outdir:htmldocs game.nim
.
General Design Choices
Moves
Moves are read from the commandline as pure coordinate notation. The inner program will convert this notation to a move-tuple.
Board Representation
Due to easier off the board checking a 10x12 board is used.
Engine
The engine uses a simple implementation of the NegaMax-algorithm with Alpha-Beta-Pruning. For the evaluation function each piece has a corresponding value. Additionally piece-square tables are used.
Contributing
Setup
To setup the project for development you need to create the file
src/secret.nim
.
It should contain values for the following variables:
let projectdir* = "<absolute path to root dir of ychess>"
let api_token* = "<lichess api token for bot>"
Code Style Guide
Basic arithmetic operations should be surrounded by spaces for example: 1 + 3
.
This however is not true for negation of a single value (-1
) or if the
arithmetic operation is done inside array brackets or in iterators (a+1..3
,
a[c+3]
).
Determining the length of a string, array, etc should not be done via a function
(len(array)
) but by appending it like array.len
.
If statements should not contain outer brackets.
In some cases (especially concatenations of and
and or
) inner brackets are
useful to increase readability in complexer logic formulas.
When assigning booleans with logical formulas outer brackets are expected.