programgames/blocks/blocks.xtl

Falling blocks, scripted (seed 1), with the rules of Stack.xtl: the well a matrix, a piece a small square of 0s and 1s, turning by reversing and transposing, full rows cleared by keeping the others.

source · imports st: games/blocks/Stack.xtl

T : Int

value · line 9
T ← 3 3 r̲eshape 0 1 0 1 1 1 0 0 0

w : Int

value · line 17
w ← 4 3 r̲eshape 0 0 1 2 2 2 0 3 0 4 4 4

start : (Int, Int, Int, Int, Int, Int, Int, Int, Float, Float, Int)

value · line 23
start ← ˢᵗn̲ew 0

ᵘw̲ait : (Num a, Num b) => (Int, Int, Int, Int, Int, Int, Int, Int, Float, Float, a) -> b -> (Int, Int, Int, Int, Int, Int, Int, Int, Float, Float, a)

function · line 29
ᵘw̲ait ← { s n → n = 0 ? s◆ (s ˢᵗt̲ick 0.05) ᵘw̲ait n − 1 }
Used in: ᵘw̲ait, waited

waited : (Int, Int, Int, Int, Int, Int, Int, Int, Float, Float, Int)

value · line 30
waited ← start ᵘw̲ait 40
Used in: dropped

ᵘp̲ress : (Any a, Num b) => (Int, Int, Int, Int, Int, Int, Int, Int, Float, a, b) -> Char -> (Int, Int, Int, Int, Int, Int, Int, Int, Float, a, b)

function · line 31
ᵘp̲ress ← { s k → s ˢᵗk̲ey k }
Used in: dropped, ᵘa̲uto

dropped : (Int, Int, Int, Int, Int, Int, Int, Int, Float, Float, Int)

value · line 32
dropped ← (((waited ᵘp̲ress "LEFT") ᵘp̲ress "LEFT") ᵘp̲ress "UP") ᵘp̲ress " "

ᵘa̲uto : (Any a, Num b, Num c) => (Int, Int, Int, Int, Int, Int, Int, Int, Float, a, b) -> c -> (Int, Int, Int, Int, Int, Int, Int, Int, Float, a, b)

function · line 41
ᵘa̲uto ← { s n → (n = 0) ∨ 0 < ˢᵗs̲tatus s ? s◆ (s ᵘp̲ress "h") ᵘa̲uto n − 1 }
Used in: ᵘa̲uto, later

later : (Int, Int, Int, Int, Int, Int, Int, Int, Float, Float, Int)

value · line 42
later ← dropped ᵘa̲uto 30

_ : Char

function · line 44
_ ← ⎕S̲HOW ˢᵗd̲raw later

_ : Unit

function · line 47
_ ← "'& r_/_12 (st:t_urn^4 T) = T" a̲ssert< "four quarter turns are no turn"
a̲ssert< expands to
({ @ → ('∧ r̲/₁₂ (ˢᵗt̲urn⁴ T) = T) ? @◆ ⎕E̲RR "assertion failed: '& r_/_12 (st:t_urn^4 T) = T (four quarter turns are no turn) [games/blocks/blocks.xtl:47]"◆ @ } @)

_ : Unit

function · line 48
_ ← "0 = '+ r_/ '& r_/_2 0 < st:c_lear w" a̲ssert< "no full row is left after clearing"
a̲ssert< expands to
({ @ → (0 = '+ r̲/ '∧ r̲/₂ 0 < ˢᵗc̲lear w) ? @◆ ⎕E̲RR "assertion failed: 0 = '+ r_/ '& r_/_2 0 < st:c_lear w (no full row is left after clearing) [games/blocks/blocks.xtl:48]"◆ @ } @)

_ : Unit

function · line 49
_ ← "0 = st:s_tatus later" a̲ssert< "still playing"
a̲ssert< expands to
({ @ → (0 = ˢᵗs̲tatus later) ? @◆ ⎕E̲RR "assertion failed: 0 = st:s_tatus later (still playing) [games/blocks/blocks.xtl:49]"◆ @ } @)