Cjkjvfnby wrote:What I want:
split code for two layers:
- information layer
- decision layer
Further increasing the separation between these tasks sounds like a *generally* fine idea to me. The AI does generally start each turn with a large information gathering step and then alternates between decisions and some smaller information gathering steps. Most of the existing individual functions do already primarily serve either one or the other of these purposes, although they are spread out among the different modules dependent on the subject matter being dealt with, and many of the "decision" functions still do at least some small amount of direct information gathering.
So, it sounds like this proposal is primarily one of grouping the information gathering functions together into a single module, refactoring many of the larger functions into smaller, more focused pieces, and then refining the various decision functions so that they are more purely decision-only.
Certainly, a number of the functions have grown quite large, and refactoring them into smaller pieces would surely be helpful. Regrouping everything according to 'layer', well, might be helpful. The current set of modules is one I mostly inherited; I'm not particularly wedded to the way things are grouped if there is a better organization to be had. Did you have any more specifics to offer regarding your ideas for the layers?
This is most important part. It should be as small as possible. Get info in couple of lines, make decisions....Decision layer will ask this question and rate planet by its own rules. Code like
Code: Select all
if "COMPUTRONIUM_SPECIAL" in planet.specials:
should be placed in info layer and never be on decision layer.
Hmm, well if you expect your 'decision' layer to be making any nontrivial decisions with only a couple of lines of information, and that it would not be making queries like whether a planet had a COMPUTRONIUM_SPECIAL, then it seems to me like the real guts of the decision code would actually be embedded in your 'information' layer, and your 'decision' layer would really just be primarily converting previous decisions into game Orders. But perhaps I'm misunderstanding what you are really proposing.
(1) It sounds like something we both definitely agree on is that some of the larger functions would be better off refactored into smaller chunks.
(2) Also, regrouping the existing functions based on whether they are primarily collecting and compiling information, versus making decisions based on that information, sounds like a generally ok idea to me as well. Do you mean to propose just two modules, or two higher level modules with submodules, or what?
As for what I understand to be a vision for an ultra-streamlined decision layer, I think I may not be really understanding you right. You could try to clarify this aspect of the proposal right now, or perhaps we could try to first proceed with (1) and (2) and then it would probably be easier to have a more focused discussion on streamlining the 'decision' layer and perhaps moving more code into the 'information' layer.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0