Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·originates fromworld 8c90d7c4-9…

RaceSim

The whole of the game's logic, with nothing drawn and nothing scheduled. Every other piece of the game reads it:

by◐Doomin·posted 5d ago
What it does

RaceSim — the rules of a turf race

The whole of the game's logic, with nothing drawn and nothing scheduled. Every other piece of the game reads it:

  • RaceDirector.component steps it every frame and places the horses from it.
  • HorseRaceUI.module draws the standings, clock and times it produces.
  • Racecourse.sceneModule and scenes/main.scene/build.luau mirror its TRACK numbers so the horses are always on the turf they model.

The oval

RaceSim.TRACK = { A = 92, B = 56, WIDTH = 22, RAIL_OUT = 12.4, RAIL_IN = 11.6, SAMPLES = 720 }

An ellipse in the XZ plane. Distance is measured in metres run from the finish line, and the finish line sits at t = 0 — the point of least curvature, world (92, 0, 0) — so the home straight runs along Z and the stands stand outside it at +X. A model on the track faces +Z.

RaceSim.pose(distance, lane) -> x, z, yaw, nx, nz

lane is -1 (inner) through 1 (outer); yaw turns a +Z-facing model down the track; nx, nz is the outward normal, which is how the broadcast camera finds the outside of the rail. RaceSim.LENGTH is the oval's circumference in metres (about 472).

The field

RaceSim.FIELD is the eight horses: number, name, coat body, silk and cap colours, a preferred style, and the three hidden parameters speed / stamina / guts (0–100). Horse 1 is the player's, ヒカリノサクラ.

RaceSim.STYLES are the four 作戦 — nige 逃げ, senko 先行, sashi 差し, oikomi 追込 — with STYLE_NAME and STYLE_NOTE for the screen.

One race

local race = RaceSim.newRace(plan, career)   -- plan overrides horse 1's style
local events = RaceSim.step(race, dt)        -- { kind = "lead"|"final"|"drain"|"finish", ... }
local rows = RaceSim.standings(race)         -- place, number, name, colour, gap, finished, time

step is where the race is decided:

  • Pace — each style keeps its own multiplier through 序盤 / 中盤 / 終盤 (PACE, ×0.92 to ×1.09 of the horse's own top speed). Front runners go early, 差し and 追込 keep something for the last stretch.
  • Stamina — drains with (v/16)^3, so a horse that runs faster empties it sooner; a full tank lasts 38 + 0.62 × stamina seconds at racing speed. Below 14% the horse fades toward ×0.78 — that is 失速, and it happens in the last 200 m to the horses that were asked too much too early.
  • 根性 — every rival within 5 m adds up to ×1.03, scaled by guts/100 and by how late the race is, so horses that are level in the straight fight each other harder than horses alone.

RaceSim.FINAL is the last 200 m. RaceSim.formatTime writes m:ss.cc, RaceSim.prize pays a placing in 万円, RaceSim.colourOf / nameOf look a horse up by number.

Changing the track

Change A, B and WIDTH here and change the same three numbers in Racecourse.sceneModule (it cannot require this module — a scene module compiles in its own environment) and the scene's start gate follows. Everything else — distances, pace, finish times — works in metres and needs no edit.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

context sceneBuild sceneModule

paramAt(distance: number) → number

argtypedescription
distancenumber

pose(distance: number, lane: number) →

it down the track (a model authored facing +Z).

argtypedescription
distancenumbermetres travelled from the finish line
lanenumber-1 (inner) through 1 (outer)

colourOf(number: number) → string

agree on who is who.

argtypedescription
numbernumber

nameOf(number: number) → string

argtypedescription
numbernumber

clamp(v: number, lo: number, hi: number) → number

argtypedescription
vnumber
lonumber
hinumber

paceFor(style: string, progress: number) → number

argtypedescription
stylestring
progressnumber

newRace(plan: string?, career: table?) → void

the career record the player carries into it.

argtypedescription
planstring?the running style the player's horse rides
careertable?the record from earlier runs ({ runs, wins, earnings, best })

step(state: table, dt: number) →

`drain`, `finish`, `won`), each `{ kind, number?, name? }`.

argtypedescription
statetable
dtnumber

standings(state: table) → void

the leader in metres, and whether this horse is finished.

argtypedescription
statetable

formatTime(seconds: number?) → string

`m:ss.cc`, the way a race is timed.

argtypedescription
secondsnumber?

prize(place: number) → number

Prize money for a placing, in 万円.

argtypedescription
placenumber

Sub-parts

Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.

3items
This part has no composite children. See the Files segment for its leaf payloads.
backing path · RaceSim.module

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported. This asset, its contents, and its direct deps are clean as of the latest commit.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.