Oh no, another Blast from the Past: Resurrecting Greenblatt’s MacHack Chess Program with Python for PicoChess

249 views
Skip to first unread message

Dirk

unread,
Jul 5, 2025, 3:25:52 PMJul 5
to PicoChess

I have implemented a simulation of Greenblatts MacHack program in python with the help of the one AI or another ;-)


The following text and pictures have been created with the help of Gemini  as well ...


The MacHack VI Python Simulation


In the annals of computer chess history, few programs are as iconic—or as charmingly primitive—as  MacHack, the brainchild of MIT’s Richard Greenblatt. Developed in 1967, this PDP-6 assembly-language marvel was one of the first chess engines to trade blows with human players in formal tournaments. Now, over half a century later, I’ve brought this digital grandparent of modern engines back to life using  Python  and the mighty  python-chess library , wrapped in a modern UCI protocol shell. Let’s dive into this retro revival!  


Unknown-1.png


The Original MacHack: A 1960s Chess Revolutionary

MacHack wasn’t just a program—it was a statement. At a time when skeptics like philosopher Hubert Dreyfus argued computers could never truly master chess, Greenblatt’s creation proved them wrong. MacHack competed in human tournaments, even defeating a rated player in 1967 (take that, Dreyfus!). Its Elo rating? A modest  ~1200-1400 —roughly club-player level. But for 1967, this was *artificial intelligence* in action.  


How did it work?

-  Restricted width search : MacHack used a brute-force approach, evaluating every possible move up to a fixed depth/time (typically 3-4 plies). No fancy pruning or neural networks here—just raw computation but there was already a selective element to the search.  

-  Heuristic evaluation : Its board evaluation was rudimentary, focusing on material balance, piece mobility, and basic pawn structure. No endgame tablebases or king safety metrics!  

-  Assembly-language grit : Written for the PDP-6, MacHack squeezed performance from every byte. Greenblatt later claimed it could search  10 positions per second —a snail’s pace by today’s standards, but revolutionary for the 60s. 


Emulating MacHack in Python: Nostalgia Meets Modern Tooling


Recreating MacHack in 2024 required balancing historical accuracy with practicality. Here’s how it came together:  


1.  Python-Chess as the Backbone   

   The brilliant  python-chess library  handled move generation, legality checks, and board states—saving me from reinventing the PDP-6’s wheel. MacHack’s original evaluation logic was ported to Python, with tweaks to mirror its 1960s priorities (e.g., favoring central pawn advances and knight outposts).  


2.  The UCI Wrapper: Time-Travel Interface   

   To let MacHack play nice with modern GUIs like  Arena, PicoChess , or  Cute Chess , I wrapped it in the Universal Chess Interface (UCI)  protocol. Now, this senior citizen engine can trash-talk Stockfish 16 (or at least lose gracefully) in a GUI of your choice.  


3.  Simulating “Retro” Limits   

   To mimic MacHack’s hardware constraints, I throttled search depth to 5 plies and added artificial delays. Spoiler: On a modern CPU, it still thinks *instantly*.  


"But is it really the same?" you ask, your voice trembling. Friend, let me lay out the facts! This is not some pale imitation. This is a FRAME-BY-FRAME, HISTORICALLY-ACCURATE RECREATION!

Check the schematics!

  • THE SAME PDP-POWERED ALPHA-BETA SEARCH LOGIC! We've captured the cold, calculating core that made it a champion!
  • THE LEGENDARY SELECTIVE SEARCH! This is the secret weapon! The tournament-crushing {15, 15, 9, 9, 7…} formula isn't a suggestion, it's the law! It thinks like Greenblatt designed it to think!
  • AN INTELLIGENT QUIESCENCE SEARCH! It sees your cheap shots coming from a mile away! It dodges tactical traps with the cold precision that left its human opponents speechless!
  • A LIMITLESS TRANSPOSITION TABLE! The original's groundbreaking 32K memory is now a Python-powered leviathan! It remembers every move, every trick, every desperate gambit you throw at it!
  • AUTHENTIC OPENING STRATEGY! We've hard-coded the classic principles of development and king safety. It has more discipline than a drill sergeant and won't be tempted by your amateur shenanigans!


