I think I have found another bug in a commercial BASIC game distributed for a computer equipped with the Motorola MC6847 Video Display Generator. I recently ported the code for "Super Mind" for the Sanyo PHC-25 to the TRS-80 MC-10. Like my last project from that machine, "Fire War," there was a bug in the code that I think would have prevented the game from functioning as the designers intended. In Supermind the problem would only have occurred on the last of your 10 guesses. For that guess there was no need for the computer to print a report about how many of your guesses were right colors and rightly placed, since it was your last turn, so the programmer had created a special routine for your last guess. But I think that guess would never be able to be judged correct.
The following routine calls the input your guess routine (3000). Then if the number of the guess you are on is 10 it will jump to the last move routine (5000). Otherwise, it goes to the check the guess against the hidden code (4000), which counts up the absolutely right guesses (O) or right color wrong places. If the number of absolutely correct guesses is 4 (O=4), then it jumps to the end of game routine (6000) to print the appropriate congratulatory message. Otherwise, it keeps getting guesses (2510).
2510 N=N+1:GOSUB 3000:IF N=10 THEN5000 ELSE GOSUB4000
2520 IF O=4 THEN 6000 ELSE 2510
The following analysis applies to the code block listed here, which is the routine jumped to for your final guess (5000).
5000 REM Reponse dernier coup
5010 IF Z=1 THEN 5050
5020 FOR I=1 TO 4:LOCATE2*I+2,1:PRINT" ";CHR$(C(X(I)+1));" ":NEXTI:GOTO5090
5050 LOCATE4,1:PRINT " "
5060 FOR I=1 TO 4:LINE(42+(I-1)*16,18)-(45+(I-1)*16,23),X(I)+1,BF:NEXTI:GOTO5090
5090 IF O=5 THEN 5100 ELSE 5110
5100 LOCATE0,13:PRINT "Ͱ Gagne en 10 coups De justesse !!! ":GOTO5120
5110 LOCATE0,13:PRINT " Vous avez perdu... "
The problem is that the check routine (4000) is not run anywhere in this last guess routine. Line 2510 of the calling input routine either runs that check routine or jumps to this final guess routine. The final guess routine simply prints the last guess input (5000-5020) and then prints the hidden code (5050-5060). Then a check is made whether the number of exact correct answers (O=5) equals five (5090). If it does, then it prints a game won message, otherwise it prints a game lost message. This is very strange, since the guess check routine (4000) which determines how many absolutely correct selections (O) have been made has not been run. It is unclear why O would contain any number other than what it contained from the 9th turn guess. And it is unclear why O equaling 5 would be an indication of a correct guess of a 4 digit code. It might have made sense to do a simpler kind of check, perhaps to compare whether the guess perfectly matched the hidden code, but that does not appear to be done anywhere in the above.
Now it is somehow possible I have misinterpreted some aspect of the program or some nuance of the type of BASIC used on the PHC-25, but I really don't think so. The BASICs are very similar and conversion is not particularly difficult. There are no obvious nuances that I think could overcome this problem. The code certainly had the effect of always saying you lose in the MC-10 version I made. I had added a simple cheat for testing, which printed the hidden code at the start of the game. So I could see the right answer. But no matter what I input on the last try, correct or not, I would always be told that I had lost.
I can make a few guesses about why the code might have ended up like it did. The programmers might not have applied my cheating technique to do bug testing. It was an easy thing for me to add when I work with a modern text editor and can easily create subroutines and add and subtract lines in a temporary fashion. But when you were coding with the clunky line editing back in the day, these things were tougher. Also, it is possible that the authors intended to add a routine or line that did the simple test I mentioned, which would return a 5 if the two codes matched perfectly, but then forgot to add it.
I made some changes to fix the lack of a comparison check of the guess and the hidden code to fix the problem. My experience with the software made for the PHC-25 has left me very unimpressed. Another game I converted Labyrinth also had an error in it.
I was able to bug fix that error:
But along with the problems in Fire War, it's a pretty poor record of software reliability. This perhaps help explain why the PHC-25 computer was a market failure. If you are interested in trying the game as it (perhaps) should have run, it can be played here:
Here's me with a lucky performance:
No comments:
Post a Comment