librarygames/racer/Race.xtl

The racer's rules, a library: racer.xtl (scripted), play.xtl (the game: keys and the clock) and the web page all use these. Built on lib/Ecs: a world is a matrix, a row per car, and every rule is a system over every car at once. Your car and the rivals are the same kind of entity: the rivals steer for the next point of the track, you steer with your keys, and the rest (moving, the grass, bumping, the points passed, the laps and the places) is the same for all. A race's state is a tuple: (the world, the seconds since the lights, how it stands: 0 racing, 1 you finished, your place at the finish).

source · imports ec: lib/Ecs.xtl lib/Ecs.xtlm; sv: lib/Svg.xtl; t: lib/Text.xtl

The data

ʰw̲orld : Int -> Float

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }
Used in: ˡn̲ew

ʰp̲os : a -> a

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }

ʰh̲asPos : (Num a, Truthy b) => a -> b

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }

ʰs̲etPos : Float -> (Int, Float) -> Float

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }
Used in: ˡn̲ew, ʰm̲ove

ʰd̲ropPos : Float -> Int -> Float

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }

ʰd̲ir : a -> a

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }

ʰh̲asDir : (Num a, Truthy b) => a -> b

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }

ʰs̲etDir : Float -> (Int, Float) -> Float

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }

ʰd̲ropDir : Float -> Int -> Float

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }

ʰs̲peed : a -> a

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }

ʰh̲asSpeed : (Num a, Truthy b) => a -> b

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }

ʰs̲etSpeed : Float -> (Int, Float) -> Float

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }

ʰd̲ropSpeed : Float -> Int -> Float

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }

ʰt̲op : a -> a

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }
Used in: ʰd̲rive

ʰh̲asTop : (Num a, Truthy b) => a -> b

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }

ʰs̲etTop : Float -> (Int, Float) -> Float

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }
Used in: ˡn̲ew

ʰd̲ropTop : Float -> Int -> Float

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }

ʰn̲ext : a -> a

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }

ʰh̲asNext : (Num a, Truthy b) => a -> b

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }

ʰs̲etNext : Float -> (Int, Float) -> Float

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }
Used in: ˡn̲ew, ʰp̲ass

ʰd̲ropNext : Float -> Int -> Float

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }

ʰl̲ap : a -> a

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }

ʰh̲asLap : (Num a, Truthy b) => a -> b

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }

ʰs̲etLap : Float -> (Int, Float) -> Float

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }
Used in: ˡn̲ew, ʰp̲ass

ʰd̲ropLap : Float -> Int -> Float

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }

ʰp̲layer : a -> a

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }

ʰh̲asPlayer : (Num a, Truthy b) => a -> b

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }
Used in: ʰm̲e, ˡd̲raw

ʰs̲etPlayer : Float -> (Int, Float) -> Float

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }
Used in: ˡn̲ew

ʰd̲ropPlayer : Float -> Int -> Float

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }

ʰp̲aint : a -> a

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }
Used in: ˡd̲raw

ʰh̲asPaint : (Num a, Truthy b) => a -> b

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }

ʰs̲etPaint : Float -> (Int, Float) -> Float

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }
Used in: ˡn̲ew

ʰd̲ropPaint : Float -> Int -> Float

function (private) · line 21

The layout: where a car is (x then y, in tiles, y down), its heading (radians, 0 to the right, turning right as it grows), its speed, its top speed (0 for yours), the point of the track it heads for, the laps it has done, whether it is yours, and its paint.

