const ModeStar, ModeRead, ModeDive
Plan modes.
Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.
Package physics is the Spot Kick penalty engine: a port of the browser game's gno-shots/src/physics.js that produces ...
Package physics is the Spot Kick penalty engine: a port of the browser game's gno-shots/src/physics.js that produces bit-identical results.
The JavaScript engine uses only + - * /, square roots, comparisons and 32-bit integer mixing inside its simulation, all of which IEEE-754 rounds exactly; gno does float64 arithmetic in software with the same rounding, and its math.Sqrt is correctly rounded. So the same inputs give the same bits here as in any browser, provided every operation happens in the same order. That is the rule this file follows, line by line:
Unlike the browser, which keeps simulating for the replay, Simulate stops as soon as the kick is decided; nothing after that can change the verdict.
Plan modes.
Outcomes.
Woodwork parts.
ResultOf summarises a decided kick in the realm's integer units.
1func SimulateShot(shot penalty.ShotParams, plan penalty.KeeperPlan, cfg penalty.Config) penalty.ResultSimulateShot is the realm's outcome function on this engine: the taker's six inputs and the keeper's four, under a game's constants.
DefaultParams returns the constants of the browser engine.
ParamsOf converts a game's constants from the realm's integer units (mm, mm/s, ms, per-mille, milli-radii) to the engine's. The defaults convert to DefaultParams exactly: each division is correctly rounded, so 2424/1000 is the same double as the browser's literal 2.424.
DecodePlan maps four uint16 onto a plan exactly as the browser does.
Simulate plays a kick to its verdict. plan is ignored with opt.NoKeeper.
ShotOf converts the taker's ten-input half (integer units plus the mishit seed) to the engine's units, as the web game does: each value / 1000.
Commit is one move the keeper made: when, how fast sideways, how high.
Contact is one keeper touch, decided at its first contact.
Launch is the ball as it leaves the boot.
Options are for tests and analysis.
1type Params struct {
2 GoalHalfWidth float64 // m
3 GoalHeight float64 // m
4 KeeperScale float64
5 ReactionMin float64 // s
6 ReactionMax float64
7 StarShare float64 // of the speed range
8 ReadShare float64
9 DiveMin float64 // m/s
10 DiveMax float64
11 JumpMin float64 // m/s
12 JumpMax float64
13 BallMinSpeed float64 // m/s
14 BallMaxSpeed float64
15 FuzzBase float64 // ball radii
16 FuzzPower float64
17 MaxContact float64 // ball radii
18}Params are the constants a game may change (penalty.Config, in SI units). DefaultParams are the browser engine's.
Plan is a keeper plan decoded from its four uint16.
1type Result struct {
2 Outcome int
3 DecidedStep int // the 1 kHz step it was decided in
4 DecidedAt float64 // s after contact
5 Launch Launch
6 Touch int // first part to touch the ball, -1 for none
7 TouchStep int
8 Woodwork int // first frame part it hit, 0 for none
9 Caught bool
10 Pounced bool // decided by the keeper pouncing on a loose ball
11 Contacts []Contact
12 Commits []Commit
13 Misread [4]float64 // the keeper's four normal draws (x, y, vx, jump)
14 // Where the ball's centre first reached the goal line (rounded to the
15 // millimetre, as the browser reports it), if it did.
16 LineCross bool
17 LineT, LineX, LineY float64
18 // Where it was when the whole ball was over the whole line, if it was.
19 Crossing bool
20 CrossT, CrossX, CrossY float64
21 EndX, EndY float64 // the ball when the kick was decided, m
22 Steps int
23 Trace uint32 // see Options.Trace
24}Result is a decided kick.
Shot is the taker's input in the browser engine's units.