Wednesday, 1 December 2021

Early Machine Learning: "Animal" from David Ahl's BASIC Games


I trach a philosophy course on AI.  One of the things we look at are historical programs from the beginning of AI research. One of these is the "Guess the Animal" game included in David Ah's classic BASIC Games compendium from 1978.  However, when I went to look for easily accessible and playable versions of the original program I was surprised to discover that they were kind of hard to access.  Like so many of the programs on the list of Ahl classics, you can easily find copies of the source, and scans of the original book, such as:


But finding an easily playable version of the original was tough.  I did find some modern remakes, including one that is trying to compile an ever increasing list of inputs from people on the Net:

https://www.animalgame.com/play/faq.php

The reason this site is so interesting is that Animal is one of the early simple and accessible examples of a program involving "machine learning", which is a big buzz word these day in the field of AI. The intelligence of the program really relies on the input of the users and the intelligence of the program grows with additions to the input from users, who slowly train and expand the ability of the program.  The program tries to accurately guess the animal your are currently thinking of simply by asking questions and answers input by prior users.  It only has a limited number of questions that it starts with, but the users must supply all the rest.

Obviously, on the early 8-bit home computers this kind of program was limited by a number of factors.  The first was the reliance on slow and awkward forms of long term storage such as cassette tapes.  The second was limits on machine RAM memory for dealing with any growing body of input data.  The program was originally developed for networked minicomputer systems, which allowed for data to be more easily compiled, and for more users to be interacted with:

https://www.animalgame.com/play/misc/source.php

However, the Microsoft BASIC version for Ahl's book dispenses with the the "save" and "loading" features.  As a result, in its accessible type-in form it is easy to understand why people might not have been particularly interested in the program, with its data limited to single sessions on an un-networked 8-bit home computer.

Another possible reason for the relative lack of prominence on the Net among retrocomputing enthusiasts is that the Ahl version seems to have some bugs.  In the version I worked from the question printing routine didn't properly parse the questions, which are saved as text strings with numeric values tacked onto the end of them for directing the Y and N responses. The result is that the computer posses question with some of this Y/N numeric info tacked on at the end.  It was more an esthetic nuisance, than a fatal error.

The Original Question Print Routine:

400 Q$=A$(K)

410 FOR Z=3 TO LEN(Q$)

415 IF MID$(Q$,Z,1)<>"\" THEN PRINT MID$(Q$,Z,1);

417 NEXT Z

420 INPUT C$

My Question Print Routine:

400 Q$=A$(K)

410 FOR Z=3 TO LEN(Q$)

415 IF MID$(Q$,Z,1)<>"^" THEN 417

416 M$=MID$(Q$,3,Z-3)+"?":GOSUB1:Z=255:REM JUMP TO WORD WRAP PRINT ROUTINE

417 NEXT Z

However, there were possibly other more fatal problems involving the creation of new data items due to improper conversion of the numeric values into strings for concatenation onto new question strings.

370 A$(K)="\Q"+X$+"\"+A$+STR$(Z1+1)+"\"+B$+STR$(Z1)+"\"

In Microsoft BASIC, the lingua Franca of Ahl's publications, the proceeding space of unsigned positive number values is preserved when the STR$ function is used to convert those values to a string.  I think the original program, based on some version of minicomputer BASIC, probably automatically stripped all spaces from numbers, and just returned the number alone. But the program was re-written for Microsoft BASIC for Ahl's publication, and seems to possibly to have been a little rushed. I decided to add some MID$ treatments to the STR$ function used, in order to make sure the spaces were stripped.

370 A$(K)="^Q"+X$+"^"+A$+MID$(STR$(Z1+1),2)+"^"+B$+MID$(STR$(Z1),2)+"^"

I think the program might have possibly messed up otherwise in its interpretation of the numeric data of those generated strings, although perhaps not, since the final result is processed by a VAL function, which will simply ignore spaces.  But I wanted to make sure that the data was in the same non-spaced format as the original DATA statements for questions: DATA "\QDOES IT SWIM\Y2\N3\"

I also added word wrap so the output of the program, regardless of the length of questions and animal names would be nicely formatted for a 32 character screen.  I suspect that it would be possible for some questions to easily go over the 32 character or even the more standard 40 character limit of most home computers of the day.

So maybe because of its obvious limitations and bugs relatively few people using home computers ever actually typed in this program and played around with it.  Hence, it is not widely recalled or discussed by people on the Net today.  Which is sad because it is an important historical forerunner of modern AI developments and particularly machine learning techniques.


Thursday, 11 November 2021

"Capture" by Mac Oglesby

This is a puzzle/board game by Mac Oglesby. I converted it from Commodore PET source to TRS-80 MC-10 Micro Color BASIC. The source can be found on the Internet Archive as a book scan of PET Games and Recreations from 1981:


