Many games have got reimplementations. But Civ4 will be different from most as you have the DLL source available. There's always the chance it might get nuked, but unlikely. They might not pay much attention to a mere console implementation.
Anyway, I want to make super huge maps practical by improving the pathfinder. Just like Factorio, I'm starting with a coarse heuristic to make A* not so much like dijkstra. Cut down on the visit set:
16x16 blocks. The coarse uniform-cost heuristic is itself a pathfinder, which starts from the goal. Even with this overhead, a basic min movement cost path search, using a std priority queue and a hash map of nodes, is much faster than vanilla. Some of that advantage will diminish though once I include all the pathing checks in
pathCost
and
pathValid
.
And that's without caching. I hope caching will be effective. Cache both the coarse heuristic and plot-wise block-local paths. One annoying thing though is that
pathValid
depends on enemy positions, including barbs, and there's a handful of animals running around in every block. What I would probably do is switch to a binary block-local validity check for distant blocks. Technically suboptimal, but such checks will become out of date anyway until you get close.
And on top of path caching, AI path requests could be improved with turn limits just like K-Mod, and use of the coarse heuristic when finding the nearest city. Only takes about half a millisecond to compute the coarse heuristic. And to help path caching, it would be better to start pathing from stationary targets rather than units. This is another slight sub-optimality as Civ4 movement is asymmetric: it can take a few extra turns to go in the opposite direction.