libraryextensions/scene/demos/Endless.xtl

Endless.xtl -- the endless world and its player, shared by the voxel demos that walk or fly in it (voxels-endless, voxels-fly, voxels-dig and those after): columns of 16 by 16 blocks made around the player and dropped behind it, each made over three frames so no frame waits long; the player -- walking, swimming, flying -- moving against them; and blocks dug out and placed, remembered as edits that every column is made with, so they stay when the player comes back. Import: "en:" u_se< "Endless"

source · imports vx: extensions/scene/demos/Voxels.xtl; sc: extensions/scene/lib/Scene.xtl

The state

ˡreach : Int

value · line 30

the columns are kept this many (16-block steps) from the player's, each way, and made within it; beyond one more they are dropped

ˡreach ← 3

ˡp̲layer : (Any a, Any b, Any c, Any d) => (a, b, c, d) -> a

function · line 33

en:p_layer s: the player (position, velocity, yaw, pitch, ground, fly)

ˡp̲layer ← { (p, _, _, _) → p }

ˡp̲osition : (Any a, Any b, Any c, Any d, Any e, Any f, Any g, Any h, Any i) => ((a, b, c, d, e, f), g, h, i) -> a

function · line 35

en:p_osition s: where the player's feet are, x y z

ˡp̲osition ← { ((x, _, _, _, _, _), _, _, _) → x }

ˡk̲eys : (Any a, Any b, Any c, Any d, Any e, Any f, Any g, Any h, Any i, Any j, Any k) => (a, (b, c, d, e, f, g, h, i), j, k) -> b

function · line 37

en:k_eys s: the columns' keys

ˡk̲eys ← { (_, (ks, _, _, _, _, _, _, _), _, _) → ks }

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

function · line 40

en:w_orld s: the world (columns, masks, edits), for en:h_it and en:p_ick

ˡw̲orld ← { (_, wo, _, _) → wo }

ˡe̲dits : (Any a, Any b, Any c, Any d, Any e, Any f, Any g, Any h, Any i, Any j, Any k) => (a, (b, c, d, e, f, g, h, i), j, k) -> f

function · line 43

en:e_dits s: the blocks dug out and placed, n by 4 (x y z block, air 0 for dug), the newest first

ˡe̲dits ← { (_, (_, _, _, _, ed, _, _, _), _, _) → ed }

ˡe̲ye : (Any a, Any b, Any c, Any d, Any e, Any f) => ((Float, a, Float, Float, b, c), d, e, f) -> Float

function · line 45

en:e_ye s: the player's eye, x y z yaw pitch (1.6 above its feet)

ˡe̲ye ← { ((x, _, yaw, pitch, _, _), _, _, _) → (x + 0.0 1.6 0.0) c̲at yaw c̲at pitch }
Used in: ˡd̲ig, ˡp̲lace

ˡw̲indow : (Any a, Any b, Any c, Any d, Any e, Any f, Any g, Any h) => (a, b, c, (d, e, f, g, h)) -> d

function · line 47

en:w_indow s: the scene window the world is drawn in

ˡw̲indow ← { (_, _, _, (w, _, _, _, _)) → w }

ˡs̲tart : (Any a, Any b, Any c, Any d, Any e, Any f, Any g, Any h) => (a, b, c, (d, e, f, g, h)) -> f

function · line 49

en:s_tart s: where the player started (x y z)

ˡs̲tart ← { (_, _, _, (_, _, x0, _, _)) → x0 }
Used in: ˡh̲omeAgain, x0

ʰk̲ey : Num a => a -> a

function (private) · line 52
ʰk̲ey ← { c → (10000 × 1000 + 1 s̲elect c) + 1000 + 2 s̲elect c }
Used in: ʰc̲ell

ʰc̲x : Int -> Int

function (private) · line 53
ʰc̲x ← { k → (k d̲iv 10000) − 1000 }

ʰc̲z : Int -> Int

function (private) · line 54
ʰc̲z ← { k → (k m̲od 10000) − 1000 }

ˡw̲ithPlayer : (Any a, Any b, Any c, Any d, Any e) => a -> (b, c, d, e) -> (a, c, d, e)

function · line 57

p en:w_ithPlayer s: the state with the player p

ˡw̲ithPlayer ← { p (_, wo, jb, st) → (p, wo, jb, st) }
Used in: ˡh̲omeAgain

ˡn̲ew : (Any a, Num b, Num c, Num d, Num e, Num f, Num g, Num h, Num i, Num j, Num k) => a -> ((Float, Float, Float, Float, Float, Float), (b, b, Box b, Box b, c, b, d, e), (f, g, h, b), (a, i, Float, j, k))

function · line 61

en:n_ew w: a world for window w, no columns made yet, the player standing above the highest ground of column (0, 0), facing north

ˡn̲ew ← { w →
  hv ← r̲avel ᵛˣh̲eightsAt 0 0 16
  i ← f̲irst w̲here hv = 'm̲ax r̲/ hv
  x0 ← ((f̲loat (i − 1) d̲iv 16) + 0.5) c̲at (f̲loat 2 + i s̲elect hv) c̲at (f̲loat (i − 1) m̲od 16) + 0.5
  w ˡn̲ewAt x0
}
Used in: s, s, s, s, s

ˡn̲ewAt : (Any a, Num b, Num c, Num d, Num e, Num f, Num g, Num h, Num i, Num j, Num k) => a -> Float -> ((Float, Float, Float, Float, Float, Float), (b, b, Box b, Box b, c, b, d, e), (f, g, h, b), (a, i, Float, j, k))

function · line 71

w en:n_ewAt x0: a world for window w, no columns made yet, the player standing at x0 (x y z, its feet; also where H goes back to), facing north

ˡn̲ewAt ← { w x0 →
  p ← (x0, 0.0 0.0 0.0, 0.0, 0.0, 0.0, 0.0)
  none ← 0 r̲eshape 0
  wo ← (none, none, 0 r̲eshape e̲nclose none, 0 r̲eshape e̲nclose none, 0 4 r̲eshape 0, none, 0 6 r̲eshape 0, 0)
  (p, wo, (0, 0 0, 0, none), (w, 1, x0, 1, 0))
}
Used in: ˡn̲ew, s

Making and dropping columns

ʰh̲ome : (Any a, Any b, Any c, Any d, Any e, Any f, Any g, Any h) => ((Float, a, b, c, d, e), f, g, h) -> Int

