Monday, 13 February 2017

Basic 10-Liners Contest 2017

Gunnar Kanold and his friends run a really neat Basic programming contest. It has been going for a number of years. It started out, I believe, as an all Atari event but a few years back they decided to open it up to other classic 8-bit home computer systems. This year the contest is being held on Saturday April 22 at the NOMAM retro convention in Lubeck Germany. Details about the contest can be viewed here: http://gkanold.wixsite.com/homeputerium/basic-10liners-2017

I decided to try programming the classic puzzle game "Minesweeper." I managed to get the game boiled down to 10 lines of Micro Color Basic on my favourite computer, the TRS-80 Micro Color Computer (MC-10). The original version of the program only did a 4-way search (up,down,left,right) for doing the flood fill after you select a location:


However, as with so many of my programming projects, a little more effort allowed me to condense the program just that wee bit more to allow me to fit in a full 8-way search:


Hard Version with 40 Mines
Here are some brief instructions for getting the game to run:
Get: http://faculty.cbu.ca/jgerrie/Home/VMC10_073D.zip
Unzip VMC10_073D.zip
Run VMC10.exe
Type CLOAD & hit ENTER. From the File menu select “Play Cassette File…” and then select SWEEPER.​C10 in the JimG subdirectory of the Cassette directory. Type RUN...
(Any trouble running it, make sure under the “Configure” menu that Memory is set to +16K Ram Expansion).
I should note that these instructions will work for getting any of my games to run, since all of the rest of my programs are also included in the JimG subdirectory of the zip compilation. This compilation includes the wonderful VMC10 emulator by James the Animal Tamer. Thanks so much James!