And the best part? NO MILLION-DOLLAR MAINFRAME REQUIRED!





Unknown.png



Why Bother? A Love Letter to Computational History

Modern engines like Stockfish or Leela Chess Zero are wonders of optimization and machine learning. But MacHack represents something purer: the  joy of early computational problem-solving . Its code is a time capsule of 1960s AI philosophy—proof that even simple heuristics, paired with determination, can breathe life into a board game older than the printing press.  


 Fun quirks of the emulation :  

- MacHack *hates* closed positions. Its evaluation struggles with locked pawn structures, often blundering in blocked middlegames.  

- It adores knights. Expect dubious “knight tours” to the edge of the board.  

- Time trouble? Not here. The original MacHack had no real-time clock management. But this emulation does..  



Play Against History   


Want to challenge MacHack yourself? Load it into PicoChess, set the engine level to “1967,” and prepare for a game that feels like teleporting to MIT’s AI Lab. You’ll witness:  


-  Blunders that make you cringe  (but remember: this program is older than *the moon landing*).  

-  Surprising flashes of cleverness , like tactical forks discovered through brute-force search.  

-  Nostalgic satisfaction  when it hangs its queen.  


Greenblatt’s program paved the way for Deep Blue, AlphaZero, and beyond. By emulating it with Python, we pay homage to the pioneers who, in the words of Alan Turing, built “a thinking machine” long before it was cool.  


IMG_8017.jpeg


The engine is implemented as python code (no executable) so you have to add it to PicoChess like the other script engines (Turing, Bernstein etc.)

If you don’t know how to do it wait and hope that Randy will eventually add the engine to his images…


Enjoy

Dirk


machack.zip

Johan Sjöblom

unread,
Jul 9, 2025, 6:15:10 AMJul 9
to PicoChess
Oh wow! What a great restoration. I have to test this as soon as I am back home at my computer.
Johan

Dirk

unread,
Jul 9, 2025, 6:45:38 AMJul 9
to PicoChess
Yes it's incredible what AI already can do by implementing requirements into a running program. I just entered  "The Greenblatt Chess Program.pdf“ and described our uci requirements and after some iterations I got this engine. I did not test it in all ways and of course could not reproduce 1:1 the old historic games 1:1 but the key elements of the MacHack algorithm should all be there (thats why it is only aa simulation instead of our retro emulation or 1:1 ported programs like Sargon, Awit, or Crayblitz).

I have created a new subdirectory under /picochess/engines/script_engines/ for machack and the python code and put the executable shell script into /picochess/engiese/aarch64/script/

sftp:pi@picochessweb2 - FileZilla 2025-07-09 12-39-16.jpg

And this is the engines.ini or favorites.ini entry:

[script/machack]
name = MacHack, 1967 by Richard Greenblatt
small = mach
medium = macHa
large = MacHack
web = MacHack 1967 by R. Greenblatt
elo = 1300
ponder/brain = n

Good luck playing against it!
Dirk

Dirk

unread,
Jul 9, 2025, 7:02:31 AMJul 9
to PicoChess
The Greenblatt Chess Program as pdf:

https://dl.acm.org/doi/10.1145/1465611.1465715

Johan Sjöblom

unread,
Jul 9, 2025, 8:34:05 AMJul 9
to PicoChess
I have not googled or followed any links here yet, but I am curious to if the original PDF 6 macroassembler code is still readable? I am old enough and have done assembler programming in the early 80s...
Johan

Dirk

unread,
Jul 9, 2025, 9:37:51 AMJul 9
to pico...@googlegroups.com, PicoChess
At least you can still play against the original MacHack on a PDP 10,emulation:

 
And there’s eben a GitHub rep. for the PDP 10 containing McHack….


Am 09.07.2025 um 14:34 schrieb Johan Sjöblom <messi...@gmail.com>:

I have not googled or followed any links here yet, but I am curious to if the original PDF 6 macroassembler code is still readable? I am old enough and have done assembler programming in the early 80s...
--
You received this message because you are subscribed to the Google Groups "PicoChess" group.
To unsubscribe from this group and stop receiving emails from it, send an email to picochess+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/picochess/0df23ec7-70f5-4a90-8cbd-0f2352f9f40cn%40googlegroups.com.

