Playing Chess Against Your Printer, With PostScript

Can you play chess against your printer? The answer will soon be yes, and it’s thanks to [Nicolas Seriot]’s PSChess. It’s a chess engine implemented in PostScript, of all things. It’s entirely working except for one last hurdle, but more on that in a moment.

What’s it like to play PSChess? Currently, one uses a PostScript interpreter (such as GhostScript) to run it, much like one would use the Python interpreter to run Python code. The user inputs moves by typing in commands like d2d4 (representing a piece’s source coordinate and a destination coordinate on the 2D board). Then the program makes a move, and outputs an updated board state to both the console and a PDF document. Then it’s the user’s turn again, and so on until somebody loses.

The chess parts are all working, but there’s one last feature in progress. The final step of the project is to enable PSChess to be run directly on a printer instead of using GhostScript as the interpreter. Intrigued? You can find the code at the project’s GitHub repository.

So why PostScript? While it is a Turing-complete stack-based interpreted language, it was never intended to be used directly by humans. There are no meaningful development tools to speak of. Nevertheless, [Nicolas] finds PostScript an appealing tool for programming projects and provides tips and techniques for like-minded folks. One of the appeals is working within constraints to solve a problem, just like implementing a chess engine in only 4k, or draw poker in 10 lines of BASIC.

Hackaday Links Column Banner

Hackaday Links: January 7, 2024

Oh, perfect — now our cars can BSOD. At least that’s how it looks from a forum post showing a Blue Screen of Death on a Ford Mustang Mach E, warning that an over-the-air software update failed, and now the car can’t be driven. The BSOD includes a phone number to reach Ford’s Customer Relationship Center and even presents a wall of text with specific instructions to the wrecker driver for loading the bricked vehicle onto a flatbed. Forum users questioned the photo’s veracity, but there are reports of other drivers getting bricked the same way. And we’ve got to point out that even though this specific bricking happened to an EV, it could just have easily happened to an ICE vehicle too; forum members were particularly prickly about that point. It would be nice if OTA software updates on vehicles could always roll back to the previous driveable state. Still, we suppose that’s not always possible, especially if memory gets corrupted during the update. Maybe the best defense against a bricked vehicle would be to keep a beater around that doesn’t need updates to keep running.

Continue reading “Hackaday Links: January 7, 2024”

The Quaint History Of The Commodore ChessMate

The Commodore International of the 1970s was a company which dabbled in a bit of everything when it came to consumer electronics, with the Commodore ChessMate being a prime example of the circuitous way that some of its products came to be. Released in 1978, its existence was essentially the result of MOS Technology releasing the KIM-1 single board computer in 1976. In May of that year, [Peter Jennings] traveled all the way from Toronto, Canada to Cleveland, USA to attend the Midwest Regional Computer Conference and acquire a KIM-1 system and box of manuals for a mere $245. On this KIM-1 he’d proceed to develop his own chess game, called MicroChess, implemented fully in 6502 ASM to fit within the 1 kB of RAM.

As one of the first major applications to run on the KIM-1, it quickly became an international hit, which caught the attention of Commodore – which had acquired MOS Technology by then – who ended up contacting [Peter] about a potential chess computer project. This turned out to based on the custom MOS 6504 CPU, while sharing many characteristics with the KIM-1 SBC. Being a MicroChess-only system, the user experience was optimized for more casual users, with the user manual providing clear instructions on how to start a new game and how to enter the position of a newly moved piece, along with no less than eight difficulty settings.

If you’re feeling like making your own ChessMate, or want to dig into the technical details, this excellent article by [Hans Otten] has got you covered.

Top image: Commodore ChessMate Prototype in 1978. (Credit: Peter Jennings)

(Thanks to [Stephen Walters] for the tip)

The Chess Computer From 1912

Who was [Leonardo Torres Quevedo]? Not exactly a household name, but as [IEEE Spectrum] points out, he invented a chess automaton in 1920 that would foreshadow the next century’s obsession with computers playing chess.

