Friday, 21 January 2022

Debugging Old BASIC Games with Neat AI Opponents


It started with an email from Greg Dionne that he had triggered an error in my ACHESS program with these moves:

Choose "0"
Then do the following moves:
E2 E4
B1 C3
G1 F3
D2 D3
C1 C2
OO

It gave a ?BS ERROR IN 4200.

This got me looking at the program again. First thing I did was rename and move AChess to CChess, since this title had been bugging me a little. I had initially called the the program AChess because it was written in Apple Integer Basic, but the programmer had titled the program "Computer Chess" so I thought I should rename it and put it in a renamed directory reflecting its internal title:

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

I think the error Greg noticed was a problem in the original program. It didn’t clear some variables used in the input routine until after the branch taken by the “OO," which left those variables in states that couldn’t be handled by the 4200 routine, which was called after the return from the input routine after an "OO" is entered, but before the initiation of the "castling function," which would set those variables to some specific values.  Or so I think after having tried to chase down the assignments of all the variables involved that were causing the error and comparing them to the original code. Nothing would seem to account for them being miss-assigned. But by simply zeroing them before the check for the input of “OO”, since they were zeroed right after that branch anyway for processing the input of regular moves, the problem went away. As I said, those particular variables would eventually be set to specific values by the castling routine, but before that routine was reached after the return from the input routine, flow had to get past a call to 4200 (basically a routine subroutine needed to display pieces in their designated new locations).

I was a little surprised that such an error might have existed in the code, since after a little investigation I discovered that the programmer Mark Watson had made the program back in 1978, and it had been distributed on a sample disk by Apple. He apparently was programmer who made contributions to AI and computer game development.  Perhaps Integer BASIC is more tolerant of array variables going out of range or something like that, so it might never have triggered a catastrophic error.  It was neat to discover that the code was an interesting contribution to early chess AI coding in BASIC.  Hopefully, it is a program more people will try out now.  My impression is that getting an Apple emulator up and running to run the early Integer BASIC can be a bit of a challenge, so it might be helpful having it converted to Micro Color BASIC.

In the midst of conversing with Greg about this minor bug, he also pointed out another in another program I had converted from a while back:

Hi Jim!...noted a few funnies in OTHO36.TXT
* line 1350 when using MID$ .. an extra ')' in front of the ",2".
* line 1440. extra parenthesis.
 
There were definitely typos there. Not sure if they were fatal in Coco BASIC, but in the MC-10 they certainly triggered errors under certain somewhat rare circumstances. I also found another error in line 1430.  The assignment of the array variable had a 9 instead of a right bracket for the array variable.  That definitely caused an error.  So I looked back at the original source (from the Coco archive) and all the errors were there in the original source.  So I decided to look at the code more closely, since I now suspected that my conversion had involved too little checking.

I found a few more quirks.  Not major errors, but obvious oversights by the programmer, probably just because he didn’t have the luxury of a full screen editor view of the code.  The message to display “THE COMPUTER WINS” for example, didn’t work.  The IF checked an incorrect variable.  Stuff like that.  Also, in two player mode, there was no win check for the two human players.  They would have to both agree when someone had won and then break out of the program and type RUN to start a new game. So I added a quit option so that players could more neatly begin another match.  I also modified the “THINKING” flashing message as I found it too flickery. I added some speed-ups, such as converting IF AND constructs to IF THENIF constructs.

OTHO36 is by Alain Dussault from 1982. It's an Othello game that plays a very strong game, at least from my limited experience as player.  Like CCHESS it is another interesting example of an AI opponent programmed in BASIC in the early days of 8-bit computing.  I really hope people will give it a try and that my edits might help folks to have a less frustrating experience with it.  They mostly involve dummy proofing.  For example, I discovered an error that I think would only happen if you triggered two consecutive input errors (move onto an existing piece, move to an invalid location) on the first move of the game. Unlikely and rare, but nice to get rid of it.

I hope I have actually improved these two neat programs, and not actually damaged them in some way.  They can be played here under the "Classic 8-bit Games" and the "Other 8-Bit Basic Game Ports" menu selections after you choose "Play Game": https://gamejolt.com/games/jgmc-10games/339292

