I was experimenting with the new generation of C compilers for the old 8 bit processors (6502, z80), and I note that I get a big speed improvement (around 3 fold) over earlier compilers for simple alpha/beta searches in 2 player games.
Is there a (relatively) good/reasonable C89/99 open source non bitboard chess program that can build and run in less than 64k, or even 32k/16k? Most of the minimal engines are really weak.
Its even an interesting idea for a competition, ie the strongest portable C program for an original 64k IBM PC, zx spectrum 48k, Commodore64, C16 or even a 5k Vic20!
I have my own simple engine, its very small but really it is weak, in particular it needs a better SEE implementation, dealing with quiescence. My engine allows variable board size, maybe a first for a 6502 program, but of course that makes it weaker still.
Ideas/thoughts welcome..
A good Small C chess program?
Moderator: Ras
-
orac81
- Posts: 4
- Joined: Sat Jul 13, 2024 2:19 pm
- Full name: Adrian millett
A good Small C chess program?
Orac/Sage/Dynamo: https://github.com/orac81/Orac-Draughts
-
smatovic
- Posts: 3753
- Joined: Wed Mar 10, 2010 10:18 pm
- Location: Hamburg, Germany
- Full name: Srdja Matovic
Re: A good Small C chess program?
I implemented 2011 a vanilla alpha-beta searcher with move ordering, qsearch, eval with 0x88 as board representiion on 6502 (Atari 800 XE) with 64KB RAM via CC65 and reached ~10 NPS. Perft showed some potential with ~75 NPS. I never had the time in spare to optimize further with a second look....
Vintage Chess Programming
viewtopic.php?t=40674
As for small engines in C, there are SCP, MCSP, TSCP, Micro-Max.
As for today, I would try to backport something like PeSTO with 0x88 board on 6502.
--
Srdja
Vintage Chess Programming
viewtopic.php?t=40674
As for small engines in C, there are SCP, MCSP, TSCP, Micro-Max.
As for today, I would try to backport something like PeSTO with 0x88 board on 6502.
--
Srdja
-
orac81
- Posts: 4
- Joined: Sat Jul 13, 2024 2:19 pm
- Full name: Adrian millett
Re: A good Small C chess program?
It is worthwhile recompiling your code with a more recent optimizing 6502 C compiler, like Oscar64, which can target the Atari800.
https://github.com/drmortalwombat/oscar64
In my test with a little 2 player game Sconnex, I get a 3 fold improvement over cc65, plus much smaller compiled code. See this thread at vcfed:
https://forum.vcfed.org/index.php?threa ... e.1254041/
You need to tweak code to use, for example, BYTE rather than int when possible, but big speedups are possible.
Another little example, Addix:
https://forum.vcfed.org/index.php?threa ... x.1257342/
Builds for 5k Vic20, a two player game with alphabeta search, has hires gfx, written in portable C.
https://github.com/drmortalwombat/oscar64
In my test with a little 2 player game Sconnex, I get a 3 fold improvement over cc65, plus much smaller compiled code. See this thread at vcfed:
https://forum.vcfed.org/index.php?threa ... e.1254041/
You need to tweak code to use, for example, BYTE rather than int when possible, but big speedups are possible.
Another little example, Addix:
https://forum.vcfed.org/index.php?threa ... x.1257342/
Builds for 5k Vic20, a two player game with alphabeta search, has hires gfx, written in portable C.
Last edited by orac81 on Sun May 31, 2026 3:28 pm, edited 3 times in total.
Orac/Sage/Dynamo: https://github.com/orac81/Orac-Draughts
-
smatovic
- Posts: 3753
- Joined: Wed Mar 10, 2010 10:18 pm
- Location: Hamburg, Germany
- Full name: Srdja Matovic
Re: A good Small C chess program?
Unfortunately I lost the source code of Zeta Vintage so I can't test the Oscar64 compiler, have to do a rewrite from scratch, IIRC I used the build in qsort of CC65, perft w/o move ordering was maybe ~200 NPS (no bulk counting), that number reflects a more reasonable implementation, or alike.
--
Srdja
--
Srdja
-
orac81
- Posts: 4
- Joined: Sat Jul 13, 2024 2:19 pm
- Full name: Adrian millett
Re: A good Small C chess program?
Thats a shame. If you have an exe maybe you can ask AI to regen the source! (can it do that yet?)
Orac/Sage/Dynamo: https://github.com/orac81/Orac-Draughts
-
mclane
- Posts: 18975
- Joined: Thu Mar 09, 2006 6:40 pm
- Location: US of Europe, germany
- Full name: Thorsten Czub
Re: A good Small C chess program?
There is also the TI99/4a that needs a new chess engine.
At least this is even a 16 Bit CPU.
the Texas Instruments TMS9900 CPU. It was the first 16-bit home computer on the market.
The commercial chess engine that was developed 1978 and came on the market 1979 is not very strong.
https://www.spacious-mind.com/html/texa ... chess.html
https://4apedia.com/index.php?title=Video_Chess
At least this is even a 16 Bit CPU.
the Texas Instruments TMS9900 CPU. It was the first 16-bit home computer on the market.
The commercial chess engine that was developed 1978 and came on the market 1979 is not very strong.
https://www.spacious-mind.com/html/texa ... chess.html
https://4apedia.com/index.php?title=Video_Chess
Last edited by mclane on Sun May 31, 2026 3:39 pm, edited 1 time in total.
What seems like a fairy tale today may be reality tomorrow.
Here we have a fairy tale of the day after tomorrow....
Here we have a fairy tale of the day after tomorrow....
-
smatovic
- Posts: 3753
- Joined: Wed Mar 10, 2010 10:18 pm
- Location: Hamburg, Germany
- Full name: Srdja Matovic
Re: A good Small C chess program?
I also have no binary anymore, I think I read somewhere about AI working directly with executables, dunno how far this goes meanwhile, using AI for disassembling.
***edit***
Just looked up my github on archive.org, surprisingly there are snapshots back to 2016, but that was after the data loss ~2013.
--
Srdja
-
orac81
- Posts: 4
- Joined: Sat Jul 13, 2024 2:19 pm
- Full name: Adrian millett
Re: A good Small C chess program?
If it was up on github, someone should have your program somewhere!
Anyway, as to my program, this is as far as I have got, with my small 16k chess program, NCHESS. Its open source, can play on boards 4x4 upto 12x10, and should build on any C compiler Eventually I will add the front end, but I want to improve the quiescence search.
https://github.com/orac81/miniapples/ra ... latest.zip
NCHESS
NCHESS is a simple/small open source Chess Program written in C. (C89/99) It can operate as an engine, or as a C console program. It can build on systems smaller than 64K, such as the Commodore 64/128, VIC20+16k, etc. There are compiled versions for CBM (.prg) Linux (.elf) and Windows (.exe) in this zip.
At time of writing it isn't strong compared to most modern programs, but I hope to improve playing strength with time. Having said that, the versions
for Linux/Windows will play OK-ish chess.
It is a "work in progress" beta version, expect bugs!
There will be a VTDL front end in due course.
COMMANDS
EXAMPLES
You can set parameters with the "/" command, so
/T2 sets 2 seconds per move
/T0 <ENTER> /D2 <ENTER> Sets fixed depth of 2 ply.
n6,6 sets a 6x6 board
n10,10 sets a 10x10 board
n8,6 set an 8x6 board
You can play a demo game just by hitting ENTER, ENTER, etc.
The source code is included in the zip (nchess.c, nchess.h). The file "maknosc.sh" will build the CBM .prg files with Oscar64 (VBCC or CC65 can also be used)
The file "makncc.sh" will build for Linux.
Released as free software under GNU GPL3 license.
Anyway, as to my program, this is as far as I have got, with my small 16k chess program, NCHESS. Its open source, can play on boards 4x4 upto 12x10, and should build on any C compiler Eventually I will add the front end, but I want to improve the quiescence search.
https://github.com/orac81/miniapples/ra ... latest.zip
NCHESS
NCHESS is a simple/small open source Chess Program written in C. (C89/99) It can operate as an engine, or as a C console program. It can build on systems smaller than 64K, such as the Commodore 64/128, VIC20+16k, etc. There are compiled versions for CBM (.prg) Linux (.elf) and Windows (.exe) in this zip.
At time of writing it isn't strong compared to most modern programs, but I hope to improve playing strength with time. Having said that, the versions
for Linux/Windows will play OK-ish chess.
It is a "work in progress" beta version, expect bugs!
There will be a VTDL front end in due course.
COMMANDS
Code: Select all
A#A# Make move (ie E2E4)
n[#,#] New game (Optional setting x,y brd size)
d Draw board
g Computer go (or just hit ENTER)
a Auto play
sFile Save pos to file
lFile Load pos from file
=FEN Set a FEN
#.. Assort Benchmark/tests..
/[A-Z]# Set/view params A..Z (/D#:set depth,/T#:sec/move,/R#:rand..)
x Exit
EXAMPLES
You can set parameters with the "/" command, so
/T2 sets 2 seconds per move
/T0 <ENTER> /D2 <ENTER> Sets fixed depth of 2 ply.
n6,6 sets a 6x6 board
n10,10 sets a 10x10 board
n8,6 set an 8x6 board
You can play a demo game just by hitting ENTER, ENTER, etc.
The source code is included in the zip (nchess.c, nchess.h). The file "maknosc.sh" will build the CBM .prg files with Oscar64 (VBCC or CC65 can also be used)
The file "makncc.sh" will build for Linux.
Released as free software under GNU GPL3 license.
Orac/Sage/Dynamo: https://github.com/orac81/Orac-Draughts