Kłak è un piccolo motore di scacchi scritto per imparare a programmare. È un progetto didattico di un padre e di suo figlio: si parte da Python, con la libreria python-chess, e più avanti il motore verrà riscritto in Rust.
Il nome si scrive Kłak, con la lettera polacca ł, che si legge come una w. Si pronuncia quindi come l'inglese quack, il verso della papera. È un gioco di parole.
Nei nomi di file e cartelle si usa Klak, senza la ł, perché questa lettera non si trova su tutte le tastiere.
Ci sono due versioni di partenza, indipendenti tra loro:
| Cartella | Autore | Cosa fa |
|---|---|---|
daniele/ |
Daniele | Klak v0.0.0: la versione più semplice. Gioca partite intere scegliendo mosse a caso. È la base da cui si impara. |
alessandro/ |
Alessandro, figlio di Daniele | Un motore completo e funzionante. |
Le due cartelle restano com'è giusto che sia: sono la storia del progetto.
- Daniele impara Python, un passo alla volta, costruendo Klak da zero.
- Quando arriva al livello di Alessandro, i due codici si confrontano.
- Si tengono le parti migliori o scritte meglio di ciascuno.
- Dal codice unito, in una nuova cartella
klak/, nasce il Klak definitivo, segnato come versionev1.0.0. - Poi arriva la riscrittura in Rust.
Il percorso di apprendimento:
- Basi di Python
- python-chess: scacchiera, mosse legali, partita a caso
- Valutazione del materiale
- Minimax, poi alpha-beta
- Quiescence e ordinamento delle mosse
- Tabelle pezzo-casa e approfondimento iterativo con gestione del tempo
- Protocollo UCI, per collegare Klak a un'interfaccia grafica
- Riscrittura in Rust
Serve Python 3. La libreria si installa con:
pip install chess
Poi, per esempio:
python daniele/klak_0_0_0.py
In Google Colab la prima riga di una cella è !pip install chess.
Daniele e suo figlio Alessandro, che ha anche fatto altri progetti come GrapeScript, un intero linguaggio di programmazione! . Il codice di ogni cartella è di chi l'ha scritto.
Klak è software libero, distribuito con la licenza GNU General Public License v3.0 (GPL-3.0). Il testo completo è nel file LICENSE.
Kłak is a small chess engine written to learn programming. It is a learning project by a father and his son: it starts in Python, with the python-chess library, and the engine will later be rewritten in Rust.
The name is spelled Kłak, with the Polish letter ł, which sounds like a w. So it is pronounced like the English quack, the sound a duck makes. It is a play on words.
In file and folder names it is written Klak, without the ł, because that letter is not on every keyboard.
There are two starting versions, independent from each other:
| Folder | Author | What it does |
|---|---|---|
daniele/ |
Daniele | Klak 0.0.0: the simplest version. It plays whole games by choosing random moves. It is the base to learn from. |
alessandro/ |
Alessandro, Daniele's son | A complete, working engine. |
Both folders stay as they are: they are the history of the project.
- Daniele learns Python, one step at a time, building Klak from scratch.
- When he reaches Alessandro's level, the two codebases are compared.
- The best or best-written parts of each are kept.
- From the merged code, in a new
klak/folder, comes the final Klak, tagged as versionv1.0.0. - Then comes the rewrite in Rust.
The learning path:
- Python basics
- python-chess: board, legal moves, a random game
- Material evaluation
- Minimax, then alpha-beta
- Quiescence and move ordering
- Piece-square tables and iterative deepening with time management
- UCI protocol, to connect Klak to a graphical interface
- Rewrite in Rust
You need Python 3. Install the library with:
pip install chess
Then, for example:
python daniele/klak_0_0_0.py
In Google Colab, the first line of a cell is !pip install chess.
Daniele and his son Alessandro. The code in each folder belongs to whoever wrote it.
Klak is free software, released under the GNU General Public License v3.0 (GPL-3.0). The full text is in the LICENSE file.