function (private) · line 81
ʰh̲ome ← { s →
  x ← ˡp̲osition s
  (f̲loor (1 s̲elect x) ÷ 16.0) c̲at f̲loor (3 s̲elect x) ÷ 16.0
}

ʰt̲rim : (Any a, Any b, Any c, Any d, Any e, Any h, Any i, Any j, Any k, Any l, Num m, Any n, Any o, Any p, Any q) => ((Float, a, b, c, d, e), (Int, Int, f, g, h, i, j, k), l, (m, n, o, p, q)) -> ((Float, a, b, c, d, e), (Int, Int, f, g, h, i, j, k), l, (m, n, o, p, q))

function (private) · line 88
ʰt̲rim ← { s →
  (p, (ks, ns, ms, wm, ed, rq, fl, fw), jb, st) ← s
  h ← ʰh̲ome s
  far ← ((a̲bs (ʰc̲x ks) − 1 s̲elect h) > ˡreach + 1) + (a̲bs (ʰc̲z ks) − 2 s̲elect h) > ˡreach + 1
  0 = '+ r̲/ far ? s
  j ← f̲irst w̲here far > 0
  n ← j s̲elect ns
  w ← ˡw̲indow s
  _ ← '{ w ˢᶜr̲emove! (10 × n) + ⍵ } m̲ap r̲ange 9
  keep ← j ≠ r̲ange t̲ally ks
  (p, (keep r̲eplicate ks, keep r̲eplicate ns, keep r̲eplicate ms, keep r̲eplicate wm, ed, rq, fl, fw), jb, st)
}
Used in: ˡs̲tream

ʰs̲endOne : Int -> Int -> Int

function (private) · line 103
ʰs̲endOne ← { wnt f →
  t ← 3 s̲elect wnt
  sel ← (5 s̲elect₂ f) = t
  0 = '+ r̲/ sel ? (f̲irst wnt) ˢᶜr̲emove! (10 × 2 s̲elect wnt) + t
  head ← (f̲loat 1 s̲elect wnt) c̲at (f̲loat (10 × 2 s̲elect wnt) + t) c̲at ((1 + t) s̲elect ᵛˣcolors) c̲at (t = 5) r̲eplicate 0.6
  fs ← sel r̲eplicate f
  7 > 2 s̲elect s̲hape f ? head ˢᶜq̲uads! ᵛˣc̲orners fs
  ⍝ lit: each corner its face's sunlight and lamplight, 0 to 1
  k ← t̲ally fs
  lc ← (1 + ((r̲ange 4 × k) − 1) d̲iv 4) s̲elect 6 7 s̲elect₂ fs
  head ˢᶜq̲uads! (ᵛˣc̲orners fs) c̲at₂ (f̲loat lc) ÷ 15.0
}
Used in: ʰs̲end

ˡs̲tream : (Any a, Any b, Any c, Any d, Any e, Num f, Any g, Any h, Num i) => ((Float, a, b, c, d, e), (Int, Int, Box Int, Box Int, Int, Int, Int, Int), (f, Int, Int, Int), (Int, Int, g, h, i)) -> ((Float, a, b, c, d, e), (Int, Int, Box Int, Box Int, Int, Int, Int, Int), (f, Int, Int, Int), (Int, Int, g, h, i))

function · line 122

en:s_tream s: one frame's work on the world: the first column too far away dropped, then a stage of making a column -- an edited one again, or else the nearest missing one: its blocks and solid mask (part 0), its faces (part 1), in a lit world its light (part 3), or sending them to scene (part 2) -- about 12 ms (20 for light) at most; or, when it is time, a tick of moving water

ˡs̲tream ← { s →
  trimmed ← ʰt̲rim s
  (_, (_, _, _, _, _, rq, fl, fw), (part, _, _, _), _) ← trimmed
  part = 1 ? ʰf̲aces trimmed
  part = 2 ? ʰs̲end trimmed
  part = 3 ? ʰl̲ight trimmed
  ((fw ≤ 0) × 0 < t̲ally fl) ? ʰf̲low trimmed
  ʰb̲locks ʰw̲ait trimmed
}

ʰw̲ait : (Any a, Any b, Any c, Any d, Any e, Num f, Any g, Any h, Num i) => ((Float, a, b, c, d, e), (Int, Int, Box Int, Box Int, Int, Int, Int, Int), (f, Int, Int, Int), (Int, Int, g, h, i)) -> ((Float, a, b, c, d, e), (Int, Int, Box Int, Box Int, Int, Int, Int, Int), (f, Int, Int, Int), (Int, Int, g, h, i))

function (private) · line 133
ʰw̲ait ← { (p, (ks, ns, ms, wm, ed, rq, fl, fw), jb, st) → (p, (ks, ns, ms, wm, ed, rq, fl, 0 m̲ax fw − 1), jb, st) }
Used in: ˡs̲tream

ʰb̲locks : (Any a, Any b, Any c, Any d, Any e, Num f, Any g, Any h, Num i) => ((Float, a, b, c, d, e), (Int, Int, Box Int, Box Int, Int, Int, Int, Int), (f, Int, Int, Int), (Int, Int, g, h, i)) -> ((Float, a, b, c, d, e), (Int, Int, Box Int, Box Int, Int, Int, Int, Int), (f, Int, Int, Int), (Int, Int, g, h, i))