Thursday, 13 January 2022

Galactic Hitchhiker by A. Knight (1980)


I've made a recoding in Micro Color BASIC (for the TRS-80 MC-10) of the text adventure "Galactic Hitchhiker" (1980) for the Compukit UK101.

Gareth Pitchford (I'm assuming it's him based on his avatar pic from on CASA and Facebook) gave me the idea in a post over on the CASA Adventure archive forum.  He noted that it was an important landmark game; one of the very first original British authored "home computer" text adventures.  Unfortunately, it was for a very early 8-bit computer system, the Compukit UK101, which was a unique variation of the Compukit line from America. As a fairly rudimentary system, it was a little more difficult to operate than later home computers and modern emulation can pose some difficulties for the uninitiated.  He suggested that if I was looking for adventures to convert or "fix up", this might be a good one to try.  He was right.

He set me on to a page he hosts "8bitAG" with a write-up about the game and a walkthrough and map by benkid77: http://8bitag.com/info/galactic.html

Benkid's walkthrough provided me with invaluable information, especially the video.  I used Gareth's page to find my way to the hex file of the original program. I was able to download it and then convert the hex listing to ASCII characters, which produced something like this:
NORTHEASTSOUTHWESTUPDOWNSTARTGOGETDROPTAKEWAVEPUSHPULLDON'TSHOOTCHOPCUTFEEDOPENGERBICOPJOLLY GERB GIANTGHOULIBRUTESPACE RANGERTREE ACROSS THE RAVINEDOORBUTTONLEVERFENCETREEPANICJUGBLASTERCHOPPING-AXEWIRE-CUTTERROAST JOINTKEYPIT-PROPTATTY OLD SCARFTICKETRUCKSACKSCORE
I'M IN A

NOW WHAT SHOULD I DO? I CAN'T. I'M CARRYING ENOUGH ALREADY.
THERE IS A HERE. I DON'T UNDERSTAND.I CAN'T GO IN THAT DIRECTION.GO WHERE? WHAT?
OKAY, NOW WHAT?
A GREAT IDEA! HOW? WHAT ? DEAD I CAN'T.

SPIKE HERE: YOU GOT LUCKY, MAN.AW, REAL COOL BABY.FANTASTIC! HE'S ON GRECIAN 2000.AMAZING, MAN!YOUR SCORE ISHE'S GETTING DRUNK!

ANOTHER TRY (Y/N)?

I'M IN A GIANT INDUSTRIAL COMPLEX. THERE ARE
PIPES LEADING EVERYWHERE AND HUNDREDS OF
ENORMOUS STORAGE TANKS.
I'M IN A DESERT OF GREY ASH. THE TWO SUNS OF
GOMERIL BEAT DOWN MERCILESSLY AND SCAVENGER
BIRDS ARE CIRCLING OVERHEAD.
A MASSIVE EARTHQUAKE IS SHAKING THE BUILDING.
I CAN FEEL ANOTHER EARTH TREMOR.
THE SHIP'S GONE! THE WHOLE PLACE IS BLOWING
UP AND THE BLOODY SHIP'S GONE!AW, POOR OLD MO.HE'S BEEN ELECTROCUTED!DON'T BE SILLY!HE'S BEEN DEADED. HOW SAD.
This gave me all the messages and room descriptions. Then I just had to use my go-to BASIC text adventure engine, "Tower of Mystery," which was provided as an example in Compute's Guide to Text Adventures (1984). It has all the standard commands for handling all the functions of most BASIC 2-word text adventures.  I just stripped out the "Tower of Mystery" stuff, and put in the room descriptions from the hex dump converted to DATA strings.  Then I just had to figure out the directional relationship (N/S/E/W/U/D) between all the rooms working from the video walkthrough provided by benkid. From that and the printed walkthrough I was able to come up with a map like this:




