HN
Today

The Math Behind Counter-Strike Surfing

This deep dive into the physics of Counter-Strike surfing meticulously explains how players exploit game engine mechanics—from velocity vectors and air acceleration to ramp angles and unintended sv_maxvelocity interactions—to achieve incredible speeds. It's a fascinating look at emergent gameplay derived from foundational physics, appealing to anyone who appreciates the technical underpinnings of digital worlds and mastery through system exploitation. The author even demonstrates a bot that nearly matches human world records.

30
Score
4
Comments
#9
Highest Rank
12h
on Front Page
First Seen
Nov 29, 3:00 PM
Last Seen
Nov 30, 2:00 AM
Rank Over Time
12910121413141716232726

The Lowdown

The article meticulously breaks down the intricate physics and mathematical principles that underpin "surfing" in Counter-Strike, a beloved custom game mode where players slide along steep ramps. It aims to demystify how this unique movement mechanic works, tracing its roots back to Quake's engine and showcasing how players (and even bots) leverage specific game mechanics to defy typical speed limits.

  • Velocity and Wish Direction: The core concept is explained: velocity dictates movement, while a "wish direction" (player input) influences how the game applies acceleration. Crucially, the Source engine's Accelerate() function caps how much speed can align with input, but not overall speed.
  • Air Acceleration & Friction: In the air, AirAccelerate() applies input at a reduced rate (30 u/s) and, critically, without friction. This allows players to retain existing speed and build upon it.
  • The Art of Strafing: The secret to speed gain lies in continuous strafing. By constantly turning the mouse while holding a strafe key (A or D), players continuously present a "fresh" direction for acceleration, incrementally increasing their overall velocity beyond the typical cap.
  • Ramp Physics: Surfaces steeper than approximately 45.57° are treated as "air," meaning they have no friction. Gravity pulls the player down these ramps, converting vertical fall into horizontal speed. Staying on a ramp requires precise input to push into its face, balancing against gravity.
  • Map Design & Speed Limits: Map features like ramp steepness and booster boxes play a crucial role. A surprising revelation is that the sv_maxvelocity limit (default 3500 u/s) is applied per-axis, meaning diagonal movement can achieve speeds up to ~4950 u/s, and falling can push it even higher (≈6062 u/s).
  • Strafe Jumping's Legacy: The article takes a brief detour into Quake's strafe jumping, an "exploitable bug" that John Carmack noted, highlighting the historical lineage of these advanced movement techniques.
  • The Surfing Bot: The author details their creation of an AI bot that uses a beam search across many "puppets" to find optimal surfing paths on maps, achieving times just shy of human world records. The bot's score function prioritizes factors like speed, progress, and altitude.
  • Behind the Scenes: The author shares insights into the article's creation, emphasizing the live rendering of all maps and gameplay directly from game files for performance, resolution, and a "lofi" aesthetic, avoiding heavy video files.