# CS:GO surf movement

The current target is `csgo-surf66-v7`: the **recorded 66-tick Cybershoke CS:GO surf
profile**, with observed acceleration and friction, automatic
bunnyhopping and no stamina. The main start-zone landing cap is described
below. CS:GO surf servers
can use different tick rates, cvars and movement plugins; this profile is
not a claim of exact equivalence to every server.

| Setting | Value |
| --- | --- |
| Simulation interval | float32(1/66) second, independent of rendering |
| Gravity | 800 units/s² |
| Air acceleration | 150 |
| Ground acceleration | 10 |
| Friction / stop speed | 4.8 / 80 |
| Maximum wish speed | 260 units/s |
| Digital forward / side command | ±450, cropped to player max speed before world-space conversion |
| Air wish-direction cap | 30 units/s |
| Jump impulse | float32(301.99337741082996) |
| Standing / crouching hull | 32×32×72 / 32×32×54 |
| Standing / crouching eye height | 64 / 46 |
| Duck speed / fatigue per button edge | 8 / −2, clamped at 0 |
| Duck speed recovery | 3/s; an extra 6/s after moving 64 units when not transitioning |
| Minimum duck speed / repeat cooldown | 1.5 / 0.4 seconds |
| Step height | 18 |
| Walkable normal threshold | 0.7 |
| Maximum velocity | 5000 by default; per-map overrides retained except Reprise's incompatible 4000 ceiling |

The air cap applies to the velocity projected along the wish direction, not
total speed. Acceleration uses the uncapped wish speed, preserving Source's
legacy air-strafe behavior. GO's duck amount scales both commands and maximum
wish speed continuously from 1 to 0.34, including in air. It does not reduce
existing momentum. This corrects v1's generic Source SDK ground-only crop.
Jumping happens before ground friction and preserves Source's extra
half-gravity step and standing/crouching jump distinction.

V3 corrects command cropping order, flattened AngleVectors normalization and
float32 reciprocal multiplication. It also applies CS:GO's minimum 1/32-unit/s
outward correction when velocity clipping leaves a negative residual into a
plane. The browser emits native 450-unit commands and the verifier accepts
the same limit. These changes were checked against independent recorded states;
they do not increase the configured maximum wish speed.

## Optional surf assists and ranked categories

Settings → Game & video offers ramp hold, air-strafe assist and W protection.
All are off on a fresh browser; explicit choices are saved locally. Ramp hold
recalculates the inward strafe from the current view yaw and ramp normal each
simulation tick, including turns, but a manually held A/D key takes priority.
W protection only suppresses positive forward input while on a surf ramp.
Air-strafe assist rotates the movement wish direction by at most twelve degrees
toward a direction perpendicular to horizontal velocity while holding A/D and
turning in free air with W/S released. This lets normal air acceleration add
lateral speed; targeting the air-cap boundary would leave no acceleration.
It does not change view angles, movement limits or physics, and does not act on
ramps, on the ground, while idle or without a turn.

Assists adjust legal commands before the normal simulation and recording. The
server verifies those recorded commands with the same physics as other runs.
The union of enabled assists sticks until an explicit restart, including toggles
while paused. Disable assists and restart for an unassisted attempt. Ordinary
replay playback applies recorded commands directly and never applies assists twice.

Ranked records and replay slots are separate for unassisted, assisted and
Route Lab automated runs, for both main courses and bonuses. The combined
leaderboard includes category labels and filters. Reward limits remain shared
across categories. Saved replay metadata, upload retries, finish results, chat,
spectating, local PBs and personal records preserve the category. Live movement
packets use bits 24–25 for provenance; bot recordings strip these bits before
Float32 storage and bots are labelled automated on playback.

Pre-assist records did not retain whether Route Lab produced them. Migration
preserves them as **Legacy · Unclassified**, without assigning them to the new
unassisted PB slot. Previous local PB keys are also preserved but not reused.
Declared assistance metadata is not a detector for modified browser clients;
the verifier establishes valid movement and completion, not human authorship.

## Crouch and contact behavior

Duck entry advances at `duckSpeed * 0.8` per second, and release advances at
`max(duckSpeed, 1.5)` per second. Button presses and releases consume duck
speed before recovery. The repeat cooldown uses simulation ticks, so a map's
movement-scale trigger does not slow that clock. Ground entry keeps the
standing hull until complete; release restores it at 75% duck amount. The
camera follows the cubic eye-offset spline. Air transitions finish immediately
and move the origin by half the hull-height difference (9 units), preserving
the hull center. Standing requires a clear swept standing hull through that
origin change. Blocked release keeps the crouched hull and eye height.