function (private) · line 138
ʰb̲locks ← { s →
  (p, (ks, ns, ms, wm, ed, rq, fl, fw), jb, (w, nxt, x0, on, lit)) ← s
  0 < t̲ally rq ? ʰr̲emake s
  h ← ʰh̲ome s
  r ← ˡreach
  o ← (r̲ange 1 + 2 × r) − 1 + r
  dx ← r̲avel o '+ t̲able 0 × o
  dz ← r̲avel (0 × o) '+ t̲able o
  ws ← (10000 × 1000 + dx + 1 s̲elect h) + 1000 + dz + 2 s̲elect h
  miss ← (0 = ws m̲ember? ks) r̲eplicate (r̲ange t̲ally ws)
  0 = t̲ally miss ? s
  d ← (miss s̲elect dx × dx) + miss s̲elect dz × dz
  i ← f̲irst (d = 'm̲in r̲/ d) r̲eplicate miss
  c ← ((i s̲elect dx) + 1 s̲elect h) c̲at (i s̲elect dz) + 2 s̲elect h
  b ← (ed, c) ˡe̲dited ᵛˣc̲olumnBlocks c
  wo ← (ks c̲at i s̲elect ws, ns c̲at nxt, ms c̲at (e̲nclose ᵛˣc̲olumnMask b), wm c̲at (e̲nclose ᵛˣc̲olumnWater b), ed, rq, fl, fw)
  (p, wo, (1, c, nxt, r̲avel b), (w, nxt + 1, x0, on, lit))
}
Used in: ˡs̲tream

ʰr̲emake : (Any a, Any b, Any c, Any d, Any e, Num f, Any g, Any h, Num i) => ((Float, a, b, c, d, e), (Int, Int, Box Int, Box Int, Int, Int, Int, Int), (f, Int, Int, Int), (Int, Int, g, h, i)) -> ((Float, a, b, c, d, e), (Int, Int, Box Int, Box Int, Int, Int, Int, Int), (f, Int, Int, Int), (Int, Int, g, h, i))

function (private) · line 160
ʰr̲emake ← { (p, (ks, ns, ms, wm, ed, rq, fl, fw), jb, st) →
  k ← f̲irst rq
  rest ← 1 d̲rop rq
  j ← ks i̲ndexOf k
  j > t̲ally ks ? (p, (ks, ns, ms, wm, ed, rest, fl, fw), jb, st)
  c ← (ʰc̲x k) c̲at ʰc̲z k
  b ← (ed, c) ˡe̲dited ᵛˣc̲olumnBlocks c
  masks ← ((j − 1) t̲ake ms) c̲at (e̲nclose ᵛˣc̲olumnMask b) c̲at j d̲rop ms
  waters ← ((j − 1) t̲ake wm) c̲at (e̲nclose ᵛˣc̲olumnWater b) c̲at j d̲rop wm
  ⍝ the column changed: the water wakes (its masks are new now)
  (p, (ks, ns, masks, waters, ed, rest, fl, 0), (1, c, j s̲elect ns, r̲avel b), st)
}
Used in: ʰb̲locks

ˡe̲dited : (Int, Int) -> Int -> Int

function · line 176

(edits, c) en:e_dited b: the blocks b of column c (18 by 32 by 18, with its border of one) with the edits (n by 4, x y z block) that fall in them -- the newest first, so the newest edit of a cell wins

ˡe̲dited ← { (ed, c) b →
  0 = t̲ally ed ? b
  lx ← (1 s̲elect₂ ed) − (16 × 1 s̲elect c) − 1
  lz ← (3 s̲elect₂ ed) − (16 × 2 s̲elect c) − 1
  ly ← 2 s̲elect₂ ed
  here ← (lx ≥ 0) × (lx ≤ 17) × (lz ≥ 0) × lz ≤ 17
  0 = '+ r̲/ here ? b
  at ← here r̲eplicate 1 + lz + 18 × ly + 32 × lx
  t ← here r̲eplicate 4 s̲elect₂ ed
  v ← r̲avel b
  hit ← at i̲ndexOf r̲ange t̲ally v
  set ← hit ≤ t̲ally at
  18 32 18 r̲eshape (v × 1 − set) + set × hit s̲elect t c̲at 0
}

ʰf̲aces : (Any a, Any b, Any c, Any d, Any e, Num f, Any g, Any h, Num i) => ((Float, a, b, c, d, e), (Int, Int, Box Int, Box Int, Int, Int, Int, Int), (f, Int, Int, Int), (Int, Int, g, h, i)) -> ((Float, a, b, c, d, e), (Int, Int, Box Int, Box Int, Int, Int, Int, Int), (f, Int, Int, Int), (Int, Int, g, h, i))

function (private) · line 193
ʰf̲aces ← { (p, wo, (_, c, n, b), st) →
  (_, _, _, _, lit) ← st
  f ← c ᵛˣc̲olumnFaces 18 32 18 r̲eshape b
  0 = lit ? (p, wo, (2, c, n, r̲avel f), st)
  (p, wo, (3, c, n, b c̲at r̲avel f), st)
}
Used in: ˡs̲tream

ʰl̲ight : (Any a, Any b, Any c, Any d, Any e, Num f, Any g, Any h, Num i) => ((Float, a, b, c, d, e), (Int, Int, Box Int, Box Int, Int, Int, Int, Int), (f, Int, Int, Int), (Int, Int, g, h, i)) -> ((Float, a, b, c, d, e), (Int, Int, Box Int, Box Int, Int, Int, Int, Int), (f, Int, Int, Int), (Int, Int, g, h, i))

function (private) · line 202
ʰl̲ight ← { (p, wo, (_, c, n, v), st) →
  b ← 18 32 18 r̲eshape 10368 t̲ake v
  f ← (((t̲ally 10368 d̲rop v) d̲iv 5) c̲at 5) r̲eshape 10368 d̲rop v
  shaded ← f c̲at₂ (c, ᵛˣc̲olumnLight b) ᵛˣf̲aceLight f
  (p, wo, (2, c, n, r̲avel shaded), st)
}
Used in: ˡs̲tream

ʰs̲end : (Any a, Any b, Any c, Any d, Any e, Num f, Any g, Any h, Num i) => ((Float, a, b, c, d, e), (Int, Int, Box Int, Box Int, Int, Int, Int, Int), (f, Int, Int, Int), (Int, Int, g, h, i)) -> ((Float, a, b, c, d, e), (Int, Int, Box Int, Box Int, Int, Int, Int, Int), (f, Int, Int, Int), (Int, Int, g, h, i))

function (private) · line 211
ʰs̲end ← { (p, wo, (_, c, n, v), st) →
  (w, _, _, _, lit) ← st
  k ← 5 + 2 × 0 < lit
  f ← (((t̲ally v) d̲iv k) c̲at k) r̲eshape v
  sent ← '{ (w c̲at n c̲at ⍵) ʰs̲endOne f } m̲ap r̲ange 9
  (p, wo, (0, c, n, 0 r̲eshape 0), st)
}
Used in: ˡs̲tream

Collision

ʰc̲ell : (Any a, Num b, Any c, Any d, Any e, Any f, Any g, Num h, Truthy h) => (Int, a, Box b, c, d, e, f, g) -> Int -> h

function (private) · line 223
ʰc̲ell ← { (ks, _, ms, _, _, _, _, _) v →
  x ← 1 s̲elect v
  z ← 2 s̲elect v
  ys ← 2 d̲rop v
  i ← ks i̲ndexOf ʰk̲ey (x d̲iv 16) c̲at z d̲iv 16
  i > t̲ally ks ? 1
  0 < '+ r̲/ (1 + (z m̲od 16) + 16 × ys + 32 × x m̲od 16) s̲elect d̲isclose i s̲elect ms
}
Used in: ˡh̲it

ˡh̲it : (Any a, Num b, Any c, Any d, Any e, Any f, Any g) => (Int, a, Box b, c, d, e, f, g) -> Float -> Float

function · line 235

wo en:h_it q: whether the player's box (0.6 wide, 1.75 tall) with its feet at q (x y z) overlaps a solid block of the world wo; below the world is solid, above it air

ˡh̲it ← { wo q →
  x ← 1 s̲elect q
  y ← 2 s̲elect q
  z ← 3 s̲elect q
  cx ← u̲nique f̲loor (x − 0.3) c̲at x + 0.3
  cy ← u̲nique f̲loor y c̲at (y + 0.9) c̲at y + 1.75
  cz ← u̲nique f̲loor (z − 0.3) c̲at z + 0.3
  0 < '+ r̲/ cy < 0 ? 1.0
  inside ← (cy ≤ 31) r̲eplicate cy
  0 = t̲ally inside ? 0.0
  px ← r̲avel cx '{ ⍺ + 0 × ⍵ } t̲able cz
  pz ← r̲avel cx '{ ⍵ + 0 × ⍺ } t̲able cz
  hits ← '{ wo ʰc̲ell (⍵ s̲elect px) c̲at (⍵ s̲elect pz) c̲at inside } e̲ach r̲ange t̲ally px
  f̲loat 0 < '+ r̲/ hits
}
Used in: ʰm̲x, ʰm̲z, ʰm̲y

Digging and building

ˡp̲ick : (Any a, Num b, Truthy b, Any c, Any d, Any e, Any f, Any g) => (Int, a, Box b, c, d, e, f, g) -> Float -> Int

function · line 260

wo en:p_ick e: the block looked at from the eye e (x y z yaw pitch) within 5 blocks, found by 100 points marched along the view ray and looked up in the masks of the columns they cross: 1 and its cell x y z, then 1 and the empty cell just before it (where a block placed goes), or 0 0 0 0 when there is none; all 0 when nothing solid is that near. Water is not solid (the ray goes through it); a column not made yet is empty.

ˡp̲ick ← { (ks, _, ms, _, _, _, _, _) e →
  yaw ← 4 s̲elect e
  pitch ← 5 s̲elect e
  t ← 0.05 × f̲loat r̲ange 100
  px ← f̲loor (1 s̲elect e) + t × (s̲in yaw) × c̲os pitch
  py ← f̲loor (2 s̲elect e) + t × s̲in pitch
  pz ← f̲loor (3 s̲elect e) − t × (c̲os yaw) × c̲os pitch
  keys ← (10000 × 1000 + px d̲iv 16) + 1000 + pz d̲iv 16
  u ← u̲nique keys
  j ← ks i̲ndexOf u
  all ← d̲isclose '{ e̲nclose (d̲isclose ⍺) c̲at d̲isclose ⍵ } r̲/ j s̲elect ms c̲at e̲nclose 0 × d̲isclose f̲irst ms
  ok ← (py ≥ 0) × py ≤ 31
  at ← (8192 × (u i̲ndexOf keys) − 1) + 1 + (pz m̲od 16) + 16 × (0 m̲ax 31 m̲in py) + 32 × px m̲od 16
  solid ← ok × at s̲elect all
  0 = '+ r̲/ solid ? 8 r̲eshape 0
  i ← f̲irst w̲here solid > 0
  cell ← (i s̲elect px) c̲at (i s̲elect py) c̲at i s̲elect pz
  other ← 0 < (px ≠ i s̲elect px) + (py ≠ i s̲elect py) + pz ≠ i s̲elect pz
  prev ← w̲here ((r̲ange 100) < i) × other
  0 = t̲ally prev ? 1 c̲at cell c̲at 0 0 0 0
  k ← f̲irst -1 t̲ake prev
  1 c̲at cell c̲at 1 c̲at (k s̲elect px) c̲at (k s̲elect py) c̲at k s̲elect pz
}
Used in: ˡd̲ig, ˡp̲lace

ˡs̲et : (Any a, Any b, Any c) => (Int, Int) -> (a, (Int, Int, Box Int, Box Int, Int, Int, Int, Int), b, c) -> (a, (Int, Int, Box Int, Box Int, Int, Int, Int, Int), b, c)

function · line 292

(cell, block) en:s_et s: the block at the cell (x y z) set -- air, 0, to dig it out -- and remembered (the newest edit first); its column made again before any new one, and a neighbor too when the cell is on their border (its faces against the cell change). Water (block 5) is not an edit: placed, it is a full block of moving water in the cell; dug out beside the sea (at a side or above), the cell fills from it. A solid block placed in moving water takes its place (that water is gone). Any change wakes the water.

ˡs̲et ← { (q, t) s →
  (_, wo, _, _) ← s
  t = 5 ? (1 6 r̲eshape q c̲at ˡfull c̲at 0 0) ˡp̲our s
  placed ← ((1 3 r̲eshape q), t) ˡs̲etAll (q, t) ʰd̲isplace s
  sea ← (t = 0) × 0 < '+ r̲/ 2 = wo ˡl̲ook (5 3 r̲eshape q) + 5 3 r̲eshape 0 1 0  -1 0 0  1 0 0  0 0 -1  0 0 1
  0 = sea ? placed
  (1 6 r̲eshape q c̲at ˡfull c̲at 0 0) ˡp̲our placed
}
Used in: ˡd̲ig, ˡp̲lace

ˡs̲etAll : (Any a, Any b, Any c) => (Int, Int) -> (a, (Int, Int, Box Int, Box Int, Int, Int, Int, Int), b, c) -> (a, (Int, Int, Box Int, Box Int, Int, Int, Int, Int), b, c)

function · line 303

(cells, block) en:s_etAll s: the cells (n by 3, x y z) all set to the block, as en:s_et (without the water), their columns queued once

ˡs̲etAll ← { (q, t) s →
  (p, (ks, ns, ms, wm, ed, rq, fl, fw), jb, st) ← s
  n ← 1 s̲elect s̲hape q
  edits ← (q c̲at₂ (n c̲at 1) r̲eshape t) c̲at ed
  x ← 1 s̲elect₂ q
  z ← 3 s̲elect₂ q
  want ← 2 1 t̲ranspose (5 c̲at n) r̲eshape (n r̲eshape 1) c̲at ((x m̲od 16) = 0) c̲at ((x m̲od 16) = 15) c̲at ((z m̲od 16) = 0) c̲at (z m̲od 16) = 15
  kx ← (x d̲iv 16) '+ t̲able 0 -1 1 0 0
  near ← u̲nique (r̲avel want) r̲eplicate r̲avel (10000 × 1000 + kx) + 1000 + (z d̲iv 16) '+ t̲able 0 0 0 -1 1
  (p, (ks, ns, ms, wm, edits, near c̲at (0 = rq m̲ember? near) r̲eplicate rq, fl, fw), jb, st)
}
Used in: ˡs̲et, seeded, banked

ˡp̲our : (Any a, Any b, Any c) => Int -> (a, (Int, Int, Box Int, Box Int, Int, Int, Int, Int), b, c) -> (a, (Int, Int, Box Int, Box Int, Int, Int, Int, Int), b, c)

function · line 317

f en:p_our s: the cells f (n by 6: x y z, amount 1 to en:full, and the direction it moves, dx dz) added to the moving water, which wakes

ˡp̲our ← { f (p, (ks, ns, ms, wm, ed, rq, W, fw), jb, st) → (p, (ks, ns, ms, wm, ed, rq, f c̲at W, 0), jb, st) }
Used in: ˡs̲et, flooded

ʰd̲isplace : (Any a, Any b, Any c) => (Int, Int) -> (a, (Int, Int, Box Int, Box Int, Int, Int, Int, Int), b, c) -> (a, (Int, Int, Box Int, Box Int, Int, Int, Int, Int), b, c)

function (private) · line 321
ʰd̲isplace ← { qt (p, (ks, ns, ms, wm, ed, rq, W, fw), jb, st) →
  (q, t) ← qt
  keep ← (t = 0) + (ʰc̲ellKey 1 2 3 s̲elect₂ W) ≠ f̲irst ʰc̲ellKey 1 3 r̲eshape q
  (p, (ks, ns, ms, wm, ed, rq, (0 < keep) r̲eplicate W, 0), jb, st)
}
Used in: ˡs̲et

ˡl̲ook : (Int, Int, Box Int, Box Int, Int, Int, Int, Int) -> Int -> Int

function · line 329

wo en:l_ook q: what is at each cell of q (n by 3, x y z) in the world wo: 0 air, 1 solid, 2 water; below the world, and a column not made yet, are solid; above it is air

ˡl̲ook ← { (ks, _, ms, wm, _, _, _, _) q →
  0 = t̲ally q ? 0 r̲eshape 0
  0 = t̲ally ms ? (t̲ally q) r̲eshape 1
  x ← 1 s̲elect₂ q
  y ← 2 s̲elect₂ q
  z ← 3 s̲elect₂ q
  keys ← (10000 × 1000 + x d̲iv 16) + 1000 + z d̲iv 16
  u ← u̲nique keys
  j ← ks i̲ndexOf u
  m ← 0 × d̲isclose f̲irst ms
  sol ← d̲isclose '{ e̲nclose (d̲isclose ⍺) c̲at d̲isclose ⍵ } r̲/ j s̲elect ms c̲at e̲nclose 1 + m
  wat ← d̲isclose '{ e̲nclose (d̲isclose ⍺) c̲at d̲isclose ⍵ } r̲/ j s̲elect wm c̲at e̲nclose m
  ok ← (y ≥ 0) × y ≤ 31
  at ← (8192 × (u i̲ndexOf keys) − 1) + 1 + (z m̲od 16) + 16 × (0 m̲ax 31 m̲in y) + 32 × x m̲od 16
  hard ← 0 < (y < 0) + ok × at s̲elect sol
  wet ← (1 − hard) × 0 < ok × at s̲elect wat
  ⍝ an Int for certain (f_loor f_loat), so the type checker settles it
  ⍝ the same way every run (ask E9)
  f̲loor f̲loat hard + 2 × wet
}

Moving water

ˡpace : Int

value · line 380

the frames between ticks of moving water

ˡpace ← 1
Used in: ʰn̲ext

ˡfull : Int

value · line 384

the units of water in a full block: fine enough that a lake can drain to within a sliver of its breach (a difference of one unit stays put)

ˡfull ← 64

ʰc̲ellKey : Int -> Int

function (private) · line 388
ʰc̲ellKey ← { q → (200000 × (64 × 100000 + 1 s̲elect₂ q) + 2 s̲elect₂ q) + 100000 + 3 s̲elect₂ q }

ʰs̲hift : Int -> Int -> Int

function (private) · line 391
ʰs̲hift ← { q o → q + ((1 s̲elect s̲hape q) c̲at 3) r̲eshape o }

ʰf̲low : (Any a, Any b, Any c, Any d, Any e, Num f, Any g, Any h, Num i) => ((Float, a, b, c, d, e), (Int, Int, Box Int, Box Int, Int, Int, Int, Int), (f, Int, Int, Int), (Int, Int, g, h, i)) -> ((Float, a, b, c, d, e), (Int, Int, Box Int, Box Int, Int, Int, Int, Int), (f, Int, Int, Int), (Int, Int, g, h, i))

function (private) · line 394
ʰf̲low ← { s →
  (p, wo, jb, st) ← s
  (ks, ns, ms, wm, ed, rq, W, fw) ← wo
  (P, A, D) ← (wo, 0 1) ʰs̲pread (wo, 0 -1) ʰs̲pread (wo, 1 0) ʰs̲pread (wo, -1 0) ʰs̲pread wo ʰf̲all wo ʰr̲efill W
  live ← A > 0
  n ← '+ r̲/ live
  W2 ← (live r̲eplicate P) c̲at₂ ((n c̲at 1) r̲eshape live r̲eplicate A) c̲at₂ live r̲eplicate D
  still ← W2 m̲atch W
  z ← (wo, W2) ʰd̲rawWater ˡw̲indow s
  (p, (ks, ns, ms, wm, ed, rq, W2, still ʰn̲ext 0), jb, st)
}
Used in: ˡs̲tream

ʰn̲ext : (Truthy a, Num b) => a -> b -> Int

function (private) · line 407
ʰn̲ext ← { still z →
  still ? 1000000000
  ˡpace
}
Used in: ʰf̲low

ʰr̲efill : (Int, Int, Box Int, Box Int, Int, Int, Int, Int) -> Int -> (Int, Int, Int)

function (private) · line 414
ʰr̲efill ← { wo W →
  P ← 1 2 3 s̲elect₂ W
  A ← 4 s̲elect₂ W
  D ← 5 6 s̲elect₂ W
  sides ← (P ʰs̲hift -1 0 0) c̲at (P ʰs̲hift 1 0 0) c̲at (P ʰs̲hift 0 0 -1) c̲at (P ʰs̲hift 0 0 1) c̲at P ʰs̲hift 0 1 0
  sea ← 0 < '+ r̲/₁ (5 c̲at t̲ally A) r̲eshape 2 = wo ˡl̲ook sides
  (P, (ˡfull × sea) + (1 − sea) × A, D)
}
Used in: ʰf̲low

ʰf̲all : (Int, Int, Box Int, Box Int, Int, Int, Int, Int) -> (Int, Int, Int) -> (Int, Int, Int)

function (private) · line 425
ʰf̲all ← { wo (P, A, D) →
  n ← t̲ally A
  keys ← ʰc̲ellKey P
  dn ← P ʰs̲hift 0 -1 0
  kd ← wo ˡl̲ook dn
  jd ← keys i̲ndexOf ʰc̲ellKey dn
  room ← (kd = 0) × ˡfull − jd s̲elect A c̲at 0
  f ← ((kd = 2) × A) + (kd ≠ 2) × A m̲in room
  ja ← keys i̲ndexOf ʰc̲ellKey P ʰs̲hift 0 1 0
  settled ← (A − f) + (ja s̲elect f c̲at 0) × ja ≤ n
  new ← (f > 0) × (kd = 0) × jd > n
  m ← '+ r̲/ new
  (P c̲at new r̲eplicate dn, settled c̲at new r̲eplicate f, D c̲at new r̲eplicate D)
}
Used in: ʰf̲low

ʰs̲pread : ((Int, Int, Box Int, Box Int, Int, Int, Int, Int), Int) -> (Int, Int, Int) -> (Int, Int, Int)

function (private) · line 443
ʰs̲pread ← { woo (P, A, D) →
  (wo, o) ← woo
  n ← t̲ally A
  off ← (1 s̲elect o) c̲at 0 c̲at 2 s̲elect o
  keys ← ʰc̲ellKey P
  side ← P ʰs̲hift off
  ks ← wo ˡl̲ook side
  js ← keys i̲ndexOf ʰc̲ellKey side
  bs ← js s̲elect A c̲at 0
  dn ← P ʰs̲hift 0 -1 0
  jd ← keys i̲ndexOf ʰc̲ellKey dn
  held ← ((wo ˡl̲ook dn) = 1) + ˡfull = jd s̲elect A c̲at 0
  drop ← 0 = wo ˡl̲ook side ʰs̲hift 0 -1 0
  ahead ← ((1 s̲elect₂ D) = 1 s̲elect o) × (2 s̲elect₂ D) = 2 s̲elect o
  wt ← 4 m̲ax (7 × ahead) m̲ax 8 × drop
  go ← (ks = 0) × (0 < held) × A > bs
  ⍝ at most half the difference: neighbors even out, never trade places
  ⍝ a stream's front keeps going the way it moves, and over an edge,
  ⍝ even by 1 (only into an empty cell, so water cannot circle)
  t ← ((go × ((A − bs) × wt) d̲iv 16) m̲ax
    go × ((A − bs) ≥ 2) + (bs = 0) × 0 < ahead + drop)
  moved ← t m̲in (ˡfull − bs) m̲in A
  jf ← keys i̲ndexOf ʰc̲ellKey P ʰs̲hift 0 − off
  got ← (jf s̲elect moved c̲at 0) × jf ≤ n
  after ← (A − moved) + got
  dx ← ((got > 0) × 1 s̲elect o) + (got = 0) × 1 s̲elect₂ D
  heading ← 2 1 t̲ranspose (2 c̲at n) r̲eshape dx c̲at ((got > 0) × 2 s̲elect o) + (got = 0) × 2 s̲elect₂ D
  new ← (moved > 0) × js > n
  m ← '+ r̲/ new
  (P c̲at new r̲eplicate side, after c̲at new r̲eplicate moved, heading c̲at (m c̲at 2) r̲eshape o)
}
Used in: ʰf̲low

ʰd̲rawWater : ((Int, Int, Box Int, Box Int, Int, Int, Int, Int), Int) -> Int -> Int

function (private) · line 478
ʰd̲rawWater ← { woW w →
  (wo, W) ← woW
  0 = t̲ally W ? w ˢᶜr̲emove! 9
  P ← 1 2 3 s̲elect₂ W
  A ← 4 s̲elect₂ W
  keys ← ʰc̲ellKey P
  n ← t̲ally A
  x ← f̲loat 1 s̲elect₂ P
  y ← f̲loat 2 s̲elect₂ P
  z ← f̲loat 3 s̲elect₂ P
  ht ← y + (f̲loat A) ÷ f̲loat ˡfull
  d̲ry ← { o → (0 = wo ˡl̲ook P ʰs̲hift o) × n < keys i̲ndexOf ʰc̲ellKey P ʰs̲hift o }
  top ← (n < keys i̲ndexOf ʰc̲ellKey P ʰs̲hift 0 1 0) × 2 ≠ wo ˡl̲ook P ʰs̲hift 0 1 0
  q ← (((top, (x, ht, z), (x + 1.0, ht, z), (x + 1.0, ht, z + 1.0), (x, ht, z + 1.0)) ʰq̲uads 0) c̲at
    ((d̲ry -1 0 0, (x, y, z), (x, y, z + 1.0), (x, ht, z + 1.0), (x, ht, z)) ʰq̲uads 0) c̲at
    ((d̲ry 1 0 0, (x + 1.0, y, z), (x + 1.0, y, z + 1.0), (x + 1.0, ht, z + 1.0), (x + 1.0, ht, z)) ʰq̲uads 0) c̲at
    ((d̲ry 0 0 -1, (x, y, z), (x + 1.0, y, z), (x + 1.0, ht, z), (x, ht, z)) ʰq̲uads 0) c̲at
    ((d̲ry 0 0 1, (x, y, z + 1.0), (x + 1.0, y, z + 1.0), (x + 1.0, ht, z + 1.0), (x, ht, z + 1.0)) ʰq̲uads 0) c̲at
    (d̲ry 0 -1 0, (x, y, z), (x + 1.0, y, z), (x + 1.0, y, z + 1.0), (x, y, z + 1.0)) ʰq̲uads 0)
  0 = t̲ally q ? w ˢᶜr̲emove! 9
  ⍝ in full sunlight: as bright as unlit by day, dimming at night
  ((f̲loat w) c̲at 9.0 c̲at ((6 s̲elect ᵛˣcolors) c̲at 0.6)) ˢᶜq̲uads! q c̲at₂ ((t̲ally q) c̲at 2) r̲eshape 1.0 0.0
}
Used in: ʰf̲low

ʰq̲uads : Num a => (Int, (Float, Float, Float), (Float, Float, Float), (Float, Float, Float), (Float, Float, Float)) -> a -> Float

function (private) · line 505
ʰq̲uads ← { (m, k1, k2, k3, k4) z →
  k ← '+ r̲/ m
  0 = k ? 0 3 r̲eshape 0.0
  c̲orner ← { (a, b, cz) → 2 1 t̲ranspose (3 c̲at k) r̲eshape (m r̲eplicate a) c̲at (m r̲eplicate b) c̲at m r̲eplicate cz }
  ((4 × k) c̲at 3) r̲eshape 2 1 3 t̲ranspose (4 c̲at k c̲at 3) r̲eshape (c̲orner k1) c̲at (c̲orner k2) c̲at (c̲orner k3) c̲at c̲orner k4
}
Used in: ʰd̲rawWater

ˡw̲ater : (Any a, Any b, Any c, Any d, Any e, Any f, Any g, Any h, Any i, Any j, Any k) => (a, (b, c, d, e, f, g, h, i), j, k) -> h

function · line 514

en:w_ater s: the moving water, n by 6: x y z, amount (1 to en:full units, a full block) and the direction it moves (dx dz)

ˡw̲ater ← { (_, (_, _, _, _, _, _, W, _), _, _) → W }

ˡa̲sleep : (Any a, Any b, Any c, Any d, Any e, Any f, Any g, Any h, Num i, Any j, Any k, Truthy l) => (a, (b, c, d, e, f, g, h, i), j, k) -> l

function · line 518

en:a_sleep s: whether the water is asleep (a tick moved nothing and nothing has changed since)

ˡa̲sleep ← { (_, (_, _, _, _, _, _, _, fw), _, _) → fw > 1000000 }
Used in: ᵘf̲rame

ˡw̲aterUnits : (Any a, Any b, Any c, Any d, Any e, Any f, Any g, Num h, Any i, Any j, Any k) => (a, (b, c, d, e, f, g, h, i), j, k) -> h

function · line 521

en:w_aterUnits s: how much water is moving, in units (en:full a block)

ˡw̲aterUnits ← { s → '+ r̲/ 4 s̲elect₂ ˡw̲ater s }
Used in: ᵘm̲easure

ˡo̲verlaps : (Num a, Truthy b) => Float -> a -> b

function · line 526

p en:o_verlaps q: whether the player's box (0.6 wide, 1.75 tall) with its feet at p (x y z) overlaps the cell q (x y z) -- no block is placed there

ˡo̲verlaps ← { p q →
  d ← (f̲loat q) − p
  3 = '+ r̲/ (d > -1.3 -1.0 -1.3) × d < 0.3 1.75 0.3
}
Used in: ˡp̲lace

The player

ˡdt : Float

value · line 534

a frame: 1/60 s

ˡdt ← 1.0 ÷ 60.0

ʰs̲et3 : Float -> Float -> Float

function (private) · line 537
ʰs̲et3 ← { l x → x + (f̲loat (r̲ange 3) = f̲loor 1 s̲elect l) × (2 s̲elect l) − x }
Used in: ʰm̲x, ʰm̲z, ʰm̲y

ʰs̲nap : Float -> Float -> Float

function (private) · line 540
ʰs̲nap ← { v a →
  v > 0.0 ? (f̲loat f̲loor a + 0.3) − 0.3001
  (f̲loat 1 + f̲loor a − 0.3) + 0.3001
}
Used in: ʰm̲x, ʰm̲z

ʰm̲x : (Any a, Num b, Any c, Any d, Any e, Any f, Any g, Any h, Any i, Any j, Any k) => (Int, a, Box b, c, d, e, f, g) -> (Float, Float, h, i, j, k) -> (Float, Float, h, i, j, k)

function (private) · line 547
ʰm̲x ← { wo (x, v, yaw, pitch, g, fly) →
  a ← (1 s̲elect x) + ˡdt × 1 s̲elect v
  q ← (1.0 c̲at a) ʰs̲et3 x
  0 = wo ˡh̲it q ? (q, v, yaw, pitch, g, fly)
  ((1.0 c̲at (1 s̲elect v) ʰs̲nap a) ʰs̲et3 x, (1.0 c̲at 0.0) ʰs̲et3 v, yaw, pitch, g, fly)
}
Used in: ˡm̲ove

ʰm̲z : (Any a, Num b, Any c, Any d, Any e, Any f, Any g, Any h, Any i, Any j, Any k) => (Int, a, Box b, c, d, e, f, g) -> (Float, Float, h, i, j, k) -> (Float, Float, h, i, j, k)

function (private) · line 553
ʰm̲z ← { wo (x, v, yaw, pitch, g, fly) →
  a ← (3 s̲elect x) + ˡdt × 3 s̲elect v
  q ← (3.0 c̲at a) ʰs̲et3 x
  0 = wo ˡh̲it q ? (q, v, yaw, pitch, g, fly)
  ((3.0 c̲at (3 s̲elect v) ʰs̲nap a) ʰs̲et3 x, (3.0 c̲at 0.0) ʰs̲et3 v, yaw, pitch, g, fly)
}
Used in: ˡm̲ove

ʰm̲y : (Any a, Num b, Any c, Any d, Any e, Any f, Any g, Any h, Any i, Any j) => (Int, a, Box b, c, d, e, f, g) -> (Float, Float, h, i, Float, j) -> (Float, Float, h, i, Float, j)

function (private) · line 559
ʰm̲y ← { wo (x, v, yaw, pitch, g, fly) →
  a ← (2 s̲elect x) + ˡdt × 2 s̲elect v
  q ← (2.0 c̲at a) ʰs̲et3 x
  0 = wo ˡh̲it q ? (q, v, yaw, pitch, 0.0, fly)
  (2 s̲elect v) > 0.0 ? ((2.0 c̲at (f̲loat f̲loor a + 1.75) − 1.7501) ʰs̲et3 x, (2.0 c̲at 0.0) ʰs̲et3 v, yaw, pitch, g, fly)
  ((2.0 c̲at f̲loat 1 + f̲loor a) ʰs̲et3 x, (2.0 c̲at 0.0) ʰs̲et3 v, yaw, pitch, 1.0, fly)
}
Used in: ˡm̲ove

ˡm̲ove : (Any a, Num b, Any c, Any d, Any e, Any f, Any g, Any h, Num i, Any j, Any k, Any l, Any m) => ((Float, Float, Float, Float, Float, Float), (Int, a, Box b, c, d, e, f, g), h, (i, j, k, l, m)) -> Float -> ((Float, Float, Float, Float, Float, Float), (Int, a, Box b, c, d, e, f, g), h, (i, j, k, l, m))

function · line 574

s en:m_ove k: one frame of the player under the controls k (mouse dx dy, then 1 for each held: w a s d space shift left right up down), walking or flying, the camera set to its eye. Walking: W A S D, Shift runs, Space jumps; in water (all air below the sea at 14) it sinks slowly, Space swims up, and from the surface Space climbs onto a bank one block high. Flying: W A S D level by the heading, Space up, Shift down, 15 blocks a second, no gravity, the blocks still stopping it.

ˡm̲ove ← { s k →
  ((x, v, yaw, pitch, g, fly), wo, jb, st) ← s
  turn ← yaw + (0.005 × 1 s̲elect k) + 2.0 × ˡdt × (10 s̲elect k) − 9 s̲elect k
  tilt ← -1.5 m̲ax 1.5 m̲in pitch + (-0.005 × 2 s̲elect k) + 1.5 × ˡdt × (11 s̲elect k) − 12 s̲elect k
  fwd ← (3 s̲elect k) − 5 s̲elect k
  side ← (6 s̲elect k) − 4 s̲elect k
  wet ← (1.0 − fly) × f̲loat 14.0 > 0.9 + 2 s̲elect x
  speed ← (fly × 15.0) + (1.0 − fly) × (1.0 − 0.4 × wet) × 4.5 × 1.0 + 8 s̲elect k
  vx ← speed × ((s̲in turn) × fwd) + (c̲os turn) × side
  vz ← speed × ((0.0 − c̲os turn) × fwd) + (s̲in turn) × side
  surface ← (1.0 − fly) × (f̲loat 14.5 > 2 s̲elect x) × f̲loat 13.0 < 2 s̲elect x
  jump ← (1.0 − fly) × (1.0 m̲in g + surface × 1.0 − wet) × 7 s̲elect k
  swim ← wet × 7 s̲elect k
  fall ← -30.0 m̲ax (2 s̲elect v) − 22.0 × ˡdt
  sink ← -2.0 m̲ax (2 s̲elect v) − 6.0 × ˡdt
  walkVy ← (7.5 × jump) + (1.0 − jump) × (4.0 × swim) + (1.0 − swim) × (wet × sink) + (1.0 − wet) × fall
  flyVy ← ((80.0 − 2 s̲elect x) × 60.0) m̲in 15.0 × (7 s̲elect k) − 8 s̲elect k
  vy ← (fly × flyVy) + (1.0 − fly) × walkVy
  p ← wo ʰm̲y wo ʰm̲z wo ʰm̲x (x, vx c̲at vy c̲at vz, turn, tilt, g, fly)
  (x2, _, _, _, _, _) ← p
  _ ← (ˡw̲indow s) ˢᶜe̲ye! (1 s̲elect x2) c̲at ((2 s̲elect x2) + 1.6) c̲at (3 s̲elect x2) c̲at turn c̲at tilt
  (p, wo, jb, st)
}

ˡh̲omeAgain : (Any a, Any b, Any c, Any d, Any e, Any f, Any g, Any h) => (a, b, c, (d, e, f, g, h)) -> ((f, Float, Float, Float, Float, Float), b, c, (d, e, f, g, h))

function · line 600

en:h_omeAgain s: the player back at the start, standing still, walking

ˡh̲omeAgain ← { s → (ˡs̲tart s, 0.0 0.0 0.0, 0.0, 0.0, 0.0, 0.0) ˡw̲ithPlayer s }

ˡt̲oggleFly : (Any a, Any b, Any c, Any d, Any e, Any f, Any g, Any h) => ((a, b, c, d, e, Float), f, g, h) -> ((a, Float, c, d, Float, Float), f, g, h)

function · line 603

en:t_oggleFly s: flying, or walking again (falling from where it is)

ˡt̲oggleFly ← { s →
  ((x, _, yaw, pitch, _, fly), wo, jb, st) ← s
  ((x, 0.0 0.0 0.0, yaw, pitch, 0.0, 1.0 − fly), wo, jb, st)
}
Used in: ʰf̲ly, ᵘf̲ly

ˡs̲top : (Any a, Any b, Any c, Any d, Any e, Any f, Any g, Any h, Num i) => (a, b, c, (d, e, f, g, h)) -> (a, b, c, (d, e, f, i, h))

function · line 609

en:s_top s: the state marked as finished

ˡs̲top ← { (p, wo, jb, (w, nxt, x0, _, lit)) → (p, wo, jb, (w, nxt, x0, 0, lit)) }

ˡs̲topped : (Any a, Any b, Any c, Any d, Any e, Any f, Num g, Any h, Truthy i) => (a, b, c, (d, e, f, g, h)) -> i

function · line 611

en:s_topped s: whether the state is marked as finished

ˡs̲topped ← { (_, _, _, (_, _, _, on, _)) → on = 0 }

Light

ˡl̲it : (Any a, Any b, Any c, Any d, Any e, Any f, Any g, Any h) => (a, b, c, (d, e, f, g, h)) -> h

function · line 623

en:l_it s: 0 when the world is not lit, 1 by day, 2 by night

ˡl̲it ← { (_, _, _, (_, _, _, _, lit)) → lit }

ˡl̲ighting : (Any a, Any b, Any c, Num d, Any e, Any f, Any g, Any h, Num i) => (a, b, c, (d, e, f, g, h)) -> (a, b, c, (d, e, f, g, i))

function · line 627

en:l_ighting s: the world lit (call it before columns are made), by day

ˡl̲ighting ← { (p, wo, jb, (w, nxt, x0, on, _)) →
  _ ← w ˢᶜd̲aylight! 1.0
  (p, wo, jb, (w, nxt, x0, on, 1))
}
Used in: s, s

ˡn̲ight : (Any a, Any b, Any c, Num d, Any e, Any f, Any g, Num h) => (a, b, c, (d, e, f, g, h)) -> (a, b, c, (d, e, f, g, h))

function · line 634

en:n_ight s: day becomes night (the sunlight and the sky gone, the lamps left) and night day

ˡn̲ight ← { (p, wo, jb, (w, nxt, x0, on, lit)) →
  _ ← w ˢᶜd̲aylight! f̲loat lit = 2
  (p, wo, jb, (w, nxt, x0, on, 3 − lit))
}
Used in: ʰn̲ightIf