Hey everyone,
I was looking at Toledo tiny chess / nanochess stuff, and also things like ChesSkelet.
So in this weeks I wrote a small JavaScript chess program under 1kb. Not posting code yet because I still want to check some edge cases and clean it a bit.
It has clickable board, move generation, check/checkmate, castling, en passant, promotion, and basic engine play.
Do people still work on this kind of tiny chess engines?
Also, do you know any JS chess program under 1kb with UI + engine + legal moves? I am looking for prior art before making any bigger claim.
-Marcos
Are tiny chess programs still a thing? sub-1kb JS chess
Moderator: Ras
-
drogontargaryen
- Posts: 3
- Joined: Fri Dec 18, 2020 7:51 pm
- Full name: Marcos Gabriel Pazzarelli
-
ZirconiumX
- Posts: 1366
- Joined: Sun Jul 17, 2011 11:14 am
- Full name: Hannah Ravensloft
Re: Are tiny chess programs still a thing? sub-1kb JS chess
There is the TCEC 4 kilobyte competition. I'm working on an entry to it.
tu ne cede malis, sed contra audentior ito
-
drogontargaryen
- Posts: 3
- Joined: Fri Dec 18, 2020 7:51 pm
- Full name: Marcos Gabriel Pazzarelli
Re: Are tiny chess programs still a thing? sub-1kb JS chess
interesting, when is next tournament start? and where to send my engine ?
-
towforce
- Posts: 13142
- Joined: Thu Mar 09, 2006 12:57 am
- Location: Birmingham UK
- Full name: Graham Laight
Re: Are tiny chess programs still a thing? sub-1kb JS chess
This forum's analysis board (click on E8 in any of the positions in the PGN below) actually plays a decent game of chess. It was written by HGM - anyone know how big the chess engine in it is?
[pgn][Event "ChessGate Web Game"]
[Site "playchessgate.com"]
[Date "2026.06.01"]
[White "Player"]
[Black "Anthony Miles"]
[Result "*"]
1. e4 Nc6 2. d4 e5 3. d5 Nce7 4. Nf3 Ng6 5. a3 Nf6 6. Nc3 Bc5 7. Nd2 Nf4 8. g3 Ng6 9. Bc4 O-O 10. O-O c6 11. b4 Bd4 12. Bb2 cxd5 13. exd5 d6 14. Rb1 Bh3 15. Re1 Ng4 16. Re2 Qf6 17. Qe1 Rac8 18. Nb5 Bb6 19. a4 a6 20. Na3 Qf5 21. a5 Ba7 22. Bd3 Qf6 23. Kh1 Nxf2+ *[/pgn]
In a world in which a simple article in a newspaper will be the best part of a megabyte (because it's full of huge scripts doing goodness-knows-what!), a 1 kb program will load so quickly that nobody will even know that a chess engine has loaded.
Maybe a website that attracts intelligent people could add it at the end of a page as a cheeky enticement for people to say there longer!
[pgn][Event "ChessGate Web Game"]
[Site "playchessgate.com"]
[Date "2026.06.01"]
[White "Player"]
[Black "Anthony Miles"]
[Result "*"]
1. e4 Nc6 2. d4 e5 3. d5 Nce7 4. Nf3 Ng6 5. a3 Nf6 6. Nc3 Bc5 7. Nd2 Nf4 8. g3 Ng6 9. Bc4 O-O 10. O-O c6 11. b4 Bd4 12. Bb2 cxd5 13. exd5 d6 14. Rb1 Bh3 15. Re1 Ng4 16. Re2 Qf6 17. Qe1 Rac8 18. Nb5 Bb6 19. a4 a6 20. Na3 Qf5 21. a5 Ba7 22. Bd3 Qf6 23. Kh1 Nxf2+ *[/pgn]
In a world in which a simple article in a newspaper will be the best part of a megabyte (because it's full of huge scripts doing goodness-knows-what!), a 1 kb program will load so quickly that nobody will even know that a chess engine has loaded.
Maybe a website that attracts intelligent people could add it at the end of a page as a cheeky enticement for people to say there longer!
Human chess is partly about tactics and strategy, but mostly about memory
-
hgm
- Posts: 28510
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: Are tiny chess programs still a thing? sub-1kb JS chess
What you show is pgn4web, which is not mine. What I wrote is the Interactive Diagram below, a web applet for embedding diagrams in HTML pages. It can be configured for an extremely wide range of chess variants, and also contains a simple AI.
The whole script is 211KB, but most of it is not engine. It contains a rather extensive GUI, generators for interactive tables that can be used as external HTML elements elsewhere on the page (e.g. piece overview), a parser for the rules description of the variant, san generator and parser...
But even the AI is not particularly small in character count. For one it uses conventional lay-outing and long variable names. And it has to do far more than a program for playing orthodox Chess has to do. There is for example an extensive heuristic for determining the value of a piece with an arbitrary given move.
The whole script is 211KB, but most of it is not engine. It contains a rather extensive GUI, generators for interactive tables that can be used as external HTML elements elsewhere on the page (e.g. piece overview), a parser for the rules description of the variant, san generator and parser...
But even the AI is not particularly small in character count. For one it uses conventional lay-outing and long variable names. And it has to do far more than a program for playing orthodox Chess has to do. There is for example an extensive heuristic for determining the value of a piece with an arbitrary given move.
theme=MV
firstRank=1
files=8
ranks=8
useMarkers=0
Pawn::::a2-h2
Knight:N:::b1,g1
Bishop::::c1,f1
Rook::::a1,h1
Queen::::d1
King::::e1
ranks=8
useMarkers=0
Pawn::::a2-h2
Knight:N:::b1,g1
Bishop::::c1,f1
Rook::::a1,h1
Queen::::d1
King::::e1
-
drogontargaryen
- Posts: 3
- Joined: Fri Dec 18, 2020 7:51 pm
- Full name: Marcos Gabriel Pazzarelli
Re: Are tiny chess programs still a thing? sub-1kb JS chess
interesting, when is next tournament start? and where to send my engine ?ZirconiumX wrote: ↑Thu Jun 11, 2026 10:46 am There is the TCEC 4 kilobyte competition. I'm working on an entry to it.
-
towforce
- Posts: 13142
- Joined: Thu Mar 09, 2006 12:57 am
- Location: Birmingham UK
- Full name: Graham Laight
Re: Are tiny chess programs still a thing? sub-1kb JS chess
Thank you for clearing that up: I just had an interesting little game against the interactive diagram (had to end it before it concluded because it's getting late).hgm wrote: ↑Thu Jun 11, 2026 3:25 pm What you show is pgn4web, which is not mine. What I wrote is the Interactive Diagram below, a web applet for embedding diagrams in HTML pages. It can be configured for an extremely wide range of chess variants, and also contains a simple AI.
The whole script is 211KB, but most of it is not engine. It contains a rather extensive GUI, generators for interactive tables that can be used as external HTML elements elsewhere on the page (e.g. piece overview), a parser for the rules description of the variant, san generator and parser...
But even the AI is not particularly small in character count. For one it uses conventional lay-outing and long variable names. And it has to do far more than a program for playing orthodox Chess has to do. There is for example an extensive heuristic for determining the value of a piece with an arbitrary given move.
theme=MV firstRank=1 files=8
ranks=8
useMarkers=0
Pawn::::a2-h2
Knight:N:::b1,g1
Bishop::::c1,f1
Rook::::a1,h1
Queen::::d1
King::::e1
Human chess is partly about tactics and strategy, but mostly about memory
-
IanO
- Posts: 502
- Joined: Wed Mar 08, 2006 9:45 pm
- Location: Portland, OR
Re: Are tiny chess programs still a thing? sub-1kb JS chess
Good timing for asking that. The Season 30 4k tournament just finished. There have been about two seasons per year, so you have about six months to get ready for the next one. Most of the TCEC events are invitational, but they would probably welcome more entries for this small event (only seven 4k engines the last few seasons). Contact the admins on Twitch chat or their Discord.drogontargaryen wrote: ↑Thu Jun 11, 2026 6:43 pminteresting, when is next tournament start? and where to send my engine ?ZirconiumX wrote: ↑Thu Jun 11, 2026 10:46 am There is the TCEC 4 kilobyte competition. I'm working on an entry to it.
(As for the main topic, I've become addicted to making cute miniatures against Kilobyte's Gambit. Chess is so much easier at 3-ply and no king safety!)