programgames/racer/racer.xtl

The racer, scripted (seed 1), with the rules of Race.xtl on lib/Ecs: the cars as rows of one matrix, and driving, the grass, bumping, laps and places as systems over every car at once.

source · imports rc: games/racer/Race.xtl; ec: lib/Ecs.xtl lib/Ecs.xtlm

start : (Float, Float, Int, Int)

value · line 11
start ← ʳᶜn̲ew 0

W : Float

value · line 12
(W, t, st, pl) ← start

t : Float

value · line 12
(W, t, st, pl) ← start
Used in: W, ᵘw̲orld

st : Int

value · line 12
(W, t, st, pl) ← start
Used in: W, ᵘw̲orld

pl : Int

value · line 12
(W, t, st, pl) ← start
Used in: W, ᵘw̲orld

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

function · line 22
ᵘw̲ait ← { s n → n = 0 ? s◆ (s ʳᶜt̲ick 0.05) ᵘw̲ait n − 1 }
Used in: ᵘw̲ait, later, moved

later : (Float, Float, Int, Int)

value · line 23
later ← start ᵘw̲ait 240

sped : (Float, Float, Int, Int)

value · line 33
sped ← ((later ʳᶜk̲ey "UP") ʳᶜk̲ey "UP") ʳᶜk̲ey "UP"

moved : (Float, Float, Int, Int)

value · line 35
moved ← sped ᵘw̲ait 20

_ : Char

function · line 37
_ ← ⎕S̲HOW ʳᶜd̲raw moved

ᵘw̲orld : (Any a, Any b, Any c, Any d) => (a, b, c, d) -> a

function · line 40
ᵘw̲orld ← { (W, t, st, pl) → W }
Used in: _

_ : Unit

function · line 41
_ ← "4 = ec:c_ount u:w_orld rc:n_ew 0" a̲ssert< "four cars in a new race"
a̲ssert< expands to
({ @ → (4 = ᵉᶜc̲ount ᵘw̲orld ʳᶜn̲ew 0) ? @◆ ⎕E̲RR "assertion failed: 4 = ec:c_ount u:w_orld rc:n_ew 0 (four cars in a new race) [games/racer/racer.xtl:41]"◆ @ } @)

_ : Unit

function · line 42
_ ← "'& r_/ 1 2 3 4.0 = s_ort 3 s_elect_2 rc:c_ars moved" a̲ssert< "the places are one to four"
a̲ssert< expands to
({ @ → ('∧ r̲/ 1 2 3 4.0 = s̲ort 3 s̲elect₂ ʳᶜc̲ars moved) ? @◆ ⎕E̲RR "assertion failed: '& r_/ 1 2 3 4.0 = s_ort 3 s_elect_2 rc:c_ars moved (the places are one to four) [games/racer/racer.xtl:42]"◆ @ } @)

_ : Unit

function · line 43
_ ← "0 = rc:s_tatus moved" a̲ssert< "still racing"
a̲ssert< expands to
({ @ → (0 = ʳᶜs̲tatus moved) ? @◆ ⎕E̲RR "assertion failed: 0 = rc:s_tatus moved (still racing) [games/racer/racer.xtl:43]"◆ @ } @)