%%HP: T(3)A(D)F(.);
@ TOWERS game, by Paul Lancaster
DIR
  TOH
    \<< 0 'T' STO
"1 2 3 4 5 6 " 'S'
STO "" 'M' STO ""
'E' STO S M E {
F1T2 F1T3 F2T1 F2T3
F3T1 F3T2 } MENU
    \>>
  TOH1
    \<< CLEAR 'T' 1
STO+ 7 CF S SIZE 3
      IF >
      THEN S 1 1
SUB STR\-> S 3 3 SUB
STR\->
        IF >
        THEN 7 SF
        END
      END M SIZE 3
      IF >
      THEN M 1 1
SUB STR\-> M 3 3 SUB
STR\->
        IF >
        THEN 7 SF
        END
      END E SIZE 3
      IF >
      THEN E 1 1
SUB STR\-> E 3 3 SUB
STR\->
        IF >
        THEN 7 SF
        END
      END S M E 7
      IF FS?
      THEN B
      END DUP
"1 2 3 4 5 6 "
      IF ==
      THEN T
" TURNS" +
      END
    \>>
  F1T2
    \<< 'F2T1' 'B'
STO E 1 2 SUB E 3
12 SUB 'E' STO M +
'M' STO TOH1
    \>>
  F1T3
    \<< 'F3T1' 'B'
STO E 1 2 SUB E 3
12 SUB 'E' STO S +
'S' STO TOH1
    \>>
  F2T1
    \<< 'F1T2' 'B'
STO M 1 2 SUB M 3
12 SUB 'M' STO E +
'E' STO TOH1
    \>>
  F2T3
    \<< 'F3T2' 'B'
STO M 1 2 SUB M 3
12 SUB 'M' STO S +
'S' STO TOH1
    \>>
  F3T1
    \<< 'F1T3' 'B'
STO S 1 2 SUB S 3
12 SUB 'S' STO E +
'E' STO TOH1
    \>>
  F3T2
    \<< 'F2T3' 'B'
STO S 1 2 SUB S 3
12 SUB 'S' STO M +
'M' STO TOH1
    \>>
  CST 0
  S 0
  M 0
  E 0
  T 0
  B 0
END