Obviously, the maps have had a lot of erasing and editing from my original crappy versions. The room numbers are mine, from the reprogramming process, but because I didn't disturb the original order too much (except for the first few room descriptions), you can discern the mapping of the author. The rooms are arranged in a grid (roughly 5X4) of 4 "levels" corresponding roughly to 4 main episodes/locales in the game.  Another interesting structure I stumbled across involved the scoring (although this may not correspond to the original). There appear to be 10 main puzzles/milestones in the game, which boil down to this list:
  1. OPEN DOOR (to get to the escape craft)
  2. CHOP TREE (to get to Gerb City)
  3. CHOP GERBICOP (to get the scarf)
  4. CUT FENCE (to get to the Spacetran)
  5. PUSH BUTTON (to escape the Spacetran)
  6. WAVE SCARF (to get rescued and taken to Gomeril)
  7. FEED GHOULIBRUTE (to get blaster to shoot Ranger)
  8. SHOOT RANGER (to get into the Time Corp building)
  9. DON'T PANIC (to get into the Time Machine)
  10. PULL LEVER to return to the beginning where you must GET TICKET and then get to the Starliner in time (to win).
Not sure if this corresponds to the original, but I like its simplicity and the fact that if you give each step a weight of 10, you get a kind of percent meter to gauge your progress to completion.

My reconstruction of the directional information is made just from posted walkthrough's and analysis of my evolving maps. There might be some differences in the original in certain areas where the walkthroughs didn't go. I invite anyone with in depth knowledge to try it and then let me know if they can find any major differences. HITCHHIK can be played here: https://archive.org/details/@james_gerrie

In particular, I have simply speculated about the wandering that might be present in the "Desert of Grey Ash" map, particularly around rooms 51 and 49.  It was also just from the apparent arrangement of room numbers that I have put the "Theatre" (Room 15) from the City of Gerb where it is.  

It is also speculation on my part that there is a count-down on the first map, and that the player has a limited number of moves before the planet blows up.  This is currently set to 30 moves.  I'm not sure if this is a fair amount for a first-time player.  When you return to the beginning by way of the time machine you get 20 moves to get to the Spaceliner to complete the game.  I tried this, and if you make a mistake like forgetting to pick up the ticket, you wont make it back to the Lounge and then back to the Liner to escape before the planet blows.  Again, I don't know if this is fair, or even like the original.

There is also some guess work on my part about the deaths. The video walkthrough provides some hints about these, as do the messages from the original code.  But there is still some speculation involved on my part.  Some deaths might be missing.

In any case, I don't think any of my speculations are weird. They make for a pretty standard game like any of that time period.  So my version might not be a perfect recreation, but then again maybe a slightly altered version might not be that bad, especially for those wanting to revisit the game. But I still would appreciate any comments that might allow me to improve fidelity. Then again, many of the commentaries I read about the game, such as Renga in Blue's (who also provided a useful partial map), note that the original (probably because of memory limitations or because the genre was still so young) had some annoying traits. There was no LOOK command. There was no INVENTORY command.  There were no shortcuts for the directions. These have all been fixed.  An EXAMINE command has also been added, along with other niceties curtesy of the Tower of Mystery engine.

I hope some folks who wouldn't have had an opportunity to play this quirky game now will be able to try it. It's a wonderful parody/homage to the Hitchhiker 's Guide to the Galaxy franchise by Douglas Adams, with a little reference to Dr. Who thrown in for good measure.  Spike is Ford Prefect. Maurice is Arthur Dent. Marina is Trillian. You can get a taste for the sense of Knight's humorous take on these characters from the intro screen:



Enjoy.  And please comment.


ADDENDUM

I realized after watching my own video walkthrough that the Tower game engine was using the phrase "You see" as part of its description.  However, in the original game the references to the main character are always in the form of "I" references coming from Maurice, with the player being the "You" who is recommending actions to him as a helper per Spike's initial request to "help him" get home (or controlling him a la Scott Adams' "puppet" metaphor for the dynamic between player and character in text adventures). So, for example, Maurice refers in several places to "You" such as in the desert, where he asks "Have you got me lost?"  So I cleaned up all the references to "you" coming from the parser that were referring to the player, and switched them to "I" references, such as "I see" "I'm carrying" and "I can't", which refer to Maurice the character and what he is experiencing.  This convention is an indication that this text adventure is a very early one (for Britain) and that such conventions were still fluid.