The version from PET Games and Recreations that I primarily worked from was dated from 1980, but there is an older version published in the People's Computer Magazine July/Aug 1977, but dated in the source to 1976.  I also used a version from Recreational Computing magazine dated 1979, that I picked up somewhere along the line and printed out and had stuck in a binder. I decided to convert the 1980 version because it was the latest and it had a computer player option.  However, it did still allow for two human players to play.  It seems like Oglesby kept tweaking the program along the way.  The 1980 version was similar to the 1979 version (both had 2-player ability) except for a modified input routine at 10000 that didn't require users to hit Return to confirm their selections.  The 1977 version seems to have been only for 2 players and wasn't written specifically for the PET. The grid dimension were smaller and it didn't use an special graphic characters.

Mac Oglesby was a very prolific programmer, who contributed games to the early 101 BASIC Classic games collection by David Ahl and to other type-in game publications. Here's a brief list of some of of his type-in games from Moby Games:

Cross-Country Balloon Trip (1978), Capture (1976), Exagon (1976), Planets (1976), Pounce (1976), Sinners (1976), Survivor (1976), Watchman (1976), Dodgem (1975), Motie (1975), Rescue (1975) Square (1975) and Frogs (1974).

I have also converted his Frogs game. I hope to convert some more because not all of them seem to be widely available on the Net. I have found one PET software repository, which lists Sinners among its collection. But I can't seem to find any others, so I am not sure how easy it is to find working copies of Oglesby's games on the Web, which is sad because he seems like a pretty significant early contributor to the home computing revolution and the type-in game phenomenon. Perhaps this is because most of his games are of the logic puzzle variety, which can be a little annoying to most folks. Capture, however, is a game where you try to pick the letters with the most blocks around them, in order to capture the most letters and blocks by the end of the game. So it is kind of a spatial recognition/strategy game. It's rather unique, and quite entertaining.

The source of my port of CAPTURE can be found here: https://github.com/jggames/trs80mc10/tree/master/quicktype/Board%20Games/Capture
The earliest numbered file version, of course, represents the rough text capture from the digital scan from the PET book.

The game can be played here: http://faculty.cbu.ca/jgerrie/MC10/Educational.html

Or here under the Educational Game category:

Saturday, 6 November 2021

"Mystery Mania" from Compute! December 1987

Mystery Mania David Leithauser was published in Compute! Magazine December 1987. It creates logic puzzles with a murder mystery theme to them; 32000 variations with five levels of play to choose from. I've added a graphic title screen and made a few changes to make it more Sherlock Holmes like. For example, when you win, the level your win is recognized by being awarded different levels of the Order of the British Empire.


The game can be played at my GameJolt page:

Just select "Play Our Educational Game."  Then select MYSTMANI and type RUN in the main emulator window.  Thanks to Mike Tinnes for letting me use his emulator.

The source code can be viewed on my Github here:

Just look for the highest numbered listing for the latest most debugged version.

Tuesday, 2 November 2021

Retrochallenge 2021: Star Lanes

Star Trader was a BASIC game written by Dave Kaufman and published by the "People's Computer Company" in 1974 or possibly earlier.  I have written elsewhere about the challenges I had converting this game to run on the MC-10.  Kaufman's game is the forerunner of the vast array of open world space exploration and trading games, such as the Trade Wars series.

According to some sources on the Net, Star Trader was "copied" and "modified" into a different game called Star Lanes some time by the late 70s or early 80s.  Some Star Lanes games use the filename TRADE.BAS while others use LANES.BAS or some variation of either these.

However, I have ported the source code for both games to Micro Color Basic and played them, and I find the contention that Star Lanes is a "variation" of Kaufmann's Star Traders to be ludicrous.  The two games are completely different in both code and conception.

In Star Lanes, players take turns building outposts, creating companies, and purchasing stock.  It is a grid based game in which you select locations on the grid to slowly form "lanes" between star systems and outposts.  These lanes are owned by different companies, that you can buy stock in, and by selecting the companies that are most likely to merge, when their lanes intersect, you can make huge returns on your investments.  The fundamental dynamic is to construct interconnected trading routes.


Star Trader, on the other hand is played on a star map where players can travel directly between different star systems.  Players travel about buying and selling six types of merchandise: uranium, metals, gems, software, heavy equipment, and medicine.  They have to plan their routes and stops while considering efficiency of routing and the likelihood of the needs and likely sale goods of the different planet types located in each star system.  You can occasionally be hit by random events, such as space pirates.  The fundamental dynamic is to be an effective travelling salesperson, which includes haggling effectively when both purchasing and selling goods.

