Volhout Guru
 Joined: 05/03/2018 Location: NetherlandsPosts: 561 |
Posted: 07:38am 10 Mar 2021 |
Copy link to clipboard |
 Print this post |
|
I managed to get 2 simple levels into the 10 lines, and when you press "r" you redo the current level. For the 48 line contest, I may simply add 38 levels or so....
' TLS = ten line sokoban
' control by cursor keys-128 (128,129,130,131 => 0,1,2,3 => ^ V < >) ' playfield values 0=empty, 1=target, 2=block, 3=wall
'z = size block 'x,y = position human 'e,g = new position human 'o,p = position onscreen 'n = ascii value key 'b,c = direction human 'd = done 'a$ = key pressed 'l,m = vars for decoding rooms 'i,j = counters 'k = value field (i,j) 'f() = playing field 't() = target locations for the boxes 's = size playfield (sxs) 'q = boolean (human on target) 'w = level (0....nn)
'----------the compacted code---------
s=11:z=9:Dim f(s,s),t(s,s):Do:Mode 4:Read x,y:For i=1To s:Read v$:l=Val("&h"+v$) For j=1To s:f(i,j)=3And l:l=l\4:t(i,j)=(f(i,j)=1):Next j,i:Print @(99,10)"TLS" f(x,y)=4:Do:d=0:For i=1To s:For j=1To s:k=f(i,j):o=120+z*(i-6):p=99+z*(j-6) Line(o,p)-(o+z-2,p+z-2),3And k,BF:Circle(o+z/2-1,p+z/2-1),3*(k=4),6,,F:d=d+(k=1) Next j,i:If d+q=0Then:w=w+1:Exit:EndIf:Data 2,2,FFFF,D003,FF03,C003:Do:a$=Inkey$ Loop While a$="":n=3And Asc(a$):c=(n<2)*(n*2-1):b=(n>1)*(n*2-5):e=x+b:g=y+c If f(e,g)=3Then:b=0:c=0:ElseIf f(e,g)=2Then:If f(e+b,g+c)<2Then:f(e,g)=t(e,g) f(e+b,g+c)=2:Else:b=0:c=0:EndIf:EndIf:f(x,y)=t(x,y):x=x+b:y=y+c:f(x,y)=4:q=t(x,y) If a$="r"Then:Exit:EndIf:Data C083,C003,C003,FFFF,0,0,0,2,2,FFFF,D5F3,CBC3,C023 Loop:Restore:For i=1To(s+2)*w:Read j:Next i:Loop:Data C3CF,EC0F,C0FF,FFFF,0,0,0
'--------------extra data------------- 'simple 8x8 'Data 2,2,FFFF,D003,FF03,C003,C083,C003,C003,FFFF,0,0,0 'Data 2,2,FFFF,E103,FF03,C003,C003,C003,C003,FFFF,0,0,0 '8x8 field Data 2,2,FFFF,D5F3,CBC3,C023,C3CF,EC0F,C0FF,FFFF,0,0,0 Data 5,2,FF0,C3F,FC03,C273,CE23,C44F,FF0C,3FC,0,0,0 Data 2,2,FFFF,C303,C0B3,DA13,CDEF,C10C,FFFC,0,0,0,0 '11x11 field Data 2,3,FFC,3FC0C,30C8C,300BF,37F23,37203,3703F,37230,37F30,30030,3FFF0
If nothing goes right ... turn left |
Volhout Guru
 Joined: 05/03/2018 Location: NetherlandsPosts: 561 |
Posted: 09:31pm 11 Mar 2021 |
Copy link to clipboard |
 Print this post |