"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
ᵉᶜc̲omponents< expands to
ʰw̲orld ← { n → (n c̲at 18) r̲eshape 0.0 }
ʰp̲os ← { W → (3 4) s̲elect₂ W }
ʰh̲asPos ← { W → 0 < 2 s̲elect₂ W }
ʰs̲etPos ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 2) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (2 3 4) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 3) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPos ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 2 = r̲ange 18 }
ʰd̲ir ← { W → (6) s̲elect₂ W }
ʰh̲asDir ← { W → 0 < 5 s̲elect₂ W }
ʰs̲etDir ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (5 6) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropDir ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 5 = r̲ange 18 }
ʰs̲peed ← { W → (8) s̲elect₂ W }
ʰh̲asSpeed ← { W → 0 < 7 s̲elect₂ W }
ʰs̲etSpeed ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (7 8) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropSpeed ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 7 = r̲ange 18 }
ʰt̲op ← { W → (10) s̲elect₂ W }
ʰh̲asTop ← { W → 0 < 9 s̲elect₂ W }
ʰs̲etTop ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (9 10) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropTop ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 9 = r̲ange 18 }
ʰn̲ext ← { W → (12) s̲elect₂ W }
ʰh̲asNext ← { W → 0 < 11 s̲elect₂ W }
ʰs̲etNext ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (11 12) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropNext ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 11 = r̲ange 18 }
ʰl̲ap ← { W → (14) s̲elect₂ W }
ʰh̲asLap ← { W → 0 < 13 s̲elect₂ W }
ʰs̲etLap ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (13 14) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropLap ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 13 = r̲ange 18 }
ʰp̲layer ← { W → (16) s̲elect₂ W }
ʰh̲asPlayer ← { W → 0 < 15 s̲elect₂ W }
ʰs̲etPlayer ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (15 16) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPlayer ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 15 = r̲ange 18 }
ʰp̲aint ← { W → (18) s̲elect₂ W }
ʰh̲asPaint ← { W → 0 < 17 s̲elect₂ W }
ʰs̲etPaint ← { W (ids, v) →
  i ← r̲avel ids
  V ← (((t̲ally i) c̲at 1) r̲eshape 1.0) c̲at₂ ((t̲ally i) c̲at 1) r̲eshape v
  R ← f̲loat (r̲ange t̲ally W) '= t̲able i
  C ← f̲loat (17 18) '= t̲able r̲ange 18
  M ← 0 < R '+ '× i̲nner (((t̲ally i) c̲at 2) r̲eshape 1.0) '+ '× i̲nner C
  (W × f̲loat n̲ot M) + R '+ '× i̲nner V '+ '× i̲nner C
}
ʰd̲ropPaint ← { W ids → W × f̲loat n̲ot ((r̲ange t̲ally W) m̲ember? r̲avel ids) '× t̲able 17 = r̲ange 18 }

X : Float

value (private) · line 24

The track: the points of its middle line, each segment from a point to the next (the last back to the first), and how wide the road is.

X ← 'ˢᵛn̲um e̲ach "racer.toml" ⎕L̲IST "x"

Y : Float

value (private) · line 25
Y ← 'ˢᵛn̲um e̲ach "racer.toml" ⎕L̲IST "y"

N : Int

value (private) · line 26
N ← t̲ally X

BX : Float

value (private) · line 27
BX ← (1 d̲rop X) c̲at f̲irst X
Used in: ʰo̲ffLine

BY : Float

value (private) · line 28
BY ← (1 d̲rop Y) c̲at f̲irst Y
Used in: ʰo̲ffLine

WIDTH : Float

value (private) · line 29
WIDTH ← f̲irst 'ˢᵛn̲um e̲ach "racer.toml" ⎕L̲IST "width"
Used in: ʰd̲rive, track

colors : Box Char

value (private) · line 31

The cars: paints and top speeds.

colors ← "racer.toml" ⎕L̲IST "colors"
Used in: ˡn̲ew, ʰc̲ar

TOPS : Float

value (private) · line 32
TOPS ← 'ˢᵛn̲um e̲ach "racer.toml" ⎕L̲IST "tops"
Used in: ˡn̲ew

race : Float

value (private) · line 37

The race: laps, seconds before the start, your fastest speed, the speed an up key adds, a left or right key's turn, the speed kept each tick, a rival's turning a second, the fastest on the grass, how near a point a car must pass.

race ← 'ˢᵛn̲um e̲ach "racer.toml" ⎕L̲IST "race"
Used in: LAPS, GO, FAST, ACCEL, TURN, KEEP, STEER, GRASS, NEAR

LAPS : Float

value (private) · line 38
LAPS ← f̲irst race

GO : Float

value (private) · line 39
GO ← 2 s̲elect race

FAST : Float

value (private) · line 40
FAST ← 3 s̲elect race
Used in: ˡk̲ey

ACCEL : Float

value (private) · line 41
ACCEL ← 4 s̲elect race
Used in: ˡk̲ey

TURN : Float

value (private) · line 42
TURN ← 5 s̲elect race
Used in: ˡk̲ey

KEEP : Float

value (private) · line 43
KEEP ← 6 s̲elect race
Used in: ʰd̲rive

STEER : Float

value (private) · line 44
STEER ← 7 s̲elect race
Used in: ʰd̲rive

GRASS : Float

value (private) · line 45
GRASS ← 8 s̲elect race
Used in: ʰd̲rive

NEAR : Float

value (private) · line 46
NEAR ← 9 s̲elect race
Used in: ʰp̲ass

A new race

ʰp̲air : (a, a) -> a

function (private) · line 51

n by 2 from two columns.

ʰp̲air ← { (a, b) → o̲\ (2 c̲at t̲ally a) r̲eshape a c̲at b }

ˡn̲ew : (Any a, Num b, Num c) => a -> (Float, Float, b, c)

function · line 55

A new race: a car for each paint, on the grid behind the start line in pairs, all heading for the second point of the track.

ˡn̲ew ← { z →
  (spawned, ids) ← (ʰw̲orld 8) ᵉᶜs̲pawn t̲ally colors
  i ← f̲loat r̲ange t̲ally ids
  grid ← ʰp̲air ((f̲irst X) − 1.1 × i, (f̲irst Y) + 0.5 − f̲loat (r̲ange t̲ally ids) m̲od 2)
  parked ← ((spawned ʰs̲etPos (ids, grid)) ʰs̲etDir (ids, 0.0)) ʰs̲etSpeed (ids, 0.0)
  aimed ← ((parked ʰs̲etTop (ids, TOPS)) ʰs̲etNext (ids, 2.0)) ʰs̲etLap (ids, 0.0)
  W ← (aimed ʰs̲etPlayer (f̲irst ids, 1.0)) ʰs̲etPaint (ids, i)
  (W, 0.0, 0, 0)
}

The systems

ʰc̲ars : Num a => a -> Int

function (private) · line 68

The cars.

ʰc̲ars ← { W → w̲here ᵉᶜa̲live W }

ʰm̲e : Num a => a -> Int

function (private) · line 70

Your car.

ʰm̲e ← { W → f̲irst w̲here (ᵉᶜa̲live W) ∧ ʰh̲asPlayer W }

ʰt̲arget : Num a => a -> Int -> Float

function (private) · line 72

Where each car heads for: the point of the track, a row each.

ʰt̲arget ← { W c → ʰp̲air ((f̲loor c s̲elect ʰn̲ext W) s̲elect X, (f̲loor c s̲elect ʰn̲ext W) s̲elect Y) }

ʰo̲ffLine : Float -> Float

function (private) · line 76

How far each car (a row of P) is from the road's middle line, squared: every car against every segment of the track at once (a table, cars down, segments across), the nearest kept.

ʰo̲ffLine ← { P →
  dx ← (1 s̲elect₂ P) '− t̲able X
  dy ← (2 s̲elect₂ P) '− t̲able Y
  s ← s̲hape dx
  ex ← s r̲eshape BX − X
  ey ← s r̲eshape BY − Y
  t ← 0.0 m̲ax 1.0 m̲in ((dx × ex) + dy × ey) ÷ (ex × ex) + ey × ey
  qx ← dx − t × ex
  qy ← dy − t × ey
  'm̲in r̲/₂ (qx × qx) + qy × qy
}
Used in: ʰd̲rive

ʰd̲rive : Float -> Float -> Float

function (private) · line 91

The rivals steer for the point they head for (turning by at most their turning in dt, less the more nearly they face it) and speed up or slow down toward their top speed; your car only loses a little speed. Then every car on the grass is held to the grass's speed.

ʰd̲rive ← { W dt →
  c ← ʰc̲ars W
  P ← c s̲elect ʰp̲os W
  d ← c s̲elect ʰd̲ir W
  v ← c s̲elect ʰs̲peed W
  top ← c s̲elect ʰt̲op W
  rival ← top > 0.0
  T ← (W ʰt̲arget c) − P
  far ← 0.001 m̲ax ((1 s̲elect₂ T) × 1 s̲elect₂ T) + (2 s̲elect₂ T) × 2 s̲elect₂ T
  side ← (((c̲os d) × 2 s̲elect₂ T) − (s̲in d) × 1 s̲elect₂ T) ÷ far ^ 0.5
  turned ← d + (f̲loat rival) × STEER × dt × -1.0 m̲ax 1.0 m̲in 3.0 × side
  fast ← (v × KEEP + (f̲loat rival) × 1.0 − KEEP) + (f̲loat rival) × 0.05 × top − v
  off ← (ʰo̲ffLine P) > (WIDTH × WIDTH) ÷ 4.0
  held ← (fast × f̲loat n̲ot off) + (f̲loat off) × fast m̲in GRASS
  (W ʰs̲etDir (c, turned)) ʰs̲etSpeed (c, held)
}
Used in: ˡt̲ick

ʰm̲ove : Float -> Float -> Float

function (private) · line 109

Cars that touch another (within 0.7 tiles) are slowed, every pair at once; then every car moves along its heading by its speed.

ʰm̲ove ← { W dt →
  c ← ʰc̲ars W
  P ← c s̲elect ʰp̲os W
  bump ← 1 < '+ r̲/₂ 0 + ᵉᶜn̲ear (P, P, 0.7)
  v ← (c s̲elect ʰs̲peed W) × 1.0 − 0.1 × f̲loat bump
  d ← c s̲elect ʰd̲ir W
  (W ʰs̲etSpeed (c, v)) ʰs̲etPos (c, P + ʰp̲air (v × dt × c̲os d, v × dt × s̲in d))
}
Used in: ˡt̲ick

ʰp̲ass : Float -> Float

function (private) · line 119

Every car that comes near the point it heads for heads for the next one; passing the first point (the line) is a lap done.

ʰp̲ass ← { W →
  c ← ʰc̲ars W
  T ← (W ʰt̲arget c) − c s̲elect ʰp̲os W
  at ← (NEAR × NEAR) > ((1 s̲elect₂ T) × 1 s̲elect₂ T) + (2 s̲elect₂ T) × 2 s̲elect₂ T
  k ← f̲loor c s̲elect ʰn̲ext W
  lapped ← W ʰs̲etLap (c, (c s̲elect ʰl̲ap W) + f̲loat at ∧ k = 1)
  lapped ʰs̲etNext (c, f̲loat k + (f̲loor at) × (1 + k m̲od N) − k)
}
Used in: ˡt̲ick

ʰp̲rogress : Float -> Float

function (private) · line 129

How far each car is in the race: laps, points passed in this lap, less a little for the way still to go to the next.

ʰp̲rogress ← { W →
  c ← ʰc̲ars W
  T ← (W ʰt̲arget c) − c s̲elect ʰp̲os W
  k ← f̲loor c s̲elect ʰn̲ext W
  ((c s̲elect ʰl̲ap W) × f̲loat N) + (f̲loat (k − 2) m̲od N) − 0.001 × ((1 s̲elect₂ T) × 1 s̲elect₂ T) + (2 s̲elect₂ T) × 2 s̲elect₂ T
}
Used in: ʰp̲laces

ʰp̲laces : (Num a, Truthy a) => Float -> a

function (private) · line 137

Each car's place: one more than the cars ahead of it, every pair of cars compared at once.

ʰp̲laces ← { W → p ← ʰp̲rogress W◆ 1 + '+ r̲/₂ 0 + p '< t̲able p }

ʰf̲inish : (Any a, Any b, Any c, Num d, Num e, Truthy e) => (Float, a, b, c) -> (Float, a, d, e)

function (private) · line 139

How it stands once you have done the laps: finished, at your place.

ʰf̲inish ← { (W, t, st, pl) →
  me ← ʰm̲e W
  LAPS > me s̲elect ʰl̲ap W ? (W, t, 0, 0)
  (W, t, 1, me s̲elect ʰp̲laces W)
}
Used in: ˡt̲ick

ˡt̲ick : (Num a, Num b, Truthy b) => (Float, Float, a, b) -> Float -> (Float, Float, a, b)

function · line 148

A tick of the clock, dt seconds: before the lights go only the time moves; then the cars drive, move and pass points of the track, each a system over every car at once. A race finished stays as it is.

ˡt̲ick ← { (W, t, st, pl) dt →
  st > 0 ? (W, t, st, pl)
  t < GO ? (W, t + dt, st, pl)
  raced ← ʰp̲ass (W ʰd̲rive dt) ʰm̲ove dt
  ʰf̲inish (raced, t + dt, st, pl)
}

Your keys

ˡk̲ey : (Num a, Any b) => (Float, Float, a, b) -> Char -> (Float, Float, a, b)

function · line 161

A key: up (or w) speeds you up, down (or s) slows you, left and right (or a and d) turn you; other keys, and keys before the lights or after the finish, do nothing.

ˡk̲ey ← { s name →
  (W, t, st, pl) ← s
  me ← ʰm̲e W
  v ← me s̲elect ʰs̲peed W
  d ← me s̲elect ʰd̲ir W
  key ← ("UP" "DOWN" "LEFT" "RIGHT" "w" "s" "a" "d") i̲ndexOf e̲nclose name
  (key > 8) ∨ (st > 0) ∨ t < GO ? s
  k ← 1 + (key − 1) m̲od 4
  k = 1 ? (W ʰs̲etSpeed (me, FAST m̲in v + ACCEL), t, st, pl)
  k = 2 ? (W ʰs̲etSpeed (me, 0.0 m̲ax v − 1.5 × ACCEL), t, st, pl)
  (W ʰs̲etDir (me, d + TURN × f̲loat (2 × k) − 7), t, st, pl)
}
Used in: ᵘl̲oop, sped

What it shows

ˡs̲tatus : (Any a, Any b, Any c, Any d) => (a, b, c, d) -> c

function · line 178

0 racing, 1 you finished.

ˡs̲tatus ← { (W, t, st, pl) → st }
Used in: ᵘs̲how, _

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

function · line 181

Your place at the finish (0 while racing).

ˡp̲lace ← { (W, t, st, pl) → pl }
Used in: ᵘe̲nd

ˡy̲ou : (Any a, Any b) => (Float, Float, a, b) -> Float

function · line 184

Your lap (counting the one you are on), your place now, the seconds.

ˡy̲ou ← { (W, t, st, pl) →
  me ← ʰm̲e W
  (LAPS m̲in 1.0 + me s̲elect ʰl̲ap W) c̲at (f̲loat me s̲elect ʰp̲laces W) c̲at t
}

ˡc̲ar : (Any a, Any b, Any c) => (Float, a, b, c) -> Float

function · line 191

Your car: where it is, its heading, its speed, and the point of the track it heads for.

ˡc̲ar ← { (W, t, st, pl) →
  me ← ʰm̲e W
  (me s̲elect ʰp̲os W) c̲at (me s̲elect ʰd̲ir W) c̲at (me s̲elect ʰs̲peed W) c̲at r̲avel W ʰt̲arget me
}

ˡc̲ars : (Any a, Any b, Any c) => (Float, a, b, c) -> Float

function · line 197

Every car: laps done, the point it heads for, its place.

ˡc̲ars ← { (W, t, st, pl) →
  c ← ʰc̲ars W
  o̲\ (3 c̲at t̲ally c) r̲eshape (c s̲elect ʰl̲ap W) c̲at (c s̲elect ʰn̲ext W) c̲at f̲loat ʰp̲laces W
}

road : Char

value (private) · line 203

The track, drawn once: the grass, the road along its middle line, and the start line across it.

road ← ᵗj̲oin '{ i → e̲nclose @ f̲ormat< "{sv:w_hole 40.0 * i s_elect X},{sv:w_hole 60.0 + 40.0 * i s_elect Y} " } e̲ach (r̲ange N) c̲at 1
f̲ormat< expands to
((f̲ormat (ˢᵛw̲hole 40.0 × i s̲elect X)) c̲at "," c̲at (f̲ormat (ˢᵛw̲hole 60.0 + 40.0 × i s̲elect Y)) c̲at " ")
Used in: track

track : Char

value (private) · line 204
track ← @ f̲ormat< "<rect y=\"60\" width=\"960\" height=\"640\" fill=\"#3a7d44\"/><polyline points=\"{road}\" fill=\"none\" stroke=\"#5c5c66\" stroke-width=\"{sv:w_hole 40.0 * WIDTH}\" stroke-linejoin=\"round\"/><rect x=\"{sv:w_hole (40.0 * f_irst X) - 4.0}\" y=\"{sv:w_hole 60.0 + 40.0 * (f_irst Y) - WIDTH / 2.0}\" width=\"8\" height=\"{sv:w_hole 40.0 * WIDTH}\" fill=\"#ffffff\"/>"
f̲ormat< expands to
("<rect y=\"60\" width=\"960\" height=\"640\" fill=\"#3a7d44\"/><polyline points=\"" c̲at (f̲ormat (road)) c̲at "\" fill=\"none\" stroke=\"#5c5c66\" stroke-width=\"" c̲at (f̲ormat (ˢᵛw̲hole 40.0 × WIDTH)) c̲at "\" stroke-linejoin=\"round\"/><rect x=\"" c̲at (f̲ormat (ˢᵛw̲hole (40.0 × f̲irst X) − 4.0)) c̲at "\" y=\"" c̲at (f̲ormat (ˢᵛw̲hole 60.0 + 40.0 × (f̲irst Y) − WIDTH ÷ 2.0)) c̲at "\" width=\"8\" height=\"" c̲at (f̲ormat (ˢᵛw̲hole 40.0 × WIDTH)) c̲at "\" fill=\"#ffffff\"/>")
Used in: ˡd̲raw

ʰc̲ar : (Float, Float, Float, Int, Int) -> Char

function (private) · line 206

A car, drawn at x, y (tiles) turned to d, in paint k; yours is "you".

ʰc̲ar ← { (x, y, d, k, you) →
  cls ← d̲isclose (1 + you) s̲elect "entity" "entity you"
  @ f̲ormat< "<g class=\"{cls}\" transform=\"translate({sv:w_hole 40.0 * x} {sv:w_hole 60.0 + 40.0 * y}) rotate({sv:w_hole d * 180.0 / p_i @})\"><rect x=\"-20\" y=\"-11\" width=\"40\" height=\"22\" rx=\"6\" fill=\"{d_isclose k s_elect colors}\" stroke=\"#111111\" stroke-width=\"2\"/><rect x=\"6\" y=\"-8\" width=\"7\" height=\"16\" fill=\"#cfe8ff\"/></g>"
}
f̲ormat< expands to
"<g class=\"" c̲at (f̲ormat (cls)) c̲at "\" transform=\"translate(" c̲at (f̲ormat (ˢᵛw̲hole 40.0 × x)) c̲at " " c̲at (f̲ormat (ˢᵛw̲hole 60.0 + 40.0 × y)) c̲at ") rotate(" c̲at (f̲ormat (ˢᵛw̲hole d × 180.0 ÷ p̲i @)) c̲at ")\"><rect x=\"-20\" y=\"-11\" width=\"40\" height=\"22\" rx=\"6\" fill=\"" c̲at (f̲ormat (d̲isclose k s̲elect colors)) c̲at "\" stroke=\"#111111\" stroke-width=\"2\"/><rect x=\"6\" y=\"-8\" width=\"7\" height=\"16\" fill=\"#cfe8ff\"/></g>"
Used in: ˡd̲raw

ʰs̲ays : (Num a, Num b) => (a, Float, b, c, d) -> Char

function (private) · line 211

What the top line says.

ʰs̲ays ← { (y, t, st, pl, n) →
  st = 1 ? @ f̲ormat< "Finished: place {pl} of {n} | Time {f_loor t} s"
  t < GO ? @ f̲ormat< "Ready... {c_eiling GO - t} | Time {f_loor t} s | Up to go, left and right to steer"
  @ f̲ormat< "Lap {f_loor f_irst y} of {f_loor LAPS} | Place {f_loor 2 s_elect y} of {n} | Time {f_loor t} s"
}
f̲ormat< expands to
("Finished: place " c̲at (f̲ormat (pl)) c̲at " of " c̲at (f̲ormat (n)) c̲at " | Time " c̲at (f̲ormat (f̲loor t)) c̲at " s")
f̲ormat< expands to
("Ready... " c̲at (f̲ormat (c̲eiling GO − t)) c̲at " | Time " c̲at (f̲ormat (f̲loor t)) c̲at " s | Up to go, left and right to steer")
f̲ormat< expands to
"Lap " c̲at (f̲ormat (f̲loor f̲irst y)) c̲at " of " c̲at (f̲ormat (f̲loor LAPS)) c̲at " | Place " c̲at (f̲ormat (f̲loor 2 s̲elect y)) c̲at " of " c̲at (f̲ormat (n)) c̲at " | Time " c̲at (f̲ormat (f̲loor t)) c̲at " s"
Used in: ˡd̲raw

ˡd̲raw : Num a => (Float, Float, a, b) -> Char

function · line 219

The picture, as SVG text: the track, every car (yours on top), and the top line.

ˡd̲raw ← { (W, t, st, pl) →
  v ← 0.0 0.0 960.0 700.0
  c ← ʰc̲ars W
  P ← c s̲elect ʰp̲os W
  d ← c s̲elect ʰd̲ir W
  k ← f̲loor c s̲elect ʰp̲aint W
  you ← c s̲elect ʰh̲asPlayer W
  order ← g̲rade you
  cars ← '{ i → e̲nclose ʰc̲ar (i s̲elect 1 s̲elect₂ P, i s̲elect 2 s̲elect₂ P, i s̲elect d, i s̲elect k, i s̲elect you) } e̲ach order
  top ← (20.0, 42.0, 30.0) ˢᵛw̲ords ʰs̲ays (ˡy̲ou (W, t, st, pl), t, st, pl, t̲ally c)
  v ˢᵛp̲icture (v ˢᵛr̲ect "fill=\"#2b2d42\"") c̲at (e̲nclose track) c̲at cars c̲at top
}
Used in: ᵘs̲how, _