Sprint - Exciting Insights
from Translating an Old
Videogame to JavaScript
Norbert Kehrer
ViennaJS Meetup, March 30, 2016
„Sprint“ is a primitive car-racing game,
but it holds interesting aspects
Atari 1976: Sprint 2
Arcade machine
Very limited hardware
Black-and-white graphics
Many sequels
Fun with Sprint
Make a browser game
Make it 3D
Understand the car AI
Design new levels
Use the methods in other projects
Fun with Sprint
Make a browser game
Make it 3D
Understand the car AI
Design new levels
Use the methods in other projects
The Sprint arcade machine is based on the
6502 microprocessor
ROM: Program and 12 race tracks
RAM 128 bytes
Screen RAM 32 x 28 6502
Special-purpose video
hardware
Game logic Video hardware
Original 6502 code translated to JavaScript
makes up a browser game
ROM: program
and 12 race tracks
RAM 128 bytes
Screen memory 32 x 28 6502
Special-purpose video
hardware
Game logic Video hardware
JavaScript
program
JS simulator of the
video hardware
Browser game
Fun with Sprint
Make a browser game
Make it 3D
Understand the car AI
Design new levels
Use the methods in other projects
Alternative interpretation of the game state
and screen memory makes it a 3D game
Little
Cubes
3D Objects
Camera
Fun with Sprint
Make a browser game
Make it 3D
Understand the car AI
Design new levels
Use the methods in other projects
Fun with Sprint
Make a browser game
Make it 3D
Understand the car AI
Design new levels
Use the methods in other projects
Designing new Sprint levels is a lot of work
Design the race track itself
Define all those direction vectors
Test it
Automation is a quite hard robotics problem
Design the race track itself
Define all those direction vectors
Test it
Automatically
by using the
potential field
method
Scalar fields (potential fields)
1 5
9
13
17
21
25
29
R1
R7
R13
R19
R25
R31
-450
-400
-350
-300
-250
-200
-150
-100
-50
0
z = f(x, y)
The gradient field indicates the direction of
the steepest slope
Source: „Kurs: Mathematik für Anwender (Osnabrück 2011-2012)“
Robot path planing by finding an adequate
potential field
Source: Diemke: „Pfadplanung mit harmonischen
Potentialfeldern“
Applying the potential field method to Sprint
Obstacles are given (track boundaries)
Calculate a harmonic potential field („bobsled track“)
From that, calculate its gradient field
The result is the vector field for the Sprint level
The calculation is not fast, but slow
Complex mathematics
BUT: Unbelievably simple algorithm (Gauss 1823 und
Seidel 1874)
64-bit floating-point numbers are not exact enough
BigNumber library needed
Slow also because of iteration (30 seconds per level)
Fun with Sprint
Make a browser game
Make it 3D
Understand the car AI
Design new levels
Use the methods in other projects
You can use the potential field method
Path planning for robots
Lawn mowers
Vacuum cleaners
Robo soccer
Autonomous cars
Games with moving computer oponents
Car racing
Mario-Kart-like games
Etc.
Summary
Browser Sprint by code translation
3D Sprint by alternative interpretation
Patented vector fields for the car AI
Automatic level generation with the Potential Field Method