Close

Random Thoughts

A project log for Commodore CHESSmate Reproduction

The plan is to make a reproduction of the dedicated chess computer CHESSmate released by Commodore in 1978.

michael-gardiMichael Gardi 02/15/2024 at 23:110 Comments

When I was looking at the opening book issue I read this in the little 8 page CHESSmate Operation Instructions:

CHESSmate contains a collection of 32 familiar chess openings. Out of these it chooses one at random and tries to follow it for 16 moves. 

It then lists the 32 openings by name.

What jumped out at me was "chooses one at random". I had not really noticed this. Sure enough if you push the following sequence of buttons on the original:

  1. NEW GAME
  2. H - ENTER (CHESSmate plays WHITE.)
  3. G - ENTER (CHESSmate moves)

CHESSmate will make the following opening moves (randomly ?) plus others:

Now it's hard to tell because it's random after all, but the moves tend to skew towards E2-E4 and D2-D4. That is to say that they seem to come up more frequently. The others much less frequently.

My reproduction only ever played E2-E4 when CHESSmate plays first.

So how is random working? I looked for other RRIOT reads happening around the same time as the opening book lookups. I noticed a read to the 8B0E register (labeled READ TIMER INTERRUPT) that I had assumed was to clear interrupts (since the current player was switching), but maybe is does more. I was always just returning FF from this read. 

On a hunch I started returning a random number between 0 and 31 inclusive instead and guess what, I'm getting random behavior now very similar to what is happening on the original machine. My guess is that the value being returned by the RRIOT is the "time" remaining before the next interrupt will be triggered.

I'm not going to overthink this. Random selection from the chess openings is working. 

That was the last item on my firmware TODO list. I believe at this point that I have a very accurate CHESSmate software experience. All that's left is to put the whole package together. For that I'll wait until my ESP-32 backpack daughter board arrives (it's in final inspection at the fabricator). Light at the end of the tunnel and all that.

Discussions