A neural network that converts chess moves (e.g. e2 e4) into an actual chessboard representation.
It can be used as an input layer for a larger neural engine.
> test; e2 and then e4
|ABCDEFGH
8|rnbqkbnr
7|pppppppp
6|........
5|........
4|....P...
3|........
2|PPPP.PPP
1|RNBQKBNR
> a7 a6
|ABCDEFGH
8|rnbqkbnr
7|.ppppppp
6|p.......
5|........
4|....P...
3|........
2|PPPP.PPP
1|RNBQKBNR
The main output is not console text, but an embedding that represents the board in memory:
> repr
Current chessboard representation by the network in memory:
RNBQKPrnbqkp.|RNBQKPrnbqkp.|RNBQKPrnbqkp.|RNBQKPrnbqkp.|RNBQKPrnbqkp.|RNBQKPrnbqkp.|RNBQKPrnbqkp.|RNBQKPrnbqkp.|
A | B | C | D | E | F | G | H |
[1............|.1...........|..1..........|...1.........|....1........|..1..........|.1...........|1............
.....1.......|.....1.......|.....1.......|.....1.......|............1|.....1.......|.....1.......|.....1.......
............1|............1|............1|............1|............1|............1|............1|............1
............1|............1|............1|............1|.....1.......|............1|............1|............1
............1|............1|............1|............1|............1|............1|............1|............1
...........1.|............1|............1|............1|............1|............1|............1|............1
............1|...........1.|...........1.|...........1.|...........1.|...........1.|...........1.|...........1.
......1......|.......1.....|........1....|.........1...|..........1..|........1....|.......1.....|......1......]
By default, the network does not print anything to the console for faster operation.
This behavior is controlled by neuron [0]:
def setPrintBoard(self, usePrint: bool = True):
# This special neuron toggles ASCII board printing after each move.
self._activations[0] = 1 if usePrint else 0
# ASCII printing is slow — several cycles per character.
# For embedding into another system, call embedding() to obtain
# the internal state faster and directly.Printing is handled via the standard feed-forward cycle.
> info
Neurons: 5553
Links: 18287
Active neurons: 256
Average connectivity: 3.29
If ASCII-printing neurons are excluded:
- 4521 neurons (–1032, ~22%)
- 15455 links (–2832, ~18%)
File sizes:
- ChessBoardNN.py — 153 KB (unzipped)
- ChessBoardNN.py.zip — 28 KB
The network was created in a specialized IDE, and then exported to Python
SemanticNN is a combination of LSTM and semantic networks.
All LSTM neurons preserve their activation between cycles. For optimization, these neurons are grouped at the beginning of the neuron array, up to index self._permanentCount.
From semantic networks, the model inherits:
-
a variable number of links per neuron,
-
the ability to form loops.
def embedding(self):
# 832 neurons stand for 64 cells * 13 options for each cell: empty cell, 6 black and 6 white pieces.
return self._activations[68:900]BSD-2-Clause license