EdgeWeightGPS

Cyberpunk 2077 RED4ext plugin that improves player GPS routing by penalizing short-segment churn in the native GPS solver. The current validated default pushes the GPS toward smoother, higher-momentum driving corridors without globally forcing every route onto highways.

Current Status

Working prototype, validated in-game.

  • Route scoring patch: enabled.
  • Live tuning file: enabled.
  • Current default fixed-edge penalty: 80.0.
  • Highway multiplier: neutral 1.0; the earlier highway-speed/class experiments are not part of the playable default.

The active package is a RED4ext plugin only:

red4ext/plugins/EdgeWeightGPS/EdgeWeightGPS.dll
red4ext/plugins/EdgeWeightGPS/momentum_weights.bin
red4ext/plugins/EdgeWeightGPS/solver_weights.bin

What It Patches

Reverse engineering found the player GPS route search loop around the native solver relaxation cluster. The useful patch surface is not the script-facing RunGPSQuery/UpdateGPSQuery helpers and not the generated traffic maxSpeed fields. The playable hook patches the two ordinary adjacency expansion sites feeding the native relax/update routine at 0x40ba58.

The plugin adds a nonnegative fixed cost to ordinary edge expansion. In practice, this makes many tiny street segments and repeated 90-degree stair-steps less attractive, while still allowing local roads when they are the right path.

Validation Summary

The default 80.0 penalty was selected after live A/B testing:

  • 0.0: vanilla behavior; visibly stair-stepped in highlighted routes.
  • 40.0: partial improvement, but still missed useful smoother corridors.
  • 80.0: best observed result; selected smoother high-speed corridors and passed drive testing.
  • 160.0: too high; caused bad hairpins/local access and one fallback-style route.

Drive validation at 80.0:

  • The Dogtown route used a smoother highway corridor and drove cleanly at high speed.
  • Live minimap recalculation still worked after a deliberate detour.
  • Claire/Westbrook route also drove cleanly; one blind hill/ramp surprise was driver unfamiliarity, not a route failure.

See docs/gps-momentum-field-tests.md for the detailed test notes, screenshots, and log references.

Build

Build in the Fedora toolbox:

toolbox run -c 2077 ./tools/build_red4ext_shim.sh

This writes:

build/red4ext/EdgeWeightGPS-mingw64/EdgeWeightGPS.dll

Install Locally

Only install while the game is cold.

toolbox run -c 2077 ./tools/install_red4ext_shim.sh

The install script builds the DLL, installs it into the Flatpak Steam Cyberpunk 2077 folder, and writes the validated defaults:

  • momentum_weights.bin = 80.0
  • solver_weights.bin = 1.0

Override the game directory with CYBERPUNK2077_GAME_DIR if needed.

Package

Create a redistributable RED4ext zip:

toolbox run -c 2077 ./tools/package_red4ext_mod.sh

The package is written under dist/ and contains the red4ext/ folder layout expected by the game.

Live Tuning

momentum_weights.bin is a single little-endian float32 and is hot-reloaded every 500 ms while the game is running.

Useful presets:

python3 tools/write_momentum_weights.py vanilla         # 0.0
python3 tools/write_momentum_weights.py default         # 80.0
python3 tools/write_momentum_weights.py overstrong      # 160.0, known too high

solver_weights.bin is still present for older highway multiplier experiments, but the playable default keeps it neutral:

python3 tools/write_solver_weights.py vanilla           # 1.0

Repository Notes

This repository also contains older experiments and reverse-engineering tools:

  • REDmod/archive traffic resource patchers.
  • Traffic lane and connection probability patchers.
  • Static disassembly helpers.
  • RED4ext logging probes.

Those tools are retained because they explain the route-finding system and document failed approaches, but they are not part of the current playable package. The important debriefs are:

S
Description
No description provided
Readme 13 MiB
Languages
Python 80.5%
C++ 12.7%
Shell 4.3%
Red 1.2%
CMake 1%
Other 0.3%