In addition to the 10 line limit, this year the rules were changed to require that the same program be submitted in a "long version", which means, with one command per line. Line jumps (GOTO, GOSUB) and other dependencies have to be adjusted so that the program remains fully functional. I'm not sure what this is all about, but perhaps it is to help with the judging, or perhaps Gunnar might want to use the programs to help teach students about Basic programming. I seem to recall that he was involved with teaching. In any case here is the original 10-line version and the long version:
0 CLS0:DIMF(10,10),K(255),A(2000),B(8),J,B,L,X,Y:B(1)=-1:B(2)=1:B(3)=-32:C=RND(-(PEEK(9)*256+PEEK(10))):D=1:B(4)=31:GOTO9
1 A$(1)=CHR$(96):I=0:FORY=1TO9:FORX=1TO9:J=-(PEEK(32*Y+X+M)=46):PRINT@32*Y+X,A$(-(F(X,Y)=1));:I=I+J:NEXT:NEXT:RETURN
2 SOUND9,1:B(5)=-31:B(6)=-33:B(7)=32:B(8)=33:K(65)=-1:K(83)=1:K(87)=-32:K(90)=32:FORY=1TO9:FORX=1TO9:POKE32*Y+X+M,46:NEXT:NEXT
3 L=RND(9):B=RND(9):ON-(F(L,B)=1)GOTO3:F(L,B)=1:J=J+1:ON-(J<10)GOTO3
4 POKEP,PEEK(P)+64:K=ASC(INKEY$+"@"):POKEP,PEEK(P)-64:ON-(K=0ORPEEK(P+K(K))=128)GOTO4:P=P+K(K):L=1:B=1:A(B)=P:IFK>32THEN4
5 Y=INT((A(B)-M)/32):X=(((A(B)-M)/32)-Y)*32:IFF(X,Y)=1THEND=2:ON-(P=A(B))GOTO9:D=1:FORJ=1TO1:GOTO8
6 C=F(X-1,Y-1)+F(X,Y-1)+F(X+1,Y-1)+F(X-1,Y)+F(X+1,Y)+F(X-1,Y+1)+F(X,Y+1)+F(X+1,Y+1)+48:IFC<>48THENPOKEA(B),C:FORJ=1TO1:GOTO8
7 POKEA(B),32:FORJ=1TO8:IFPEEK(A(B)+B(J))=46THENL=L+1:A(L)=A(B)+B(J):POKEA(L),32
8 NEXT:B=B+1:ON-(B<=L)GOTO5:GOTO4
9 M=16384:P=33+M:ONDGOTO2:GOSUB1:?@416,"SAFE!":IFI<>10THEN?@416,"DEAD!":FORC=1TO10:SOUND1,1:POKE49151,64:POKEA(B),64:NEXT
20 REM     minesweeper
21 REM     ***********
22 REM BASIC 10LINERS CONTEST
23 REM http://gkanold.wixsite.com/homeputerium/basic-10liners-2017
24 REM BY JIM GERRIE 2017
25 REM USE A,S,W,Z & SPACE.
26 REM AVOID THE 10 MINES.
27 REM WHEN DONE, HIT SPACE
28 REM ON A MINE TO SHOW MINES.
******************************************************************
0 CLS0
1 DIMF(10,10),K(255),A(2000),B(8),J,B,L,X,Y
2 B(1)=-1
3 B(2)=1
4 B(3)=-32
5 C=RND(-(PEEK(9)*256+PEEK(10)))
6 D=1
7 B(4)=31
8 GOTO900
100 A$(1)=CHR$(96)
101 I=0
102 FORY=1TO9
103 FORX=1TO9
104 J=-(PEEK(32*Y+X+M)=46)
105 PRINT@32*Y+X,A$(-(F(X,Y)=1));
106 I=I+J
107 NEXT
108 NEXT
109 RETURN
200 SOUND9,1
201 B(5)=-31
202 B(6)=-33
203 B(7)=32
204 B(8)=33
205 K(65)=-1
206 K(83)=1
207 K(87)=-32
208 K(90)=32
209 FORY=1TO9
210 FORX=1TO9
211 POKE32*Y+X+M,46
212 NEXT
213 NEXT
300 L=RND(9)
301 B=RND(9)
302 IFF(L,B)=1THEN300
303 F(L,B)=1
304 J=J+1
305 IFJ<10THEN300
400 POKEP,PEEK(P)+64
401 K=ASC(INKEY$+"@")
402 POKEP,PEEK(P)-64
403 IFK=0ORPEEK(P+K(K))=128THEN400
404 P=P+K(K)
405 L=1
406 B=1
407 A(B)=P
408 IFK>32THEN400
500 Y=INT((A(B)-M)/32)
501 X=(((A(B)-M)/32)-Y)*32
502 IFF(X,Y)=1THEND=2:ON-(P=A(B))GOTO900:D=1:FORJ=1TO1:GOTO800
600 C=F(X-1,Y-1)+F(X,Y-1)+F(X+1,Y-1)+F(X-1,Y)+F(X+1,Y)+F(X-1,Y+1)+F(X,Y+1)+F(X+1,Y+1)+48
601 IFC<>48THENPOKEA(B),C:FORJ=1TO1:GOTO800
700 POKEA(B),32
701 FORJ=1TO8
702 IFPEEK(A(B)+B(J))=46THENL=L+1:A(L)=A(B)+B(J):POKEA(L),32
800 NEXT
801 B=B+1
802 IFB<=LTHEN500
803 GOTO400
900 M=16384
901 P=33+M
902 ONDGOTO200
903 GOSUB1
904 PRINT@416,"SAFE!"
905 IFI<>10THENPRINT@416,"DEAD!":FORC=1TO10:SOUND1,1:POKE49151,64:POKEA(B),64:NEXT

In addition to the Sweeper game, last year I made a game based on a suggestion from someone from Brazil who commented on one of my programs a while back.  He told me about a game he had made when he was a kid. √Črico also sent me an image that had reworked using his old machine. He also described a little how it worked. Based on his recollections, I came up with another game, which I was able to cram into 10 lines in the hope of entering it into the NOMAM 2016 competition, but I was too late. So here is the "Monteiro Challenge," an arcade space flying game with 3 levels to get through, for this year's competition:


