
Cool Chess: a surprisingly full chess engine and graphical UI in one QB64 BASIC file
Hey r/computerchess,
I wanted to share a project I have been picking away at called Cool Chess (github link). It started as me messing around with QB64, then got somewhat out of hand and turned into a small self-contained chess program with a graphical board and a playable engine.
I am a chess player, not an engine programmer. I play on Lichess as JeffyJeff, and have followed computer chess off and on since the late 90s. I remember looking at Crafty’s source code in absolute awe back then, and later following all the Rybka drama as it unfolded. BASIC was also the first (and only) language I learned as a kid in the early to mid 90s, so this was partly an excuse to get back into it.
I used AI heavily as a coding partner on this. I am not pretending I sat down and wrote a chess engine from scratch in isolation. But I also did not just dump generated code into GitHub and call it a day. I have been testing, debugging, iterating, and trying to understand what the code is actually doing as I go. I definitely was not trying to make Stockfish in BASIC. Mostly I wanted to see how much of a real, playable chess program I could fit into one BASIC file.
The whole thing is self-contained. The board UI is in the source, and even the little pixel-art chess pieces are stored as DATA statements, so there are no external image files or assets.
The mouse input is probably the feature I am happiest with. You click a friendly piece and its legal quiet moves show up as dots, while capturable pieces get blue rings. Click a marked destination to make the move. You can click the same piece again or right-click to cancel, and you can flip the board. Mouse promotions default to a queen. You can also still type moves directly if you prefer, including e2e4, e2-e4, O-O, and e7e8q.
It has undo/redo (takeback!), hints, FEN display, PGN export, adjustable search depth, and a per-move time setting. Default depth is 5 ply, and you can set it from 1 through 10 with “depth n.” It handles castling, en passant, promotion, checkmate, stalemate, threefold repetition, the fifty-move rule, and the common insufficient-material draw cases.
Under the hood it is a small classical engine: iterative-deepening negamax with alpha-beta pruning, quiescence search, MVV-LVA capture ordering, killer moves, capped check extensions, a 64-bit Zobrist hash, and a fixed-size transposition table. The evaluation is basic but includes material, pawn structure, passed pawns, development/centralization, rook files, bishop pair, and king-placement terms.
I checked the move generator against initial-position perft through depth 4, plus several standard special-case positions involving castling, en passant, promotion, and checks. I also made a heavily commented tutorial version of the source, because I spent enough time relearning what all this engine terminology actually meant that I figured it might be useful to someone else.
The project is here:
https://github.com/jeffanderson253-sketch/coolchess
The Windows executable is unsigned and built through the project’s GitHub workflow, so SmartScreen or antivirus may treat it as an unknown publisher. (I SWEAR ON THE LIFE OF MY MOTHER IT IS NOT A VIRUS.) The full source is in the repository if you would rather inspect or compile it yourself with QB64.
I would genuinely appreciate feedback, especially from people who know computer chess or QB64 better than I do. I am particularly interested in small engine or evaluation improvements that would make it play a little sharper without turning the source into something impossible for a normal person to follow.