Movement clips against up to five planes over four bumps, follows a two-plane
crease using the last clipped candidate, and stops at a three-plane corner.
Endpoint occupancy checks reject false-clear sweeps. Ground probing checks
four hull quadrants at ledges. Step movement chooses the better valid horizontal
path and checks both overhead clearance and the landing surface; accepted
vertical corrections are included in trigger segments. Float32 rounding also
covers committed positions and remaining frame time. V4 keeps sweep
displacement intact, traces world brushes before props, limits prop sweeps to
the world impact, and uses centered float32 BSP box traces. See
`shared/csgo-trace.mjs` for the shared narrowphase implementation.

V5 adds BSP leaf/brush traversal order where independently sourced metadata is
available (Lux and Reprise). Equal-fraction contacts at Lux's ramp seam now
select the native face instead of clipping an additional face and losing speed.
This remains a box-trace port, not Valve's complete collision engine.

The port's contact recovery is limited to 1/32-unit overlap and moves at most
1/16 unit along an actual outward plane. A reverse sweep must confirm that the
same face is being escaped. It no longer searches arbitrary neighboring
positions, which could cross a thin obstacle. This is a conservative port
safeguard, not a claim to duplicate Valve's full CheckStuck offset search.

V6 commits combined moving duck recovery once per tick rather than rounding
both recovery additions separately. This prevents the accumulated deficit at
the unchanged 1.5 duck-speed cutoff that delayed Legends command 2052. Eligibility
still precedes recovery, and the cooldown, dimensions and rate constants are
unchanged. This is a recording-backed numerical correction, not certification
of the missing native duck-state history.

V6 also normalizes the selected imported VPhysics prop contact normal in
float32 before movement clipping. It preserves the authored sweep planes,
BSP normals, world-first tracing and the GO residual separation correction.
This fixes the Nyx prop-ramp reset in native-start playback and reduces Boreas
contact discrepancies. Nyx completes but still accumulates about 22 units
of later drift; completion is not exact trajectory parity.

V7 retains collision planes across BSP hits whose positive trace fraction is
less than float32(0.0001). These are immediate contacts in the public CS:GO
movement reconstruction: they must not advance the origin, consume time or
clear earlier planes. This prevents an acute seam's second clip from pushing
velocity back into its first face. Near-vertical contact normals also have
their Z component cleared when its magnitude is below float32(0.0001), so a
wall cannot add spurious vertical speed. The exact boundaries remain strict.

The fraction cutoff is deliberately limited to the float32 BSP/displacement
trace. Imported VPhysics convex sweeps still use double precision and need
their small positive advances; applying the cutoff to those approximate
fractions stalls the existing optimized Boreas route. This exception remains
a known difference from native VPhysics. The v7 changes do **not** eliminate
the 456 strict contact-velocity discrepancies in the two detailed recordings.
Movement settings, crouch timing and hull dimensions are unchanged.

## Implementation and validation

`shared/csgo-physics.mjs` owns the profile and numeric movement corrections.
`shared/csgo-crouch.mjs` owns duck transitions; `shared/csgo-collision.mjs`
owns ground categorization, sliding, stepping, and contact recovery. Duck
fatigue, button history, cooldown and recovery origin live in player state,
so checkpoint restoration and lazy collision-tile retries restore them too.
`scripts/physics-adapter.mjs` embeds the same implementation in the browser
and generated server replay verifier. It also updates the embedded manifest,
input turn timing, physics fingerprint and board IDs. Build extraction runs
before importing the verifier manifest to avoid using a cached older engine.

Every map gets a new physics suffix. Old replays are rejected and old records
stay in their old version; records are not deleted. Map velocity overrides,
incline fix and momentum-carrying stage teleports
remain part of this game's rules. Linear airborne start exits keep momentum.
Landing inside the main start zone caps horizontal speed at 260, an inferred
Cybershoke rule. V5 removes the separate first-stage exit speed cap. Under the
Cybershoke profile, stage teleports preserve world-space velocity and use the
authored trigger destination rather than the practice spawn. They still change
view angles. Other profiles retain their previous stage-velocity rotation.

Ending a tick inside the start zone during a run resets the timer, as surf
timers do: a fail teleport to the start, a stage 1 return or surfing back in.
The player keeps the position and speed the map gave them, and the next run
starts on leaving the zone. Restart stage on stage 1 keeps its run until the
player leaves. `scripts/start-return-adapter.mjs` applies this after the
physics fingerprint, so board IDs are unchanged.

