AssignStartingPlots - An Exercise in Murder

Gorbles

Load Balanced
Joined
Nov 24, 2014
Messages
11,955
Location
UK
This isn't a help thread or anything, just a general "why on earth" question-based thread.

Why is the file so hideously verbose? Why is everything so horrendously spread-out? Is anyone sitting on a "cleaned-up" version that they might have caved and worked on? I'm planning to myself, but that's going to take a solid weekend of Pepsi and crying myself to sleep (I'm no slouch, but one thing wrong can break map generation, which makes things awkward).

Is there any reasoning behind what looks to be the unnecessary duplication of assigning resources to files? Does anyone else share my criticisms, or am I just being naive and everything in that file actually has a relevant purpose that can't be simplified or tidied up?
 
I might have answer for "why":

The original starting plots finder used in Civ4 relied heavily on C++ code, specifically the CvSiteEvaluatorForStart and CvCitySiteEvaluator classes. These classes only needed a few updates between Civ5 expansions, and generally functioned by having a map generated first, then assigning starting plots based on the current map at hand.

Firaxis wanted to change the terrain generation setup for Civ5: as written in the comments section of AssignStartingPlots.lua, they wanted to generate starting plots first, then shape the map around the starting plots. However, there presumably was a shortage of C++ programmers (for whatever reason), so Firaxis decided to do the rewriting on the Lua side instead of the C++ side.
Problem is that while the C++ side already has access to a bunch of helper functions from the CvPlot class, the Lua side does not, so not only did Firaxis have to port the site evaluation functions to Lua, they also had to recreate all the C++ helper functions used by the site evaluation functions as well. Oh yes, and the CvPlot helper functions also had access to other helper functions (from things like religions and cities), so guess what also needed to be recreated in Lua?

So yeah, the reason everything is so convoluted-looking is because Firaxis needed to recreate all the methods and functions from at least four C++ classes in Lua, and of course they're located in a single file for some reason.
Also, the entire map generation logic thing is kind of backwards: implementing the impact-ripple stuff and easy terrain vs. high value terrain stuff on the map generation side would have been a much more logical choice IMHO (the former as fractal seeds, the latter as a common script that the default mapscripts could reference, but that player mapscripts could opt to reference selectively).
 
I might have answer for "why":

The original starting plots finder used in Civ5 relied heavily on C++ code, specifically the CvSiteEvaluatorForStart and CvCitySiteEvaluator classes. These classes only needed a few updates between Civ5 expansions, and generally functioned by having a map generated first, then assigning starting plots based on the current map at hand.

Firaxis wanted to change the terrain generation setup for Beyond Earth: as written in the comments section of AssignStartingPlots.lua, they wanted to generate starting plots first, then shape the map around the starting plots. However, there presumably was a shortage of C++ programmers (for whatever reason), so Firaxis decided to do the rewriting on the Lua side instead of the C++ side.
Problem is that while the C++ side already has access to a bunch of helper functions from the CvPlot class, the Lua side does not, so not only did Firaxis have to port the site evaluation functions to Lua, they also had to recreate all the C++ helper functions used by the site evaluation functions as well. Oh yes, and the CvPlot helper functions also had access to other helper functions (from things like religions and cities), so guess what also needed to be recreated in Lua?

So yeah, the reason everything is so convoluted-looking is because Firaxis needed to recreate all the methods and functions from at least four C++ classes in Lua, and of course they're located in a single file for some reason.
Also, the entire map generation logic thing is kind of backwards: implementing the impact-ripple stuff and easy terrain vs. high value terrain stuff on the map generation side would have been a much more logical choice IMHO (the former as fractal seeds, the latter as a common script that the default mapscripts could reference, but that player mapscripts could opt to reference selectively).

Ummm... ASP.lua from late vanilla is almost identical to ASP.lua from G&K is almost identical to ASP.lua from BNW, is almost identical to ASP.lua from BE.

The only differences from BNW to BE are that they removed the code for Natural Wonders and Start Biases. G&K to BNW the only thing different is Venice's special Start Bias (they get the best ocean start). late vanilla to G&K they altered Natural Wonder placement to work with a bunch of new XML values instead of from hardcoded ones. I don't have an early vanilla Civ V version to compare, but late vanilla to BE is essentially the same exact code.

With all that being said, ASP.lua is a four letter word around here. :eek:
 
Ummm... ASP.lua from late vanilla is almost identical to ASP.lua from G&K is almost identical to ASP.lua from BNW, is almost identical to ASP.lua from BE.

The only differences from BNW to BE are that they removed the code for Natural Wonders and Start Biases. G&K to BNW the only thing different is Venice's special Start Bias (they get the best ocean start). late vanilla to G&K they altered Natural Wonder placement to work with a bunch of new XML values instead of from hardcoded ones. I don't have an early vanilla Civ V version to compare, but late vanilla to BE is essentially the same exact code.

With all that being said, ASP.lua is a four letter word around here. :eek:

I stand corrected and have changed the original reply to suit... I still find the way they want about implementing it is a bit baffling, especially since they're not loading in values from XML files.
 
since they're not loading in values from XML files.

The XML/Database values are used by WorldBuilder. The C++ starting plot finder is then used if starting plots aren't assigned in WB

The move to Lua was supposed to make it easier / more flexible for modders to add/change the map scripts.

And then there was a half-hearted attempt to drive the map scripts from other values (mainly for natural wonders) in the XML/Database.

The net result is that map generation is just very confused and confusing.
 
Top Bottom