sourcegames/racer/Race.xtl
1⍝│ The racer's rules, a library: racer.xtl (scripted), play.xtl (the
2⍝│ game: keys and the clock) and the web page all use these. Built on
3⍝│ lib/Ecs: a world is a matrix, a row per car, and every rule is a
4⍝│ system over every car at once. Your car and the rivals are the same
5⍝│ kind of entity: the rivals steer for the next point of the track, you
6⍝│ steer with your keys, and the rest (moving, the grass, bumping, the
7⍝│ points passed, the laps and the places) is the same for all. A race's
8⍝│ state is a tuple: (the world, the seconds since the lights, how it
9⍝│ stands: 0 racing, 1 you finished, your place at the finish).
10
11"ec:" u̲se< "Ecs"
12"sv:" u̲se< "Svg"
13"t:" u̲se< "Text"
14
15⍝━━ The data
16
17⍝│ The layout: where a car is (x then y, in tiles, y down), its heading
18⍝│ (radians, 0 to the right, turning right as it grows), its speed, its
19⍝│ top speed (0 for yours), the point of the track it heads for, the laps
20⍝│ it has done, whether it is yours, and its paint.
21"h" ᵉᶜc̲omponents< "pos:2 dir speed top next lap player paint"
22⍝│ The track: the points of its middle line, each segment from a point to
23⍝│ the next (the last back to the first), and how wide the road is.
24X ← 'ˢᵛn̲um e̲ach "racer.toml" ⎕L̲IST "x"
25Y ← 'ˢᵛn̲um e̲ach "racer.toml" ⎕L̲IST "y"
26N ← t̲ally X
27BX ← (1 d̲rop X) c̲at f̲irst X
28BY ← (1 d̲rop Y) c̲at f̲irst Y
29WIDTH ← f̲irst 'ˢᵛn̲um e̲ach "racer.toml" ⎕L̲IST "width"
30⍝│ The cars: paints and top speeds.
31colors ← "racer.toml" ⎕L̲IST "colors"
32TOPS ← 'ˢᵛn̲um e̲ach "racer.toml" ⎕L̲IST "tops"
33⍝│ The race: laps, seconds before the start, your fastest speed, the
34⍝│ speed an up key adds, a left or right key's turn, the speed kept each
35⍝│ tick, a rival's turning a second, the fastest on the grass, how near a
36⍝│ point a car must pass.
37race ← 'ˢᵛn̲um e̲ach "racer.toml" ⎕L̲IST "race"
38LAPS ← f̲irst race
39GO ← 2 s̲elect race
40FAST ← 3 s̲elect race
41ACCEL ← 4 s̲elect race
42TURN ← 5 s̲elect race
43KEEP ← 6 s̲elect race
44STEER ← 7 s̲elect race
45GRASS ← 8 s̲elect race
46NEAR ← 9 s̲elect race
47
48⍝━━ A new race
49
50⍝│ n by 2 from two columns.
51ʰp̲air ← { (a, b) → o̲\ (2 c̲at t̲ally a) r̲eshape a c̲at b }
52⍝ :: (Any a, Num b, Num c) => a -> (Float, Float, b, c)
53⍝│ A new race: a car for each paint, on the grid behind the start line
54⍝│ in pairs, all heading for the second point of the track.
55ˡn̲ew ← { z →
56 (spawned, ids) ← (ʰw̲orld 8) ᵉᶜs̲pawn t̲ally colors
57 i ← f̲loat r̲ange t̲ally ids
58 grid ← ʰp̲air ((f̲irst X) − 1.1 × i, (f̲irst Y) + 0.5 − f̲loat (r̲ange t̲ally ids) m̲od 2)
59 parked ← ((spawned ʰs̲etPos (ids, grid)) ʰs̲etDir (ids, 0.0)) ʰs̲etSpeed (ids, 0.0)
60 aimed ← ((parked ʰs̲etTop (ids, TOPS)) ʰs̲etNext (ids, 2.0)) ʰs̲etLap (ids, 0.0)
61 W ← (aimed ʰs̲etPlayer (f̲irst ids, 1.0)) ʰs̲etPaint (ids, i)
62 (W, 0.0, 0, 0)
63}
64
65⍝━━ The systems
66
67⍝│ The cars.
68ʰc̲ars ← { W → w̲here ᵉᶜa̲live W }
69⍝│ Your car.
70ʰm̲e ← { W → f̲irst w̲here (ᵉᶜa̲live W) ∧ ʰh̲asPlayer W }
71⍝│ Where each car heads for: the point of the track, a row each.
72ʰ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) }
73⍝│ How far each car (a row of P) is from the road's middle line, squared:
74⍝│ every car against every segment of the track at once (a table, cars
75⍝│ down, segments across), the nearest kept.
76ʰo̲ffLine ← { P →
77 dx ← (1 s̲elect₂ P) '− t̲able X
78 dy ← (2 s̲elect₂ P) '− t̲able Y
79 s ← s̲hape dx
80 ex ← s r̲eshape BX − X
81 ey ← s r̲eshape BY − Y
82 t ← 0.0 m̲ax 1.0 m̲in ((dx × ex) + dy × ey) ÷ (ex × ex) + ey × ey
83 qx ← dx − t × ex
84 qy ← dy − t × ey
85 'm̲in r̲/₂ (qx × qx) + qy × qy
86}
87⍝│ The rivals steer for the point they head for (turning by at most
88⍝│ their turning in dt, less the more nearly they face it) and speed up
89⍝│ or slow down toward their top speed; your car only loses a little
90⍝│ speed. Then every car on the grass is held to the grass's speed.
91ʰd̲rive ← { W dt →
92 c ← ʰc̲ars W
93 P ← c s̲elect ʰp̲os W
94 d ← c s̲elect ʰd̲ir W
95 v ← c s̲elect ʰs̲peed W
96 top ← c s̲elect ʰt̲op W
97 rival ← top > 0.0
98 T ← (W ʰt̲arget c) − P
99 far ← 0.001 m̲ax ((1 s̲elect₂ T) × 1 s̲elect₂ T) + (2 s̲elect₂ T) × 2 s̲elect₂ T
100 side ← (((c̲os d) × 2 s̲elect₂ T) − (s̲in d) × 1 s̲elect₂ T) ÷ far ^ 0.5
101 turned ← d + (f̲loat rival) × STEER × dt × -1.0 m̲ax 1.0 m̲in 3.0 × side
102 fast ← (v × KEEP + (f̲loat rival) × 1.0 − KEEP) + (f̲loat rival) × 0.05 × top − v
103 off ← (ʰo̲ffLine P) > (WIDTH × WIDTH) ÷ 4.0
104 held ← (fast × f̲loat n̲ot off) + (f̲loat off) × fast m̲in GRASS
105 (W ʰs̲etDir (c, turned)) ʰs̲etSpeed (c, held)
106}
107⍝│ Cars that touch another (within 0.7 tiles) are slowed, every pair at
108⍝│ once; then every car moves along its heading by its speed.
109ʰm̲ove ← { W dt →
110 c ← ʰc̲ars W
111 P ← c s̲elect ʰp̲os W
112 bump ← 1 < '+ r̲/₂ 0 + ᵉᶜn̲ear (P, P, 0.7)
113 v ← (c s̲elect ʰs̲peed W) × 1.0 − 0.1 × f̲loat bump
114 d ← c s̲elect ʰd̲ir W
115 (W ʰs̲etSpeed (c, v)) ʰs̲etPos (c, P + ʰp̲air (v × dt × c̲os d, v × dt × s̲in d))
116}
117⍝│ Every car that comes near the point it heads for heads for the next
118⍝│ one; passing the first point (the line) is a lap done.
119ʰp̲ass ← { W →
120 c ← ʰc̲ars W
121 T ← (W ʰt̲arget c) − c s̲elect ʰp̲os W
122 at ← (NEAR × NEAR) > ((1 s̲elect₂ T) × 1 s̲elect₂ T) + (2 s̲elect₂ T) × 2 s̲elect₂ T
123 k ← f̲loor c s̲elect ʰn̲ext W
124 lapped ← W ʰs̲etLap (c, (c s̲elect ʰl̲ap W) + f̲loat at ∧ k = 1)
125 lapped ʰs̲etNext (c, f̲loat k + (f̲loor at) × (1 + k m̲od N) − k)
126}
127⍝│ How far each car is in the race: laps, points passed in this lap, less
128⍝│ a little for the way still to go to the next.
129ʰp̲rogress ← { W →
130 c ← ʰc̲ars W
131 T ← (W ʰt̲arget c) − c s̲elect ʰp̲os W
132 k ← f̲loor c s̲elect ʰn̲ext W
133 ((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
134}
135⍝│ Each car's place: one more than the cars ahead of it, every pair of
136⍝│ cars compared at once.
137ʰp̲laces ← { W → p ← ʰp̲rogress W◆ 1 + '+ r̲/₂ 0 + p '< t̲able p }
138⍝│ How it stands once you have done the laps: finished, at your place.
139ʰf̲inish ← { (W, t, st, pl) →
140 me ← ʰm̲e W
141 LAPS > me s̲elect ʰl̲ap W ? (W, t, 0, 0)
142 (W, t, 1, me s̲elect ʰp̲laces W)
143}
144⍝ :: (Num a, Num b, Truthy b) => (Float, Float, a, b) -> Float -> (Float, Float, a, b)
145⍝│ A tick of the clock, dt seconds: before the lights go only the time
146⍝│ moves; then the cars drive, move and pass points of the track, each a
147⍝│ system over every car at once. A race finished stays as it is.
148ˡt̲ick ← { (W, t, st, pl) dt →
149 st > 0 ? (W, t, st, pl)
150 t < GO ? (W, t + dt, st, pl)
151 raced ← ʰp̲ass (W ʰd̲rive dt) ʰm̲ove dt
152 ʰf̲inish (raced, t + dt, st, pl)
153}
154
155⍝━━ Your keys
156
157⍝ :: (Num a, Any b) => (Float, Float, a, b) -> Char -> (Float, Float, a, b)
158⍝│ A key: up (or w) speeds you up, down (or s) slows you, left and right
159⍝│ (or a and d) turn you; other keys, and keys before the lights or after
160⍝│ the finish, do nothing.
161ˡk̲ey ← { s name →
162 (W, t, st, pl) ← s
163 me ← ʰm̲e W
164 v ← me s̲elect ʰs̲peed W
165 d ← me s̲elect ʰd̲ir W
166 key ← ("UP" "DOWN" "LEFT" "RIGHT" "w" "s" "a" "d") i̲ndexOf e̲nclose name
167 (key > 8) ∨ (st > 0) ∨ t < GO ? s
168 k ← 1 + (key − 1) m̲od 4
169 k = 1 ? (W ʰs̲etSpeed (me, FAST m̲in v + ACCEL), t, st, pl)
170 k = 2 ? (W ʰs̲etSpeed (me, 0.0 m̲ax v − 1.5 × ACCEL), t, st, pl)
171 (W ʰs̲etDir (me, d + TURN × f̲loat (2 × k) − 7), t, st, pl)
172}
173
174⍝━━ What it shows
175
176⍝ :: (Any a, Any b, Any c, Any d) => (a, b, c, d) -> c
177⍝│ 0 racing, 1 you finished.
178ˡs̲tatus ← { (W, t, st, pl) → st }
179⍝ :: (Any a, Any b, Any c, Any d) => (a, b, c, d) -> d
180⍝│ Your place at the finish (0 while racing).
181ˡp̲lace ← { (W, t, st, pl) → pl }
182⍝ :: (Any a, Any b) => (Float, Float, a, b) -> Float
183⍝│ Your lap (counting the one you are on), your place now, the seconds.
184ˡy̲ou ← { (W, t, st, pl) →
185 me ← ʰm̲e W
186 (LAPS m̲in 1.0 + me s̲elect ʰl̲ap W) c̲at (f̲loat me s̲elect ʰp̲laces W) c̲at t
187}
188⍝ :: (Any a, Any b, Any c) => (Float, a, b, c) -> Float
189⍝│ Your car: where it is, its heading, its speed, and the point of the
190⍝│ track it heads for.
191ˡc̲ar ← { (W, t, st, pl) →
192 me ← ʰm̲e W
193 (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
194}
195⍝ :: (Any a, Any b, Any c) => (Float, a, b, c) -> Float
196⍝│ Every car: laps done, the point it heads for, its place.
197ˡc̲ars ← { (W, t, st, pl) →
198 c ← ʰc̲ars W
199 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
200}
201⍝│ The track, drawn once: the grass, the road along its middle line, and
202⍝│ the start line across it.
203road ← ᵗ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
204track ← @ 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\"/>"
205⍝│ A car, drawn at x, y (tiles) turned to d, in paint k; yours is "you".
206ʰc̲ar ← { (x, y, d, k, you) →
207 cls ← d̲isclose (1 + you) s̲elect "entity" "entity you"
208 @ 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>"
209}
210⍝│ What the top line says.
211ʰs̲ays ← { (y, t, st, pl, n) →
212 st = 1 ? @ f̲ormat< "Finished: place {pl} of {n} | Time {f_loor t} s"
213 t < GO ? @ f̲ormat< "Ready... {c_eiling GO - t} | Time {f_loor t} s | Up to go, left and right to steer"
214 @ 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"
215}
216⍝ :: Num a => (Float, Float, a, b) -> Char
217⍝│ The picture, as SVG text: the track, every car (yours on top), and the
218⍝│ top line.
219ˡd̲raw ← { (W, t, st, pl) →
220 v ← 0.0 0.0 960.0 700.0
221 c ← ʰc̲ars W
222 P ← c s̲elect ʰp̲os W
223 d ← c s̲elect ʰd̲ir W
224 k ← f̲loor c s̲elect ʰp̲aint W
225 you ← c s̲elect ʰh̲asPlayer W
226 order ← g̲rade you
227 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
228 top ← (20.0, 42.0, 30.0) ˢᵛw̲ords ʰs̲ays (ˡy̲ou (W, t, st, pl), t, st, pl, t̲ally c)
229 v ˢᵛp̲icture (v ˢᵛr̲ect "fill=\"#2b2d42\"") c̲at (e̲nclose track) c̲at cars c̲at top
230}
ᵉᶜ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 }
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 " ")
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\"/>")
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>"
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"