The imported Kitsune and Ace geometry contains specific CS:S spawn points
with insufficient ceiling clearance for a 72-unit hull. Those exact spawn
coordinates are lowered 10 units in both client maps and verifier metadata.
The laboratory crouch tunnel is 55 units high. Reprise's world brushes and
render hulls now come from a public CS:GO BSP; the imported static props and
reviewed trigger metadata are retained. The replacement reduces native route
drift to below 0.18 units through the finish. Its native velocity exceeds 4000,
so Reprise now uses the profile's 5000 ceiling. That ceiling is compatible with
the recording, not a recovered server cvar. Source URLs and BSP hashes live
in `map-data/geometry/surf_reprise.json` and the generated map asset.
Other course geometry is retained. Utopia return destinations
are resolved from its imported BSP entities. Its upper return pair has an
explicit, unverified server compatibility override; see the comparison report.
Legends' `teleport-41` also has an explicit inferred compatibility override:
use its authored absolute destination instead of applying a landmark offset.
Its actual recorded BSP/plugin identity is unknown. V6 removes the one-tick
crouch recovery delay; native-start Legends drift is now below 0.054 units
through the finish, but exact parity is not established.

`npm run build`, `npm run check` and `npm test` validate the generated game.
Movement tests cover numeric gravity/acceleration/friction results, air
projection and steering, jumps, autobhop, crouch clearance, ramp clipping,
stairs and low roofs, interrupted crouches, fatigue and cooldown, swept
uncrouch clearance, thin walls, two/three-plane corners, split ramp seams,
displacement seams, ledges, endpoint overlap, all shipped map start/stage
spawns, browser/server state agreement, checkpoint and tile-retry restoration,
full replay completion, and rejection of older physics versions.

## Limits of the match

The suite now also compares **6,718 adjacent recorded steps** from public 2022
Cybershoke Boreas and Utopia NJV recordings. Run `npm run validate:csgo` for
the complete report, or append `-- --strict` to fail while any discrepancy
remains. [Methods, results and outstanding differences](validation/csgo-comparison.md)
distinguish diagnostic one-step agreement from uninterrupted playback.
The [all-map audit](validation/route-compatibility.md) additionally checks all
the bundled recordings against the expanded map catalog. The generated
`routes-current.json` reports current completion and missing-recording counts;
historical browser/Worker results in the prose report are labelled by version.
Each build regenerates that evidence for its engine fingerprint. Route Lab
displays the measured completion status before preparing a bundled recording.
**Bit-for-bit CS:GO parity has not been established.** In particular:

- The current profile uses the recordings' observed 66 Hz interval directly. Full
  uninterrupted playback stays within 0.144 units on Boreas and 0.691 on
  Utopia. Strict 0.01-unit/units-per-second parity still fails. The files lack
  a build identifier and complete cvar dump. Utopia's start landing cap and
  inactive upper return pair are inferred compatibility rules, not recovered
  server settings or independent verification of all map triggers.

- Duck timing is based on public CS:GO movement reconstruction and server
  plugin observations. It still needs comparison against a specified CS:GO
  binary and captured player states, particularly across engine revisions.
- Collision uses the imported brushes and displacement triangles, not
  Valve's complete BSP tracing engine. Seam, edge and stuck-resolution cases
  can differ. JavaScript trig and remaining double-precision trace math can
  differ from Source's native float implementation.
- Water, ladders, moving platforms, surface jump factors, and weapon-specific
  movement beyond the knife are not fully modeled by this surf engine.
- Timer bounds and some stage/start rules still differ from the recorded
  server. Missing map revisions, plugin rules and pre-recording input history
  prevent the remaining recordings from becoming canonical completed runs.

To certify a particular server, capture its CS:GO build, tick rate, movement
cvars and plugin versions plus per-tick user commands, player positions,
velocities and duck/ground state. Replay those inputs on matching map
geometry, report the first divergent tick, and compare ramp seams, landings,
repeated crouches and teleports as well as free movement.

## References

- [SurfTimer server configuration](https://github.com/surftimer/SurfTimer/blob/master/cfg/sourcemod/surftimer/main.cfg)
  supplies the surf acceleration, friction, gravity and stamina choices.
- [Valve's public Source movement implementation](https://github.com/ValveSoftware/source-sdk-2013/blob/master/src/game/shared/gamemovement.cpp)
  documents the shared acceleration, friction and collision algorithms; it
  is not the complete CS:GO movement implementation.
- [Public CS:GO movement reconstruction](https://github.com/VacCatGT/undercover-csgo-fork/blob/master/gamemovement_rebuilt.cpp)
  describes CCSGameMovement duck speed, ApplyDuckRatio, hull flags and eye
  interpolation. This is a reverse-engineered reference, not Valve source;
  generic SDK HandleDuckingSpeedCrop alone misses the GO override.
- [RNGFix movement prediction](https://github.com/jason-e/rngfix/blob/master/plugin/scripting/rngfix.sp)
  documents CS:GO duck fatigue and cooldown, plus jump and extra half-gravity
  behavior. Its simplified air-duck predictor is not a full duck state machine.
- [GOKZ movement modes](https://github.com/KZGlobalTeam/gokz/wiki/Modes)
  documents CS:GO movement cvars and server-specific variations.