|
This is going to be my entry to the challenge. I am finally happy with the performance, and the playability.
10 liner sokoban for CMM1
s=11:z=9:Dim f(s,s),t(s,s):Do:Mode 4:Read x,y:For i=1To s:Read a$:l=Val("&h"+a$) For j=1To s:f(i,j)=3And l:l=l\4:t(i,j)=(f(i,j)=1):Next j,i:Cls:Print w,,"TLS" f(x,y)=4:Do:d=0:For i=1To s:For j=1To s:k=f(i,j):o=120+z*(i-6):p=99+z*(j-6) Line(o,p)-(o+z-2,p+z-2),3And k,BF:Circle(o+z/2-1,p+z/2-1),3*(k=4),6,,F:d=d+(k=1) Next j,i:If d+q=0Then:w=w+1:Exit:EndIf:Data 9,2,FFC,3003,3003,30C3:Do:a$=Inkey$ Loop While a$="":n=3And Asc(a$):c=(n<2)*(n*2-1):b=(n>1)*(n*2-5):e=x+b:g=y+c If f(e,g)=3Then:b=0:c=0:ElseIf f(e,g)=2Then:If f(e+b,g+c)<2Then:f(e,g)=t(e,g) f(e+b,g+c)=2:Else:b=0:c=0:EndIf:EndIf:f(x,y)=t(x,y):x=x+b:y=y+c:f(x,y)=4:q=t(x,y) If a$="r"Then:Exit:EndIf:Data FC0,,FFC,3217,3203,3003,FFC,5,2,,,,FFFF,D5F3,CBC3 Loop:Restore:For i=1To(s+2)*w:Read a$:Next i:Loop:Data C023,C3CF,EC0C,C0FC,FFC0
And 14 lines of extra levels This makes up for a 80x24 editor screen from a terminal.
Data 8,5,,,,FC0,DC0,CFF,FE87,D83F,FFB0,370,3F0,6,3,,,3FF,3FF03,30FA3,30083,303FF Data 3F300,C3F0,C570,FFF0,5,4,,,,FF0,C30,E3F,3DA3,3163,3163,3F03,3FF,7,7,,,,FF00 Data C3F0,C03F,CE07,C897,C87F,C3F0,FF00,6,6,,,3FF,3FC3,3C23,3CE3,3163,317F,32F0 Data 30C0,3FC0,9,7,,,,,FFFF,C017,C897,FABB,C897,C017,FFFF,7,6,,,FFFF,D503,D1B3 Data CB03,C23F,F30C,328C,3F0C,3FC,7,6,,,,3FF0,303F,3053,3373,32B3,3C23,C0F,FFC Data 8,2,,,,FF0,C3F,FC03,C273,CE23,C44F,FF0C,3FC,6,2,,,,,FFFF,C303,C0B3,DA13 Data CDEF,C10C,FFFC,2,3,FFC,3FC0C,30C8C,300BF,37F23,37203,3703F,37230,37F30 Data 30030,3FFF0,6,3,,,,3FFFC,321DC,32FCF,31323,377C3,32043,31FFF,3FC00,10,7,,FF Data 3FFCC3,300FE3,339003,331FEF,339C0C,3C1CEC,3F100C,30FFC,3FC00,5,10,,,3FFFC0 Data 3005C0,33F5FF,303003,32B0C3,3E3FCF,32000C,303F0C,3FF3FC,5,3,3FC0,30FF,F023 Data C2C3,CC8F,C0BC,FF0C,F0C,D0C,D5C,FFC,3,8,FFFFC,C3C0C,C008C,C0F0F,FC8C3,C803 Data FC3F,3570,3030,30F0,3FC0,9,7,,,,3FFF,3003,3333,3003,FF3F,C2A3,C153,FFFF Data 10,10,3FF003,3333FF,303003,0,3FF3FF,8030,3FF3FF,0,3FF3FF,307333,FC303
How to play: Sokoban is a game where a guy (yellow circle) has to shove boxes (green) to their destination (blue) within the warehouse walls (cyan). The guy can only push, not pull. He is controlled using the cursor keys. Once you make bad move, the "r" (lowercase only) let you replay the level.
The level is indicated in the top left corner. There are 2 levels in the 10 liner, 18 additional levels in the extra code.
Once you achieve a level, the next level is loaded. The aim is to finalize all 20 levels in one evening. A restart of the game forces you to start again with level 0.
However...you can cheat... Variable "w" is the level that you go to after pressing "r". If you add this before the first line of the game, you can restart at any level by pressing "r" (example is level 16).
w=16
CMM2 owners should be able to run this by preceeding the program with
OPTION LEGACY ON
Happy Sokobanning... Edited 2021-03-12 07:39 by Volhout If nothing goes right ... turn left |