I also added the ability to get an INVENTORY by typing "OPEN RUCKSACK" to be like the original and fixed a misplaced comment from Spike.  He says "Cool baby" when you are ejected into open space, rather than when you get to the final elevator, which had been a complete speculation on my part.  It's much funnier as a comment when Maurice is floating in open space.  I also fixed it so you die if you don't wave your scarf in open space, rather than simply being left in a room with no exits.

P.S.

With the help of Gareth's page I finally got the Compukit emulator up-and-running and played through to the Desert region.  I was able to figure out the rooms in the 49-51 grouping.  I realized that I had left out and combined a number of room descriptions.  I was able to restore the original map, but I had to add 3 new rooms.  In the course of making that change, I was able to consolidate the repeating Desert description, so it used a single string for the initial part of all the desert room descriptions. This saved a bunch of memory, so I was able to go back and fix up some things and make some minor additions to the program.  I had been somewhat constrained because I was reaching the max of memory.  I noticed a misspelling of "corridoor," which I changed to "corridor."  I added a description to the EXAMINE function that notes that the axe is for chopping trees, since Renga in Blue had complained that there was no specific reference to TREE as an object in the game. I also made it deadly to try to kill the Jolly Gerb Giant or the Ghoulibrute, since there are plenty of warnings about Ghoulibrutes (and who attacks a giant!). I also made the Ghouilbrute disappear after you feed him, since I noticed that happened while playing the original. And I made Maurice's complaint that "the whole place is blowing up..." disappear after your reach the lift to the Starliner the first time. Seemed a bit excessive to have it repeated ever time you enter the room, and the original game removed it.  Anyway here's the new desert map:




Saturday, 8 January 2022

Simple 5-Heuristic Chess by Mark Watson

An idea I had for some simple chess pieces using SG6 mode got me looking for more chess source code on the Net that I might be able to use to implement them.  Here is a rough mock-up of what I had in mind.

Pawn Rook Knight Bishop Queen King

I came across a neat little program:

12000 REM SIMPLE-5 HEURISTIC CHESS BY MARK WATSON

Ported to Micro Color BASIC for the TRS-80 MC-10. It's a fairly tough little program, at least for an extremely casual player like me, although I do get it in the end. There is no wrong move detection, so I could have cheated without knowing it. Let me know if you spot anything fishy. See here for info about the original: https://games.slashdot.org/story/15/01/28/0148234/computer-chess-created-in-487-bytes-breaks-32-year-old-record

Here's me playing the game:


Here's me winning:


I might try converting the code to use my SG6 chess pieces if I'm really bored.  Or perhaps pitting this game against one of my other chess programs.

Here's a mock-up of what my SG6 chess board might look like:




Wednesday, 5 January 2022

The "Four" Colours of SG6 Mode

On Cocotalk last week L. Curtis Boyle mentioned my "Tank Capture" port (from a TRS-80 Model 1/3 game) and noted the "stripy" green characters left as trails behind the tanks.  I made a short video about these green characters.  Not all the “undefined” characters (0-127) from the MC6847 SG6 character set appear as “stripy” characters.  Two characters (ASCII characters 0 and 85) appear as solid dark green and solid light green characters on real hardware, probably due to some NTSC artifact effect. You can see them in the video (the dark green block on the last few seconds is one of the target blocks).  In many of my SG6 games I use these two characters to provide some visual variety to the otherwise limited RED/BLUE semi-graphic block characters.

Flywheel with light green sky and dark green wheels

XRally with dark green fuel bar and light walls.

From what I have been told, the 0-128 characters of the character set in SG6 mode are a result of the fact that the lines for the MC6847 VDG chip are not wired up fully for that mode.  Other computers like the NEC PC6001 do wire up the VDG to exploit all its abilities.  You can see that demonstrated here:

The NEC PC6001 really pushes the VDG to its max.

You can see that there are actually 4 semigraphic block colors available and text mixed in, so how the VDG is wired up can be much more complex. It's interesting to think about what the possibilities would have been for games if some extra wiring had been added to the MC-10 to exploit those modes to their maximum.