Anyway, I don't know if any of these game are any good as games, but they sure were a lot of fun to program. Thanks to Gunnar and the folks at the NOMAM retro event for organizing a great competition. Have fun in Lubeck this year!


P.S.
I had been hoping to get a car game going for the contest, But I can't for the life of me think of how I can get a game dynamic that wont sap the speed of the basic algorithm that I came up with for drawing a moving road graphic. I'll keep plunking away at it. It's called Formula1:



In addition to this program I have been busy lately making some ports of old code from other systems and reprogramming efforts based on videos I have seen. For example, RRUNNER.C10 is a game based on a Sinclair ZX-81 game, which can be seen on Villordsutch's page: https://youtu.be/0zJr3wPoi70.


Here is a modification of some code by my friend Robert Sieg from the MC-10 Yahoo group that draws a friendly frog. I was always intrigued by the starring white eyes of the frog and decided to animate them to make a version of what I call MC-10 Hynotoad:


Quite a bit of programming work had to go into converting a game from QBasic that recreated the Mattel Football classic handheld game from the 1970s. The Qbasic code was by bomberpunk. See this thread for info http://atariage.com/forums/topic/9013... and a vid of the original: https://youtu.be/jNKgpAFOsa0


In addition to the above I have also completed the following projects since I last posted:

Island of Secrets
Island of Secrets is a type-in listing in the book of the same name, which is a free PDF available for download from Usborne Publishing: https://usborne.com/browse-books/features/computer-and-coding-books/ As well as the listing the book contains an illustrated background story to the adventure. Some of the illustrations contain information that may aide the adventurer. I ported it from Commodore 64 version I found on-line. However, there were some bugs in it which prevented it from being winnable (or even playable). I fixed'em. Here's a video of a 64 version. Don't know if its the same one: https://youtu.be/Tstl9kjhpUE

Plunkit
Re-programming of Plunkit for the TRS-80 Coco by Roger Taylor. My MC-10 version was based on the Highretrogamelord video: https://youtu.be/1MFm7_zPTG8


Earthquake
Aardvark Software text adventure, ported from Commodore VIC 20 to TRS-80 MC-10. For original see: https://youtu.be/ulh2QWDoeSQ

Amazing!
A closer examination of the source has prompted some alterations to how the maze is drawn. Now level choice influences the amount of free space present on screen.



VicTron Port of Tron by F. G. Huerta
Originally for the Commodore VIC 20. This is a port of the program to Micro Color Basic for the TRS-80 Micro Color Computer. For the original see: http://blog.nanomuelle.com/2012/03/08/tron-3-0/



CupBall
Port to the TRS-80 MC-10 of a game for the Acorn Atom by Dino Dini called "CupBall." For the original see: https://youtu.be/Uwsm7TcvUao



Awful Green Things for the TRS-80 MC-10
Ported an Acorn Atom version of this classic board game to MC-10. See here for more details about the original: https://youtu.be/Es6WmwWxh50  (GREENTHI.C10)


Robot Nim
Ported from Acorn Atom to the TRS-80 MC-10. Original Basic source by P. Mainwaring, Sept 1981


Sniper 1K Game
Ported from a Sinclair ZX-81 1K games compilation. See: https://youtu.be/aANxm-v7P_M
(SNIPER.C10 in the 4K directory of JimG)

Orbit 1K Game
Ported from a Sinclair ZX81 1K game compilation. See: https://youtu.be/YPP-RhYWCUs
(ORBIT.C10 in the 4K directory of JimG)

Escape from Colditz
From the World of Stewart, a teenage software creation re-imagining escape from the famous WW2 POW camp. See: http://worldofstuart.excellentcontent.com/world/scorpion/scorpion.htm
(COLDITZ.C10)

JetPac
Jet Pac for the TRS-80 MC-10 based on an ZX81 game you can see here:
https://www.youtube.com/watch?v=tg6a84uqKTk


Bowling Champ
Basic game ported to TRS-80 MC-10 from Apple 2 game found at: http://www.atarimagazines.com/compute/issue57/bowling.html
(BOWLING.C10)