Algorithms: what the kit took from TheAlgorithms

Two repositories were read in October 2026:

What a game needs from them

Most of both is what a computer science course covers and Godot or .NET already provides (AStarGrid2D, AStar2D, NavigationServer, Geometry2D, PriorityQueue, Array.Sort). Five gaps were worth tested code or a check:

Gap Where now Instead of
Many agents toward one target, and fleeing Example.Core/Ai/DistanceField.cs (a Dijkstra map, after Brian Walker's Brogue) one A* search per agent
Connected regions on a grid Example.Core/Procgen/Regions.cs (Regions.Label, RegionMap) a recursive flood fill
Joining as you go DisjointSet in the same file re-filling after every change
"Did you mean" Example.Core/Ui/Suggest.cs; Get-EditDistance and Get-ClosestName in ci/godot/lib/Common.ps1 String.Similarity, which misses swapped letters
Prerequisites that loop the data runner's acyclic field rule (ci/godot/lib/Data.ps1, Find-DataCycles) finding out in a playtest that a tech can never be researched

The kit's own output uses the suggestions: the data runner names the near id, enum value, column or table, and test -Runners gdunit answers 'gdunit' is probably 'gdunit4'.

From the explanations, two lessons that are not in the code repository either: insertion sort is linear on nearly sorted input (a draw order or turn queue sorted again every frame), and a stable sort keeps equal keys in order. Both were measured (below). The rest (Bloom filters, tries, ciphers, quick select) has no common use in a game that a HashSet, a Dictionary or a PriorityQueue does not cover; saves are not protected by a cipher (anti-cheat).

Measurements

.NET 8.0 (Release), Godot 4.7.2, 4 cores, Linux. A grid with 20% random walls, the largest open region kept, the goal in its first cell; 200 agents on random open cells. The comparison program referenced TheAlgorithms' projects from a separate clone (StyleCop analyzers off) and Example.Core; it is not committed, since it needs the GPL code to run.

Grid DistanceField.Build 200 downhill walks TheAlgorithms Dijkstra TheAlgorithms A* x 200 AStarGrid2D x 200 (GDScript)
32 x 32 0.56 ms 0.36 ms 12.1 ms 69 ms
64 x 64 1.15 ms 0.41 ms 45.8 ms 197 ms 30.8 ms
128 x 128 1.43 ms 0.48 ms 792 ms 530 ms 130.7 ms

Tests

tests/Example.Core.Tests/AlgorithmsTests.cs (23 cases: a million-element union-find chain, an open 1000 x 1000 fill, labels checked against union-find on a random grid, walking distances round walls and mud, diagonals that never cut corners, fleeing, rebuilds that leave nothing behind, edit distances and suggestions) and tests/Test-Data.ps1 (cycles, the near names, a misconfigured acyclic, Get-EditDistance against the C# values).