Monday, 3 January 2022

Greg Hassett and Other Text Adventure Games

I generally only upload games to my Retrogame site that I have confirmed the distribution status with the owner of the copyright.  However, one of the people it has been difficult to find extensive biographical information about in order to try to make contact with is Greg Hassett. Many commentator's note that Mr. Hassett started programming at the age of 12 and that he was very prolific [1][2]. But it is unclear what happened to him after his contribution to the early age of home computing. But I've noticed that some people might already have been using one of my early games distributions to examine one of his games, such as:

https://www.retrogamestrove.com/game-15-king-tuts-tomb/

I've also been contacted by a number of people wanting to play this game from my faculty site, so I have decided to upload his games to the Internet Archive so these people can access them, at least for an indefinite time. If anyone out there knows anything about the copyright status of these games, please contact me.

I have already ported the following games by Hassett:

  • The House of Seven Gables
  • Journey to the Center of the Earth
  • Sorcerer's Castle Adventure
  • King Tut's Tomb
  • Voyage to Atlantis
  • Enchanted Island

I am now in the process of considering converting some of Hassett's games to Micro Color Basic, so that people will have easy online access to the works of this important contributor:

  • Mystery Mansion
  • World’s Edge
  • Curse of the Sasquatch
  • Devil's Palace

I have listed them in order of my priority for porting. When I have finished any of these conversions I'll also make them available. I'll take them back down by April 2022.  Let me know if you have any thoughts on the priority.

I've also stumbled across a neat publication: Captain 80 BASIC Adventures. It has a huge list of classic text adventure games, many I have already converted to Micro Color BASIC (See the ones with *s).

Chapter 1 Atlantean Odyssey Teri Li 37
Chapter 2 Dog Star Lance Micklus 87 *
Chapter 3 Thunder Road Don & Freda Boner 97
Chapter 4 Deadly Dungeon Don & Freda Boner 107
Chapter 5 Revenge of Balrog Don & Freda Boner 117
Chapter 6 The Fortress at Times-End Don & Freda Boner 125
Chapter 7 Temple of the Sun Jack Powers 134
Chapter 8 Lost Ship Charles Forsythe 148
Chapter 9 Spider Mountain Teri Li 157
Chapter 10 Lost Dutchman's Gold Teri Li 167 *
Chapter 11 Journey to the Center of the Earth Greg Hassett 177 *
Chapter 12 King Tut's Tomb Greg Hassett 187 *
Chapter 13 Voyage to Atlantis Greg Hassett 197 *
Chapter 14 House of Seven Gables Greg Hassett 206 *
Chapter 15 Sorcerer's Castle Greg Hassett 216 *
Chapter 16 CIA Adventure Hugh Lampert 225 *
Chapter 17 Arctic Adventure Harry McCracken 234
Chapter 18 Adventureland Scott Adams 241 *

I will be converting some of these that I haven't done yet over the next few months.  But first I must investigate which one's are already easily available in repositories.  If I find any that are not I'll come back to this list and mark them with a + sign to indicate that they are on my radar screen for porting.  If anyone has any suggestions for any that I should prioritize for porting please post a comment.

One final "Text Adventure" project I am thinking of undertaking is converting my re-code of Planet of Death by Artic Soft.  I have read many reviews of this game, and they all praise its innovative features.  But there are also a number of specific complaints that reviewers make about its puzzles that they agree spoil the game, especially for modern players. It might be nice, since I have converted it to BASIC, to make my recode a new version of the game that addresses these complaints. That way it might serve a useful function of providing an opportunity for modern players to give it a try and not be overly frustrated.  Any comments on this project would be much appreciated.

Addendum

Found an inspiration online of a simple "Pharaoh" graphic to use for Hasett's Tut's Tomb game.


I worked up a SG6 version of it to replace the simple pyramid I had originally created for an intro screen.

Also added title screens for other of his games too:


Journey to the Centre of the Earth

The House of Seven Gables

Sorcerer's Castle

Enchanted Island