I think that the use of the term "trade" in the filenames of these two games and the fact that they are set in space is all that really connects these games.  People with vague recollections of playing various "interstellar space trading" BASIC games has allowed them to become interconnected in people's minds. I am not sure who wrote Star Lanes, but I have come across a number of variations, including one for the TRS-80 Color Computer that have AI built into it so that you can play against the computer.  I didn't convert that one because I wanted to get a very early version of the program running, and the Altair was one of the first 8-bit hobby computers, so I figured that it must be a pretty early variation.  However, no original author's name is mentioned in the documentation.  Just these remarks

REM ***** STAR LANES *****
REM MODIFIED BY S J SINGER
REM FOR ALTAIR BASIC 4.0

I also have some source that states:

REM - MODIFIED FOR THE MICROBEE BY JOHN ZAITSEFF, 1988

As I mentioned, I also have uncovered a TRS-80 Coco version with these remarks and title page code:

1 ' Coco Version enhancements over          original PC version.
2 ' 1. Marked display of players poss-         ible move locations.                 2. Computer added as a player.             (Using the advanced heuristic            programming technique called            RND numbers).
3 ' 
4 ' I intend to improve the computers       playing ability in the near future,     but it may be a while before I have     time.
5 '
6 ' I hope you enjoy playing the game.

2510 V=10: CT$="-:*  Original PC version by  *:-": GOSUB 2290
2520 V=12: CT$="John Bernauer": GOSUB 2290: V=14: CT$="Malcom  Higgins": GOSUB 2290: V=16: CT$="Brian Irvine": GOSUB 2290:V=18:CT$="-:*  Coco III Version by  *:-":GOSUB 2290
2530 V=20:CT$="Martyn Phillips":GOSUB 2290

Not sure if John Bernauer, Malcolm  Higgins (I've added an l), Brian Irvine are the original authors, or simply folks who converted the game to PC.  A search of the Net doesn't turn up anything definitive.  This is the only functioning link that I could find, but it doesn't actually seem to reference the names.

So I am not completely sure who to attribute authorship to for this game.  For the time being, I will use the names mentioned in the Coco source code: J Bernauer, M Higgins, B Irvine.  But if anyone could shed more light, I would really appreciate it.

Anyway, this is the last project I mentioned in my description of my Retrochallenge for Fall 2021.  It's a little late, I know.  I've already made my excuses in prior posts. Thanks again to the other Retrochallengers, and to the folks organizing again this year.


P.S. 

Here is the link to my Github with the various source code files for the different versions of the program Star Lanes that I reference in this post:

Here is a link to the source for Star Traders by Kaufman. Feel free to compare them. They seem to be completely different programs

Sunday, 31 October 2021

RetroChallenge 2021: Happy Halloween!

Well just to prove that I haven't been completely skiving off lately, here are some videos of a couple of projects that I have been doing this month.  The first is the slide show from the Cocotalk Live presentation I did a week ago.  The kind folks there organized a show focused on the MC-10.  Great to finally see some of the folks I've been corresponding with since the days of the old MC-10 Yahoo group.  Anyone remember Yahoo?  Thanks especially to Curtis Boyle for all the coordinating for the show.  


The other video is of a program called DRAC that I worked on recently.  James Host the admin of the MC-10 Facebook group challenged folks to come up with some seasonal programs.  So I whipped up something quickly over an evening.  Just stole some ASCII graphics of Dracula and some lips with fangs from the Net.  Plot them using SET/RESET.  Little graphic work with my SKETCH program for some big text and graphics for a few wee animated bats and Bob's your uncle.

I decided to put them on my real MC-10 and then put them on a loop using the MCX-SD.  Just have each program RUN the other.  MCX BASIC lets you use a filename with RUN so you can easily chain programs together.  Who says BASIC isn't useful anymore!


Saturday, 30 October 2021

RetroChallenge 2021: Greg Dionne's BASIC Compiler Compared to Interpreted BASIC

Well this hasn't been my most productive Retrochallenge. My real job has finally caught up with me and I find myself unable to devote the same amount of time I used to for coding.  Or perhaps it is simply life that has caught up with me and body, so that I no longer have the spare energy to devote to amount of coding I might otherwise like to do.  I can't be sure.

In any case I can report that Les Cavernes basically works as I think it was intended to work.  It's simply not an overly great game. It's a simple little type-in program RPG/Text adventure hybrid that provides a very basic level of game play.  Still, an interesting little bit of type-in history.

My compiled Freecell is working well.  It seems to play a decent little game of solitaire.  And all I had to do was mangle a beautifully designed piece of QBasic code (nicely indented and without line numbers) into a GOTOed piece of nightmarish 8-bit Color Basic code.  Kind of like taking a Porsche and removing the body and putting a rusty Volkswagen Beatle body on to the chassis instead. The original code was from some French bloke.  His site can be found here:

http://jemaf.free.fr/index.php?page=qbasic

He's got a bunch of other programs in Qbasic.  Mostly puzzle games.  I might try converting some of these others to Micro Color Basic.  But it was really Freecell I wanted to try.  I thought it would be a good test for Greg Dionne's Basic compiler because QBasic programs are compiled, and I suspected it would run a little slow under regular interpreted Basic on the MC-10.  Here's the comparison:

Interpreted Basic Freecell:



Compiled Basic Freecell:


My wife Patty has played it a number of times.  She's an experienced card player, so I hope her assessment is a good indication that all the bugs are out.  Still if anyone would like to play, it can be played via the following link. After you select "Play" below select the "Educational" programs item and then choose "FREECELL" from the "Cassette" menu of the Javascript emulator and type EXEC in the main window:

Saturday, 11 September 2021

RetroChallenge 2021: Les Cavernes by Charles Feydy 1982


Auraes from over on the CASA text adventures forum put me onto a game for possible porting.  He wrote:

“A tiny game found in the French magazine Trace with an esoteric and unreadable source code, but which may be of interest to jgerrie”

Auraes made a transcription of the article available, but acknowledged that there could be some mistakes in the listing.  I did find one:

240: G=INT N-10*INT (B/10)

It should have read as:

240: G=INT B-10*INT (B/10)

“Les cavernes” was originally designed for the TRS-80 Pocket Computer.  It was a fascinating little program. From my meagre French, it appeared to use a special method of entering the list of descriptions into variable memory. Rather than entering it by a traditional READ/DATA statement approach), to conserve as much memory as possible, it has the user simply enter the list of text descriptions into the array variables by typing them in direct mode. The main program itself is highly condensed using every trick possible in pocket TRS-80 Basic. All this to shoe-horn a simple text adventure game into 4K. So cool. I have tried to get it to work in the 4K space of the unexpanded TRS-80 MC-10.