RandyR

unread,
Jul 13, 2025, 6:21:51 PMJul 13
to PicoChess
It looks like MacHack doesn't like under-promotion? or is this something else? Here's the game:

1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 4. a3 Nf6 5. Nc3 Ng4 6. O-O Bxf2+ 7. Rxf2 Nxf2 8. Kxf2 O-O 9. Kg1 Qe7 10. b4 Qf6 11. Nd5 Qd6 12. Bb2 Re8 13. Ng5 Rf8 14. Qh5 Qg6 15. Qh4 Rb8 16. b5 Qh6 17. Qxh6 gxh6 18. Nf3 Na5 19. Ne7+ Kh8 20. Bxe5+ f6 21. Bxc7 Re8 22. Bxb8 a6 23. bxa6 Nxc4 24. a7 Rxe7 25. a8=Q Kg7 26. Bc7 Nxd2 27. Nxd2 Re8 28. Re1 Rh8 29. Nc4 b5 30. Nd6 Rg8 31. Nxc8 b4 32. axb4 Kh8 33. e5 f5 34. e6 d6 35. e7 Kg7 36. Bxd6 Kf6 37. Qa6 Kg5 38. Be5 Rg6 39. Qd3 f4 40. Bxf4+ Kf6 41. e8=N+

After I under-promoted, MacHack didn't respond and I won on time. There wasn't an error in the log file. Running from the command line:

pi@picochess:/opt/picochess/engines/aarch64/script $ ./machack
uci
id name MacHack VI Simulation
id author Gemini & Molli & Richard Greenblatt (Inspiration)
option name Search Depth type spin default 6 min 1 max 20
option name Full Width Search type check default false
option name Ignore Time type check default false
uciok
position fen 2N5/4P2p/5krp/8/1P3B2/3Q4/2P3PP/4R1K1 w - - 1 41 moves e7e8n
go movetime 10000
info depth 1 score cp -2145 nodes 224 nps 477 pv f6f7
info depth 2 score cp -2390 nodes 746 nps 370 pv f6f7 d3f5
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/home/pi/.pyenv/versions/3.9.2/lib/python3.9/threading.py", line 954, in _bootstrap_inner
    self.run()
  File "/home/pi/.pyenv/versions/3.9.2/lib/python3.9/threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/picochess/engines/script_engines/machack/machack.py", line 439, in _search_thread_target
    best_move, ponder_move = self.searcher.search_root(self.board, search_depth_limit, time_to_think, start_time)
  File "/opt/picochess/engines/script_engines/machack/machack.py", line 328, in search_root
    self.engine.send(f"info depth {depth} score cp {int(score)} nodes {self.nodes_searched} nps {nps} pv {pv_str}")
OverflowError: cannot convert float infinity to integer

Then I hit Ctrl-C to get back to the prompt:

^CTraceback (most recent call last):
  File "/opt/picochess/engines/script_engines/machack/machack.py", line 484, in <module>
    engine.uci_loop()
  File "/opt/picochess/engines/script_engines/machack/machack.py", line 355, in uci_loop
    line = sys.stdin.readline().strip()
KeyboardInterrupt


Randy

Dirk

unread,
Jul 14, 2025, 3:52:57 PMJul 14
to PicoChess
Oh - I guess that means that MacHack was not able to and hence did not accept under promotions ;-)

I talked with Gemini Pro about this and it could find and hopefully correct the bug (and its is one of course!).

Here is the updated source code ...

Happy under promoting!

Dirk

machack.py.zip

Randy Reade

unread,
Jul 14, 2025, 4:11:48 PMJul 14
to pico...@googlegroups.com
Thanks, Dirk. I'll test it soon.

Randy

RandyR

unread,
Jul 15, 2025, 10:54:14 AMJul 15
to PicoChess
Works fine, Dirk.

I have updated my images with the fixed version. See here for the links.

Randy
Reply all
Reply to author
Forward
0 new messages