Sunday 26 November 2023

"O-Jello" by Clyde Perkins (1980)

This is a conversion to Micro Color BASIC of a game by Clyde Perkins for the Bally Arcade/Astrocade game console and early 8-bit home computer. The first "Bally BASIC" version appeared in the Arcadian 2, no. 5, March 24, 1980. The "AstroBASIC" version was released on the "Best of Arcadian, 1980" tape.  I took the source for my port from Arcadian Vol 5 No2, Dec 1982. Perkins' game is an early version of Othello or the game of Reversi with an AI opponent created in BASIC. It also allows for a game between two human players, and it does this on an MC-10 computer with only 4K of memory!  Amazing!

Thanks to the Bally Alley folks for their helpful playthrough:

https://youtu.be/DR6gyQvdR8I?si=LtfETxYljqeicxtL

There's nothing much to report about this port regarding differences in BASIC.  The only real bump regards the diabolically hard translation of AstroBASIC graphics, which are laid out as a grid with the 0/0 coordinates located at the centre of the screen.  The graphics are 160 by 88 pixels:

          44

           |

-80  ---  0,0  ---  80

           |

         -44

I had to do some fancy math to translate everything to a more common graphic grid starting in the upper left corner and then scale it for the MC-10 low res 64 X 32 Semigraphics-4 screen. Otherwise, BallyBASIC is pretty straightforward.  Quite nice in a lot of ways, although very memory restricted.  That's okay though, because it means we now have another board game to add to the BASIC Checkers sold by Tandy for the 4K MC-10. Source code can be found here:

https://github.com/jggames/trs80mc10/tree/master/quicktype/Board%20Games/OJello

I'll post an addendum here when I have a chance to think about the project a little more.

Addendum.

I think I found a bug in the original program.  When I printed the move-weighting table consulted by the AI via its lookup algorithm for reading the table data from a single index array this is what came out:

 5  3  99  2   2   99  3  5 

 15 8  2  -15  -15 2   8  15 

 0  1  15  0   0   15  1  0 

 9  5  8   1   1   8   5  9 

 9  5  8   1   1   8   5  9 

 0  1  15  0   0   15  1  0 

 15 8  2  -15  -15 2   8  15 

 5  3  99  2   2   99  3  5 

When my son Charlie came home for Christmas he looked at the routine that generates the table and also came up with this arrangement using a modern programming language.  It seemed obvious to us that the corners were what should be prioritized with the 99 weights and that there were other weird asymmetries going on. 

I'm not 100% sure if there is something I did in my port, or something different about the BASICs, which can account for this mixed up table.  Apparently Perkins worked from an article in Byte magazine, but we couldn't find anything in the earliest article from 1977 (see refs at bottom) presenting a BASIC version of Othello.  Eventually Charlie figured out that there was a problem with decimal points in the lookup algorithm in line 510 of our test routine below.  This test program includes Perkins' routine (56-57) for generating and storing the 8X8 weighting table in a single index array variable A(2-66) and then uses the lookup algorithm from the program (510) to consult every space on the 8X8 board using the coordinate system for plotting pieces (500):

REM Perkins' original table generating routine for populating the array 
0 DIMA(70):A(0)=-1:A(1)=-1:REM first two elements reserved for storing player scores
56 A(2)=3:A(3)=5:A(4)=1:A(5)=8:A(7)=9:A(8)=0:A(9)=15:A(12)=-15:A(13)=2:A(17)=99
57 FORX=0TO3:FORY=0TOX:FORZ=2TO50STEP16:FORW=1TO4STEP3:A(X*W+Y*(5-W)+Z)=A(X+Y*4+2):NEXTW,Z,Y,X

59 C=0:FORY=1TO8:FORX=1TO8:PRINTA(2+C);:C=C+1:NEXT:PRINT:NEXT:STOP

REM My modified lookup algorithm tailored for the MC-10 screen (jumps by 8s instead of 9s in the vertical) and with Charlie's -4 and -5 fudge factor)
500 FORB=28TO-28STEP-8:FORA=-35TO35STEP10
510 O=(ABS(B)-4)/8*4+(ABS(A)-5)/10+2+32*-(B<0)+16*-(A<0):R=A(O):PRINTR;:NEXT:PRINT:NEXT:PRINT

REM The original lookup and plotting algorithms 
500 FORB=-31TO32STEP9:FORA=-35TO35STEP10
510 O=ABS(B)/9*4+ABS(A)/10+2+32*-(B<0)+16*-
(A<0):R=A(O):PRINTR;:NEXT:PRINT:NEXT:PRINT
Here is the raw table data created by Perkins:


Here is how the table looks using the lookup algorithm with Charlie's -4 and -5 fudge factors, which he added to prevent decimal rounding errors in translating A and B coordinates into an index number for a  single dimension array:


His version produces something we think makes more sense for weighting and when I implemented it into the game and played against it, it played like a boss.  The following is me testing the new routine on high speed mode in the emulator:


Here is the result of another game with the new algorithm being played on Mike Tinnes online emulator: 
Charlie's algorithm for the win!

O-Jello can be played online using Mike Tinnes' JavaScript emulator hosted on my games site on GameJolt:


Just select "Play" from my game page, then select my "8-Bit BASIC A.I. Programs" collection and then select "OJELLO" from the Cassette menu and type RUN and hit Enter in the main emulator screen.  Feel free to list the program (it's really tiny) to see it for yourself in all of its under 4K glory. Only about 1800 bytes long.  I think  he might have been working from one of these:

  • Duda, Richard O (October 1977). "Othello, a New Ancient Game". BYTE: 60–62.
  • Wright, Ed (November–December 1977). "Othello". Creative Computing: pp. 140–142.
  • Frey, Peter W (July 1980). "Simulating Human Decision-Making on a Personal Computer". BYTE: pp. 56.

Addendum to the Addendum

In checking out Duda's article I thought I would try typing it in as well, and seeing what kind of game it plays.  Its algorithm is similar but simpler.  It counts up pieces that will be captured, but it only adds extra weight to such possible moves if they are along the outside edge.  There is no differential weighting of specific positions.  Still, it plays a pretty decent game.  Here's a squeaker, when I just manage to edge it out:


I should thank Peter McGavin from the facebook BASIC group, who noticed two  typos/transcription/OCR errors in the source code when I posted it in the group.

These were in line 3210, which should have read 2310
And 1410, which should have read 1310.

Both of these errors were in the original source which I worked from.  This source was from an article entitled "Analysis of the First Published Othello Game" by Timothy Swenson, which the author generously provided online.  It saved me a lot of typing, but it had some typos so I also fixed some other errors than those found by Peter. But with his corrections hopefully now it's fully working so people can try it out.

How to play

OTHEBYTE can be played at my GameJolt site under the "More 8-bit BASIC game ports" menu item.


Just select Play Game, "More 8-bit BASIC game ports", and then select OTHEBYTE from the Cassette Menu, and type RUN and hit Enter in the Main emulator screen.

Similarly OJELLO can be played as per the above. However it can be found by clicking the "8-Bit BASIC A.I. Programs" menu item.

No comments:

Post a Comment