I had to figure out that for the pocket computer an expression like F=4F is interpreted as F=4*F.  This is one of the ways the programmer, Charles Feydy, used to save precious memory.

Here's the link for the original source code in TRACE magazine, page 62 to 63:

https://www.abandonware-magazines.org/affiche_mag.php?mag=205&num=4090&album=oui

Auraes noticed that there seemed to be infinite loop at the heart of the program, that provided no way to jump out of it to the various subroutines of the program.  However, the pocket computer turned out to have some ability to auto sense the pressing of “programmable” keys.  If a line started with a string of a key

“K”

for example, it would be automatically jumped to when that key was pressed.  It must have been based on some form of interrupt driven key sensing working in the background while Basic was running.

Auaes tried to reproduce the code using PureBasic, but like me he was having trouble with the memory management of the Pocket computer.  He was able to help me figure out that the variables, which could only be single letters, could also be treated as a single digit array.  For example, we had both noticed that the variable B was not initialized anywhere in the program when in fact it was being indirectly initialized by references to A(2).  So single numeric variables like B equate to ordered array instances of A.

A(1) = A

A(2) = B

A(3) = C

Thanks to Auraes pointing this out to me I finally made some progress converting the program to Micro Color Basic:

https://github.com/jggames/trs80mc10/tree/master/quicktype/Text%20Adventures/Cavernes

The problem is that the game seems very difficult and the map seems basically arbitrary. I’m not sure if there are still bugs in it, that I have somehow missed.  I am not sure how it is supposed to be won.  So I will keep you folks posted on any progress I make testing them game, and if this reveals any bugs.

Anyone interested can try playing the game here:

http://faculty.cbu.ca/jgerrie/MC10/JG_MC_Ports2.html

Just select CAVERNES from the Cassette menu. It can be a little tricky sometimes to select it. Then type RUN in the main emulator screen and hit Enter.

I translated the game to use English text.  I updated the interrupt key sensing to a more standard system using INPUT and the following commands:

  • RESTART
  • N
  • E
  • S
  • W
  • GET
  • INVENT
  • KILL
  • QUIT
  • LOOK

The first letter is actually all that is needed.  Enjoy.

P.S.

Auaes posted a response that suggests that the way to "win" is wander and collect keys, that will allow you to kill certain monsters, which is how you earn points.  I think there are 10 keys, so conceivably you are playing for the highest score possible.  This is likely to be pretty challenging, as you sometimes can find yourself in rooms with no exit, either because there aren't any, or the monster blocks the only exit.  At that point it's "game over."  However, there is no randomness in the mazes numerically generated from the numbers you enter at game startup in response to the "No" and "Level" prompts.  Those numbers determine the maze you get, so there should be room for retrying until you make some progress.  Type Q to end the game and see your final score.