[comp.sys.handhelds] puzzle-24 game for HP-48SX

mcgovern@ee.su.oz.au ( ) (09/28/90)

Hi netters,

I think I screwed up sending it so here it is (again ?)

Here's a game I wrote (for hp-48sx) a couple of weeks ago but couldn't send
till now.  Its the puzzle-24 game.  I read that someone wrote
a similar program using the chip8 interpreter.  I thought I'd send this
anyway, it's rather hack out and its got a bug, but its still quiet playable.

The problem is that it creates a random layout of the pieces and this 
doesn't always result in a puzzle which can be solved.  About ever second
puzzle is solvable.  I wonder if the guy that wrote puzzle-15 knows of
a test to see if the puzzle has a solution, or is the only way to do it
scrambling a completed puzzle.  The program RARR creates an array of
the number 1 to 24 in a random order, this is then used to place the
pieces on the board.  I wonder if some sort of test can be performed on 
this to see if the puzzle will have a solution.  I thought maybe taking
the dot product with [1 2 ... 24 ] and testing if even, but this is not
correct.

Load the directory PUZZLE, go into the the directory's CST menu, then
to play run PLAY and use the arrow keys to move a piece adjacent to the 
empty square into that square.  Due to extreme lazyness on my behalf 
you need to use key y^x as the down arrow ; i.e.

			^
		     <     >
		       y^x		


				Hamish McGovern
				mcgovern@ee.su.oz.au

Checksum: #8F42  Bytes: 1944

---------------------------------------------
%%HP: T(3)A(D)F(.);
DIR
  PLAY
    \<< INIT 0 TIME
11 \-> KN T EM
      \<<
        WHILE 1
        REPEAT
"TIME: " TIME T
HMS- 1 + \->STR 3 6
SUB + 1 \->GROB PICT
{ # 50h # Ah } ROT
REPL
          IF KEY
          THEN 35 -
NEG \-> K
            \<<
              IF K
ABS DUP 10 == SWAP
1 == OR
              THEN
EM 'K' STO+
IF K 11 \>= K 55 \<= K
10 MOD DUP 6 \=/ SWAP
0 \=/ AND AND AND
THEN K POS2PT PICT
OVER K 11 + POS2PT
SUB PICT ROT EMPTY
REPL PICT EM POS2PT
ROT REPL K 'EM' STO
1 'KN' STO+
"KEYS: " KN \->STR +
1 \->GROB PICT {
# 50h # 12h } ROT
REPL
END
              END
            \>>
          END
        END
      \>>
    \>>
  CST { PLAY }
  INIT
    \<< RARR \-> RR
      \<< ERASE {
# 0h # 0h } PVIEW {
# 9h # 9h } { # 3Dh
# 3Dh } BOX 24 1
        FOR N PIECE
RR N GET GET PICT N
5 MOD 1 + N 5 / IP
1 + 10 * + POS2PT
ROT REPL -1
        STEP
      \>> PICT { # Ah
# Ah } EMPTY REPL
    \>>
  RARR
    \<< 1 24
      FOR V V
      NEXT 24 \->ARRY
24 1
      FOR B B RAND
* 1 + FLOOR \-> Q
        \<< Q OVER
SWAP GET SWAP B
OVER SWAP GET Q
SWAP PUT B ROT PUT
        \>> -1
      STEP
    \>>
  EMPTY
GROB 11 11 FF70FF70FF70FF70FF70FF70FF70FF70FF70FF70FF70
  POS2PT
    \<< DUP 10 MOD 10
* R\->B SWAP 10 / IP
10 * R\->B 2 \->LIST
    \>>
  PIECE {
GROB 11 11 FF70306010401340124012401240174010403060FF70
GROB 11 11 FF70306010401740144017401140174010403060FF70
GROB 11 11 FF70306010401740144017401440174010403060FF70
GROB 11 11 FF70306010401540154017401440144010403060FF70
GROB 11 11 FF70306010401740114017401440174010403060FF70
GROB 11 11 FF70306010401640114017401540174010403060FF70
GROB 11 11 FF70306010401740144012401140114010403060FF70
GROB 11 11 FF70306010401740154017401540174010403060FF70
GROB 11 11 FF70306010401740154017401440174010403060FF70
GROB 11 11 FF7030601040D840945094509450D94010403060FF70
GROB 11 11 FF7030601040DC40984098409840DD5010403060FF70
GROB 11 11 FF7030601040DC5090509C509440DD5010403060FF70
GROB 11 11 FF7030601040DC5090509C509050DD5010403060FF70
GROB 11 11 FF7030601040D45094509C509050D15010403060FF70
GROB 11 11 FF7030601040DC5094409C509050DD5010403060FF70
GROB 11 11 FF7030601040D85094409C509450DD5010403060FF70
GROB 11 11 FF7030601040DC50905098409440D54010403060FF70
GROB 11 11 FF7030601040DC5094509C509450DD5010403060FF70
GROB 11 11 FF7030601040DC5094509C509050DD5010403060FF70
GROB 11 11 FF7030601040D9401550D5505450D94010403060FF70
GROB 11 11 FF7030601040DD401940D9405840DD5010403060FF70
GROB 11 11 FF7030601040DD501150DD505440DD5010403060FF70
GROB 11 11 FF7030601040DD501150DD505050DD5010403060FF70
GROB 11 11 FF7030601040D5501550DD505050D15010403060FF70
}
END