# README

Nemorino is a UCI chess engine.

### Features

- Syzygy Tablebase support
- Pondering
- Standard Chess and Chess960
- Multi Core support (Shared Hash Table)
- Multi PV analysis mode
- Support of NNUE based evaluation

#### UCI parameters:

- UCI_Chess960: If set to true engine will play according to Chess960 rules (default false)
- Hash: Size in MBytes used for the transposition table (default is 32. Nemorino will use additional memory for other fixed-size hash tables)
- Clear Hash: Will clear the transposition table
- Print Options: Outputs all UCI parameter values
- MultiPV: Number of principal variations shown (default 1)
- Threads: Maximum number of threads (cores) used (default determined by number of available hardware threads)
- Ponder: When set to true, engine will continue analysis while waiting for opponent's move (default false)
- Contempt: Score (in centipawns) for accepting draws. If Contempt > 0 then the engine will avoid draws (default 0)
- BookFile: Polyglot book file the engine shall use (default "book.bin"). Nemorino doesn't have an own book so far
- OwnBook: Use Polyglot book, specified by book file (default false)
- SyzygyPath: Path(es) to directories where Syzygy tablebase files can be found. Separate multiple directories by ';' on windows and by ':' on linux
- SyzygyProbeDepth: Minimum search depth for probing Syzygy Bases. The lower the number, more tablebase lookups will be done, but search speed will decrease (default 7)
- SyzygyProbeLimit: Use only up to -men Tablebases (default 7)
- MoveOverhead: Safety Time(in ms) needed to avoid time-losses.
- UCI_Opponent: With this command the GUI can send the name, title, elo and if the engine is playing a human or computer to the engine (see UCI Specification)
- EvalFile: Path to a NNUE parameter file
- UseNNUE: When set to false engine uses classic evaluation (default true if default net is available)

### Installation

These archive contains 5 executables (sorted by speed/playing strength in descending order)

- nemorino_6.00_win64_bmi2.exe For CPUs supporting BMI2
- nemorino_6.00_win64_avx2.exe For CPUs supporting AVX2
- nemorino_6.00_win64_sse41.exe For CPUs supporting SSE4.1
- nemorino_6.00_win64_sse2.exe For CPUs supporting SSE2
- nemorino_6.00_win64_old_cpu.exe For most other CPUs

Additionally

- nemorino_net_6.nnue Network parameter file - should be placed in the executables (work) directory

Nemorino doesn't bring it's own UI. So for running it, you need a GUI supporting UCI (like Arena).

The engine requires 64-bit Windows. Linux compiles can be easily created by cloning the Repository of Nemorino via

    git clone https://bitbucket.org/christian_g_nther/nemorino.git

and then use make

Nemorino uses a slightly adapted file format compared to Stockfish, but you can use the network parameter files from Stockfish (and other NNUE engines) as well. Those files will be copied and converted automatically at first usage by Nemorino.

### Internals

- Bitboard based (using magic bitboards for sliding move generation)
- Principal Variation Search (with Aspiration Windows, Null-Move Pruning, Killermoves, Futility Pruning, Razoring, ...)
- Tapered Eval based on Material, Mobility, Threats, King Safety, and Pawn Structure
- Special evaluation functions for some endgames
- Copy/Make

### Version History

1.01:

- Bugfix: rare crashes caused by hash collisions in transposition table
- Code changes for non-popcount compiles

1.02:

- New Parameters: SyzygyProbeDepth and MoveOverhead
- Bugfix: Handling of EP-Squares in TB probing code

2.00:

- Several Improvements in Search: Singular Extensions, Cut Node Extensions, improved IID,..
- Improved SEE (consider promotions and pinned pieces)
- Improved King Safety Evaluation
- Scale down endgame values if there are opposite colored bishops
- Several minor improvements and clean-ups

2.00a (only bugfixes relevant when running with more than one thread):

- Fix for known issue with tablebase access (see https://github.com/basil00/Fathom/issues/15
- Fix for other (rare) crashes

3.00:

- Refactoring of SMP implementation => Improved stability
- Several minor improvements in search and move ordering

4.00:

- Improved King Safety evaluation
- Some Improvements when running with many threads
- Some Evaluation Improvements (added some material imbalance terms, knight center mobility, ... and removed some useless terms)

5.00:

- Several minor Improvements especially for King Safety
- Several Bugfixes
- Replaced Syzygy probing code. Now instead of Fathom library, probing code from Stockfish is used

6.00:

- Support of NNUE (Neural Network used for Evaluation)
- Reworked Thread Management
- Embedded 4-men Syzygy Tablebases for elementary endgames
- Several minor Improvements and Tweaks in Search and Evaluation
- Several Bugfixes

6.00 Patch 1 (only bug fixes without impact on playing strength):

Bugs fixed:

- No output of name after uci command
- No support for case-insensitive uci option keys

### License

GNU GENERAL PUBLIC LICENSE Version 3

Source code is available at Bitbucket

### Remarks

I wrote this engine because I wanted to understand, how a chess engine is working. And the best way to learn is to write an engine from scratch by yourself. I first started with C#, but after some time I got the ambition to learn C++. Therefore don't expect a lot of new ideas within my code, and neither expect clean and well-structured code. Instead you will find a unique combination of all those ideas explained in the Chess Programming Wiki.

### Acknowledgements

These are my sources of information I used for my engine:

- My main source of information: Chess Programming Wiki
- Computer Chess Club Forums
- The code of several Open Source Chess Engines, mainly:
  - Stockfish - Nemorino contains copied and adapted code from Stockfish, mainly the Syzygy probing and the NNUE inference code in the files network.h, tbprobe.h and tbprobe.cpp.
  - Hakkapeliitta
  - Lozza
  - Senpai
- The blogs of Steve Maughan, Thomas Petzke and Jonatan Pettersson