An amazing contribution to this years Basic 10 Liner contest by Copper France.
Sokoban in just 10 lines of Basic! Great work!
Download here: https://bunsen.itch.io/dokoban-by-copper-france
Got to admit these are ten pretty long lines, but WOW.
Cool.
In fact, the initial listing is more than 10 lines and you must do a "RUN 100" first to build the final listing that contain special caracters that you can not type by hands. (very nice done)
1 MODE 1:s$="E8C292008E2C290033336C207F7F7F7F3333C901FBFBFBFB7F7F7F7F7F3333CCFBFBFBFBFB3333CC000000000107070F00000000A0F0F0F00F0F0F0500000000F0F0E08000000000C3902A2A9093C2CB3C06515103361C7C5F5FCFDFDEDEFEFCFAFAFCFEDEDEDFCF0000431312121010":w$="WELL DONE!"
2 PAPER 0:DEFINT a-y:CALL&BD1C:BORDER 0:FOR n=0TO 15:READ v:INK n,v:NEXT:o=35:w=20:h=12:DIM b(w+1,h+1),r$(h),l(h),r(h),x(o),y(o):FOR i=0TO 5:READ b$(i):NEXT:z=HIMEM:FOR s=1TO 223STEP 2:z=z+1:POKE z,VAL("&"+MID$(s$,s,2)):NEXT:b$=b$(5):b$(0)=b$(0)+CHR$(0)
3 READ l$:IF l$=""THEN 10ELSE n=LEN(l$)-37:FOR i=0TO n:a=ASC(RIGHT$(l$,i+1))-o:y(i)=a\18+2:x(i)=a MOD 18+2:NEXT:FOR j=1TO h:r$=MID$(l$,j*3-2,3):r$=BIN$(ASC(r$)-o,7)+BIN$(ASC(RIGHT$(r$,2))-o,7)+BIN$(ASC(RIGHT$(r$,1))-o,7):l(j)=INSTR(r$,"1"):i=20:r$(j)=r$
4 WHILE l(j)AND MID$(r$,i,1)="0":i=i-1:WEND:r(j)=i:NEXT:l=l+1:IF l(h)=0THEN l(h)=1:r(h)=0:DATA,6,13,2,3,24,,,26,,18,,23,15,,11,"@@@@@@@@@@@@@@@@@@@@@@@@@","@@@@@@@@@@","@@@@@@@@@@","@@@@@@@@@@","@@@@@@@@@@","@@@@@@@@@@@@@@"
5 CLS:PEN 2:?"LEVEL";l:FOR j=1TO h:FOR i=l(j)TO r(j):b(i,j)=VAL(MID$(r$(j),i,1))+1:NEXT:NEXT:FOR i=1TO n:b(x(i),y(i))=4*(i AND 1):NEXT:FOR j=1TO h:LOCATE l(j)*2-1,j+j:FOR i=l(j)TO r(j):?b$(b(i,j));:NEXT:NEXT:x=x(0):y=y(0)
6 FRAME:LOCATE x+x-1,y+y:?b$:u=(INKEY(1)=0AND b(x+1,y)<2)-(INKEY(8)=0AND b(x-1,y)<2):v=(INKEY(2)=0AND b(x,y+1)<2)-(INKEY(0)=0AND b(x,y-1)<2):IF u<>0XOR v<>0THEN LOCATE x+x-1,y+y:?b$(b(x,y)):x=x-u:y=y-v:SOUND 1,0,2,7,,,10:GOTO 6ELSE IF INKEY(18)=0THEN 5
7 u=(INKEY(1)=0AND b(x+1,y)>2AND b(x+2,y)<2)-(INKEY(8)=0AND b(x-1,y)>2AND b(x-2,y)<2):v=(INKEY(2)=0AND b(x,y+1)>2AND b(x,y+2)<2)-(INKEY(0)=0AND b(x,y-1)>2AND b(x,y-2)<2):IF NOT u<>0XOR v<>0THEN 6:DATA"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
8 LOCATE x+x-1,y+y:?b$(b(x,y)):x=x-u:y=y-v:b(x-u,y-v)=b(x-u,y-v)+3:b(x,y)=b(x,y)-3:LOCATE(x-u)*2-1,(y-v)*2:?b$(b(x-u,y-v)):DATA"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
9 SOUND 1,0,2,9+6*(4-b(x-u,y-v)),,,10:m=0:FOR i=2TO n STEP 2:m=m-(b(x(i),y(i))=3):NEXT:IF m+m=n THEN LOCATE x+x-1,y+y:?b$ELSE 6:DATA"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@","@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
10 IF l$=""THEN MODE 1:LOCATE 15,h:?w$:WHILE INKEY(47):WEND:RUN ELSE FOR j=200TO 1STEP-10:SOUND 2,j,1,12:NEXT:GOTO 3:DATA"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@","@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@",
100 MODE 2:PEN 1:DEFINT a-z:f=&170
110 RESTORE 150:FOR i=0 TO 5:READ p,a,b,c,d:b$=CHR$(15)+CHR$(48+p)+CHR$(a)+CHR$(b)+CHR$(8)+CHR$(8)+CHR$(10)+CHR$(c)+CHR$(d)+CHR$(11)
120 IF i=5 THEN b$=CHR$(14)+"1"+b$+CHR$(14)+"0" ELSE IF i=0 THEN b$=CHR$(15)+"1"+CHR$(253)+CHR$(253)+CHR$(8)+CHR$(8)+CHR$(10)+CHR$(253)+CHR$(253)+CHR$(8)+CHR$(8)+CHR$(11)+CHR$(22)+CHR$(1)+b$+CHR$(22)'+CHR$(0)
130 FOR a=f TO &1170:IF PEEK(a)=64 THEN FOR p=1 TO LEN(b$):POKE a,ASC(MID$(b$,p,1)):a=a+1:NEXT:f=a ELSE NEXT
140 NEXT
150 DATA 3,245,246,247,248,1,253,253,253,253,1,240,240,240,240,3,241,242,243,244,2,241,242,243,244,3,249,250,251,252
200 RESTORE 260:DIM xd(17),yd(17),xs(17),ys(17):FOR l=1 TO 6:d=-1:s=-1:h$="":FOR i=1 TO 12:READ l$:FOR k=0 TO 2:b$="&x":FOR j=1 TO 7:c$=MID$(l$,k*7+j,1)
210 IF c$="#" THEN b$=b$+"1" ELSE b$=b$+"0":IF c$="." OR c$="+" THEN d=d+1:xd(d)=k*7+j:yd(d)=i ELSE IF c$="$" THEN s=s+1:xs(s)=k*7+j:ys(s)=i
220 IF c$="@" OR c$="+" THEN x=k*7+j:y=i
230 NEXT:h$=h$+CHR$(VAL(b$)+35):NEXT:NEXT:FOR i=0 to d:h$=h$+CHR$((yd(i)-2)*18+(xd(i)-2)+35)+CHR$((ys(i)-2)*18+(xs(i)-2)+35):NEXT:h$=h$+CHR$((y-2)*18+(x-2)+35)
240 PRINT CHR$(34);h$;CHR$(34);",";LEN(h$):FOR a=f TO &1170:IF PEEK(a)=64 THEN FOR p=1 TO LEN(h$):POKE a,ASC(MID$(h$,p,1)):a=a+1:NEXT:f=a ELSE NEXT
250 NEXT:DELETE 100-
260 DATA" ### "," ## ##"," # #"," #$ #"," ### $##"," # $ $ #","### # ## ##########","# # ## ## ## ..#","# $ $ ..#","##### ### #@## ..#"," # #########"," #######"
270 DATA"#####","# #","# $ #","# $ ## #####","# ### #","##$# @#","# $ # # ###","# $### # ######","# $ # . .#","# ## . .#","######## .## .#"," ########"
280 DATA"#########","# # #","# $$$ #","# $$$ #","## # #","# ######","# #. #######","# #. ## #","## .#. @ #"," ## ...$# ##"," #### ## #"," #########"
290 DATA" ####"," ###### #######"," # ## ##"," # ###$$ #"," # ##### ## $$ #"," # ## ..## $$#"," ## ##.@. ## $$ ##"," # ##.#.####$$ #"," # ...# # #"," ###### # #### #"," #### ####",""
300 DATA"####","#..### #######","#.. ###### #","#.. @# ## #$ #","### ## $ $# #","#.. $ #$ $ #","#.. # ## # # #","#.. ## ## #$ #$ #","### $ # $# #"," ##$# $ #######"," # ##"," #######"
310 DATA"#################","# ## . . ## #","# # # + # # #","# # # #. .# # # #","# # . . # #","# # #### #### # #","# # # # # # # #","# # # $# #$ # # #","# # $ $ # #","# # $$$ # #","# ### ### #","#### ####### ####"
I read the description. Is this allowed though?
I think the rules was not enough strict to avoid that, but finally not bad when you see the result.
I have updated the previous post to include it here, from the gamopat forum.
https://www.gamopat-forum.com/t115213-le-10lignopat-2021-resultats
Permitted or not, I like these clever hacks. Reminded me of that xKB-limit demo from several years ago (on PC) where the code was indeed within the limits but they used a long folder structure (0 bytes) to store the data😀
Winners don't use drug... But cheat.
There was a Pac-Man typein in one of the magazines back in the day where you had to execute a set of KEY commands to put the needed extended characters onto the function keys first. https://www.cpcwiki.eu/index.php/Roland_in_the_Haunted_House
Dokoban could "easily" have used a similar trick, making it directly typable, so I think it's not completely breaking the rules. Using a generator program just simplifies the process, it's not absolutely required.
Quote from: TotO on 13:57, 25 March 22that contain special caracters that you can not type by hands
Dokoban is properly using control codes, which are a documented feature of the Amstrad. I don't see why this would be against the rules, even if a human being can hardly follow what it's doing. All characters except for CHR$(0) can typed by hands by using CTRL + a normal key. (CTRL+A = 1, CTRL +B=2,...) . OK, CHR$(13) needs to be copied, as CTRL+M always executes a return, but I count copying also as typing.
The enhanced listing imho only makes it "user friendly" to fix/change the data, which otherwise would be a nightmare.
Well... And, how do you print the 10 lines listing on the paper or web page? ;D
Funny, I don't see anything in the rules about needing to do that. Although given that even the control codes on the CPC have glyphs attached, the final listing *is* fully printable:
Listing 255.png
Quote from: TotO on 16:02, 25 March 22Well... And, how do you print the 10 lines listing on the paper or web page?
There is no rule that says that a listing has to be printed and typed back in. It's just required, that you can list it.
Control Codes are used by many of the entries and none of them can be printed and typed back in.
Sure, as said, the rules was not enough clear to avoid to do that. Now, I will be surprised to see someone saying: "Nice listing, I'm starting to type it on my CPC from that screenshot" Hahaha.
So, the biggest listing was just a commodity to create the real one. That is a clever thing for this project.
Let's not forget that one way or the other, the outcome is phenomenal.
Exactly. 10 basic lines for that is an amazing acheivement.
To my experience, usually BASIC programs are mostly made of ASCII art / monochrome blocks / etc.
Here I'm amazed, because we have a colorful screen with pixel precise, detailed graphics. I love it ! :)
Wow, this is an amazing achievement!