I) check which of the hulls are available for the empire based on tech - manual selection of combat-suitable hulls
II) find the maximum weapon level, standard armor level (i.e. without need of ressources), tank, engine, shields
III) Use only weapons and armor plates in external slots and fill all of these
IV) Use only engine parts, fuel tanks (or none of these) in the internal slots
V) For each available hulls, make all combinations of the following traits:
1. weapon count: 1/4 - 2/3 of the available slots
2. Shield - yes/no?
3. Fill all inner slots with either fuel tanks or improved engines
Yet to do:
-add core slots
-add ressource-based armor
-change heuristic for end-game ships to reduce number of combinations (must have shields, narrow down interval of weapon count)
-delete outdated designs (is there an interface available for this?)
-make restrictions for the lower difficulties (is this really a good idea to have this here anyway? Imo this should be controlled by the tech route the AI at lower difficulties takes)
Possible extensions in the future:
-write heuristic for other ship classes
-Directly calculate the "optimum" setup based on some parameters (i.e. attack-structure-cost ratio, desired internal parts, speed etc.pp) which might be passed and updated dependend on the current situation the AI is in (e.g. facing enemy with MSS through ruins, need more fuel to reach enemy planet, ...). Then only create the best designs for each Hull (possibly even only shipyard/Ressource).
Before doing so, however, the AI's capability of understanding the ressource system, tactical value of speed/fuel and of course also shield-value vs. increased cost should be improved. How does one evaluate the Organic-Structure gain correctly? Etc. pp., so at the moment just adding more designs than needed to be evaluated elsewhere.
-Parse hull info from .txt file once, then store it somewhere. Evaluate usefulness for each task to obtain a hull-list suitable for each ShipType.
-the same for the ship parts.
As part of this patch, each combat hull also receives a new unique name (obviously free to change).
The generated name of the design is finally given by:
[H] - Class name based on the hull (e.g. "Griffon" for Organic Hull, "Lynx" for standard hull)
[W] - determined by the used weapon, e.g. "L4" for Laser level 4.
[nw] - number of weapon slots used in the design
[A] - determined by used armor, e.h. "Z" for Zortrium plate
[sl] - used shield level, e.g. "0" for no shield, "2" for deflector shield
[nt] - number of fuel tanks used in the design
So we (currently) end up with names like "Comet-L4x1-Z1-1", "Griffon-L4x1-Z0-0" etc. I think the initial part is ok but maybe a better encoding for the internal parts might be nice.
I am aware of the fact that the additional functions I added should probably be moved to a seperate .py file where all kind of these functions should be stored. However, I would like to discuss the general structure of the file ProductionAI.py.
I would suggest to actually move all the addXDesign() to a seperate file. The rating of the designs should probably be moved also to either this file or another one. ProductionAI.py would completely focus on the decision-making part, i.e. what to produce right now from the available options. I suppose for this purpose it only makes sense to move all functions but spentPP() and generateProductionOrders().
The latter one is quite a monster at the moment and I suppose it would be helpful to split this function into multiple. I would go as far as to move all the implementing code to new functions and have generateProductionOrders() be merely a collection of function calls such as
Code: Select all
QueueShipYards() QueueUniqueBuildings() QueueShips() SortQueueByPriority()
PS: I'm having more of a scientific programming background (and non-python) so I'm used to write code relatively quick and dirty just to see if it works and then give the algorithm to a real programmer who then implements it "correctly" in accordance to language specific style guidelines, implementation specific speed etc. pp.
So while I'm trying my best, feel free to point out any issues in the coding style or any horrible non-python stuff I do.
/Edit: Outdated patch removed