Post Reply 
Sokoban game for HP Prime
01-05-2014, 09:11 AM (This post was last modified: 01-05-2014 09:20 AM by patrice.)
Post: #5
RE: Sokoban game for HP Prime
About compression, you can use a simple encoding as commonly used in the game of life
Here is a decoding routine
Code:
RLEMap (Rows, Cols,RLE)
BEGIN
LOCAL Row, Col, Ptr, Cnt, Tmp;
Row:= 1; Col:= 1; Cnt:= 0;
Tmp:= MAKEMAT(0,Rows,Cols);
FOR Ptr FROM 1 TO DIM(RLE) DO
  CASE
  IF INSTRING("0123456789", MID(RLE, Ptr, 1)) <> 0 THEN Cnt:= Cnt*10+EXPR(MID(RLE, Ptr, 1)); END;
  IF MID(RLE, Ptr, 1) == "$" THEN Row:= Row+MAX(1, Cnt); Col:= 1; Cnt:= 0; END;
  IF INSTRING("b.", MID(RLE, Ptr, 1)) <> 0 THEN Col:= Col+MAX(1, Cnt); Cnt:= 0; END;
  IF INSTRING("w", MID(RLE, Ptr, 1)) <> 0 THEN // Wall
    FOR Col FROM Col TO Col+MAX(1, Cnt)-1 DO Tmp(Row,Col):=1; END; Cnt:= 0; END;
  IF INSTRING("c", MID(RLE, Ptr, 1)) <> 0 THEN // Cube
    FOR Col FROM Col TO Col+MAX(1, Cnt)-1 DO Tmp(Row,Col):=2; END; Cnt:= 0; END;
  IF INSTRING("d", MID(RLE, Ptr, 1)) <> 0 THEN // Destination
    FOR Col FROM Col TO Col+MAX(1, Cnt)-1 DO Tmp(Row,Col):=3; END; Cnt:= 0; END;
  IF INSTRING("s", MID(RLE, Ptr, 1)) <> 0 THEN // Sokoban
    FOR Col FROM Col TO Col+MAX(1, Cnt)-1 DO Tmp(Row,Col):=4; END; Cnt:= 0; END;
   END;
END;
RETURN Tmp;
END;
and the encoding for the first level
Code:
"$$$5b5w$5bw3bw$5bwc2bw$3b3w2bc2w$3bw2bcbcbw$b3wbwb2wbw3b7w$bw3bwb2wb5w2b2dw$bwbc​6bs6b2dw$b5wb3wbwb2w2b2dw$6bw5b9w$5b7w!"
The coding is :
$ : new line
! : End (optional)
b : Background (your 0)
w : Wall (your1)
c : Cube (your 3)
s : Sokoban (your 4)
and numeric is the repeat factor for next letter

Routine and level untested, but you get the idea

By the way, are you sure there is a Cube missing in level 1 ?

Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Sokoban game for HP Prime - ArielPalazzesi - 01-04-2014, 10:58 AM
RE: Sokoban game for HP Prime - Les_Koller - 01-04-2014, 10:39 PM
RE: Sokoban game for HP Prime - patrice - 01-05-2014 09:11 AM
RE: Sokoban game for HP Prime - patrice - 01-05-2014, 11:01 AM
RE: Sokoban game for HP Prime - patrice - 01-05-2014, 03:29 PM
Sokoban game for HP Prime - Dante - 01-09-2014, 03:36 PM
RE: Sokoban game for HP Prime - Tugdual - 01-10-2014, 09:59 PM
RE: Sokoban game for HP Prime - patrice - 01-14-2014, 11:25 AM
RE: Sokoban game for HP Prime - patrice - 01-14-2014, 05:42 PM
RE: Sokoban game for HP Prime - patrice - 01-15-2014, 08:37 AM
RE: Sokoban game for HP Prime - patrice - 01-27-2014, 11:21 PM
RE: Sokoban game for HP Prime - patrice - 02-24-2014, 04:05 PM
RE: Sokoban game for HP Prime - patrice - 03-10-2014, 05:15 AM
RE: Sokoban game for HP Prime - patrice - 03-10-2014, 11:50 AM
RE: Sokoban game for HP Prime - patrice - 03-10-2014, 06:24 PM
RE: Sokoban game for HP Prime - patrice - 03-14-2014, 11:56 PM
RE: Sokoban game for HP Prime - patrice - 05-30-2014, 09:28 PM
RE: Sokoban game for HP Prime - jonakeys - 03-04-2024, 06:52 PM
RE: Sokoban game for HP Prime - rprosperi - 03-04-2024, 11:01 PM
RE: Sokoban game for HP Prime - jonakeys - 03-05-2024, 06:17 PM



User(s) browsing this thread: 1 Guest(s)