programgames/trek-adventure/trek-adventure.xtl

source · imports t: games/trek-adventure/TrekAdventure.xtl

s : Int

value · line 12
s ← ᵗn̲ew 0

s : Int

value · line 13
s ← s ᵗu̲pdate 1 5

said : Int

value · line 15
said ← s ᵗs̲ay 5

taken : Int

value · line 16
taken ← s ᵗu̲pdate 5 1 6 1

said : Int

value · line 18
said ← taken ᵗs̲ay 5

moves : Int

value · line 34
moves ← 11 2 r̲eshape 3 2 3 3 3 5 4 3 4 4 4 5 3 3 3 2 3 6 5 1 5 2
Used in: game

ᵘp̲lay : Int -> Int -> Int

function · line 35
ᵘp̲lay ← { s m →
  0 = t̲ally m ? (1 c̲at t̲ally s) r̲eshape s
  next ← ᵗc̲lock s ᵗm̲ove f̲irst m
  ((1 c̲at t̲ally s) r̲eshape s) c̲at next ᵘp̲lay 1 d̲rop m
}
Used in: ᵘp̲lay, game

game : Int

value · line 40
game ← (ᵗn̲ew 0) ᵘp̲lay moves

last : Int

value · line 42
last ← r̲avel -1 t̲ake game

said : Int

value · line 44
said ← last ᵗs̲ay 201

bay : Int

value · line 49
bay ← 8 20 1 0 0 0 1 0 1 0 0 0

said : Int

value · line 51
said ← bay ᵗs̲ay ᵗs̲aid bay ᵗm̲ove 6 0

ᵘw̲ait : Int -> Int

function · line 53
ᵘw̲ait ← { s → ᵗc̲lock s ᵗm̲ove 1 0 }

said : Int

value · line 57
said ← (ᵗn̲ew 0) ᵗs̲ay ᵗs̲aid (ᵗn̲ew 0) ᵗm̲ove 2 0

ok : Unit

value · line 62
ok ← "1 = t:s_tatus last" a̲ssert< "the scripted moves win"
a̲ssert< expands to
({ @ → (1 = ᵗs̲tatus last) ? @◆ ⎕E̲RR "assertion failed: 1 = t:s_tatus last (the scripted moves win) [games/trek-adventure/trek-adventure.xtl:62]"◆ @ } @)