Don’t confuse this with the infamous Mechanical Turk, which appeared to be a chess computer but was really a guy hiding inside a fake chess computer. The Spanish engineer’s machine really did play a modified end game. The chessboard was vertical, and pegs represented pieces. There were mechanical arms to move the pegs. The device actually dates back to 1912, with a public demonstration in Paris in 1914. Given [Quevedo’s] native language, the machine was called El Ajedrecista.

Continue reading “The Chess Computer From 1912”

A Chess AI In Only 4K Of Memory

The first computer to ever beat a reigning chess world champion didn’t do so until 1996 when a supercomputer built by IBM beat Garry Kasparov. But anyone who wasn’t a chess Grandmaster could have been getting beaten by chess programs as early as 1979 when Atari released one of the first ever commercially-available chess video games for the Atari 2600. The game was called Video Chess and despite some quirky gameplay it is quite impressive that it was able to run on the limited Atari hardware at all as [Oscar] demonstrates.

The first steps of getting under the hood of this program involved looking into the mapping of the pieces and the board positions in memory. After analyzing some more of the gameplay, [Oscar] discovered that the game does not use trees and nodes to make decisions, likely due to the memory limitations, but rather simulates the entire game and then analyzes it to determine the next step. When the game detects that there are not many pieces left on the board it can actually increase the amount of analysis it does in order to corner the opposing king, and has some unique algorithms in place to handle things like castling, finishing the game, and determining valid movements.

Originally it was thought that this engine couldn’t fit in the 4K of ROM or work within the 128 bytes of system memory, and that it was optimized for the system after first developing a game with some expanded capabilities. The game also has a reputation for making illegal moves in the higher difficulty settings although [Oscar] couldn’t reproduce these bugs. He also didn’t get into any of the tricks the game employed just to display all of the pieces on the screen. The AI in the Atari game was a feat for its time, but in the modern world the Stockfish open-source chess engine allows for a much more expanded gameplay experience.

Wood game piece being carved by a CNC mill with a hacked rotary axis

This $12 CNC Rotary Axis Will Make Your Head Spin

[legolor] brings us a great, cheap rotary axis to add to your small 3 axis CNC mills. How are you going to generate G-Code for this 4th axis? That’s the great part, and the hack, that [legolor] really just swapped the Y axis for the rotation. To finish the workflow and keep things cheap accessible to all there’s a great trick to “unwrap” your 3D model so your CAM software of choice thinks it’s still using a linear Y axis and keeps your existing workflow largely intact. While this requires an extra step in Blender to do the unwrapping, we love the way this hack changes as little of the rest of your process as possible. The Blender script might be useful for many other purposes too.

Wood game pieces carved from wood by a CNC mill with a hacked rotary axis

The results speak for themselves too! We thought the 3D printed parts were suspect in a CNC setup, but for the small scale of game pieces and milling wood, the setup is stable enough to produce a surprisingly accurate and detailed finish. If you want to try the same approach with something larger or a tougher material, [legolor] has a suggestion of a tailstock setup that’s still under $100 USD. Continue reading “This $12 CNC Rotary Axis Will Make Your Head Spin”

A metal watch is held in a man's fingers. The watchface has a laser etched chess board with miniature chess pieces made of brass enacting a match. The time is told on an etched chess clock to the right hand side of the timepiece and a small window on the rightmost "clock" shows the date.

A Little Chess With Your Timepiece

Some things remain classics, even after centuries, and chess and watches have certainly stood the test of time. [W&M Levsha] decided to combine them both in this “Chess Club” watch containing a miniature chess game frozen in time.

[W&M Levsha] used an off-the-shelf wristwatch for the mechanism and case, but rearranged the parts and built a custom watchface that’s much nicer than the original. The new watchface was cut and etched on a fiber laser after disassembly of the original watch.

The real magic happens when [W&M Levsha] turns those teeny little chess pieces on the lathe. The knight was a two piece affair with the horse head being laser cut out of brass sheet and then soldered onto a turned base. As you can see from the video embedded below, all of the chess pieces inside the watch could fit on the maker’s fingernail! It’s probably a good thing that this tiny set isn’t playable since trying to play on a board that size would be an exercise in patience.

We’ve seen machined chess sets here before at a larger scale, but if you’re more into 3D printing, how about teaching your printer to play?

Continue reading “A Little Chess With Your Timepiece”