enabling a DoesNotPartitionEmpires scripting requirement

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderator: Committer

Post Reply
Message
Author
User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

enabling a DoesNotPartitionEmpires scripting requirement

#1 Post by Dilvish »

This is to talk through issues regarding a Condition I am considering, partly simply as a reminder/notes for myself, and partly to solicit comments and suggestions.

The key thing I want to be able to support as a scripting requirement (either as a complex macro or directly as a Condition) is a DoesNotPartitionEmpires (or somesuch) scripting Condition/Macro, which takes as a condition a list of systems to be excluded from the system graph, and then (in the simplest form I am contemplating) returns a bool which is true if either (i) the excluded systems do not form one or more 'cuts' that divide the system graph into two or more subgraphs with no connections between them, or (ii) even if they do, their are no empire homesystems located outside of the largest of such subgraphs. A primary use would be to enable a location restriction for any special that could generate a Sentinel or Warden, so that they do not wall off an empire from the rest of the galaxy (can make for a very frustrating game if you are stuck on the smaller side of that blockade). I think this could also be used for the experimentor outpost location.

There are surely a variety of ways the main problem could be approached, what I am currently leaning towards is a "MainPartition" Condition, which takes a mandatory parameter "graph_excludes=" or just "excluding=" which specifies a condition for the systems to be excluded when making the partition/cut determination; this MainPartition Condition would then return all the systems which are in the largest subgraph (which, if the excluded systems do not form at least one 'cut' in the main system graph, would be all the non-excluded systems). If the two largest subgraphs are tied in size, then I would probably have this return no Systems (because that is the easiest way to support the kind of decision I want and I don't see a compelling need to accept a situation where the entire galaxy is divided in half by Sentinels/Wardens/Experimentors).

To facilitate this I would change the HasSpecial Condition (and parser) so that it could accepts a list of specials (like many of our other similar Conditions) rather than just a single special.

I would probably make a group of macros to facilitate this being used most easily, I think something like

Code: Select all

PARTITIONING_SPECIALS
'''ANCIENT_RUINS_SPECIAL
HONEYCOMB_SPECIAL
FORTRESS_SPECIAL
PANOPTICON_SPECIAL
GAIA_SPECIAL
'''

HEAVILY_GUARDED_SYSTEMS
'''And [
            System
            Contains condition = HasSpecial [  [[PARTITIONING_SPECIALS]]  ]
]
'''

// Note, the following uses RootCandidate rather than LocalCandidate for efficiency, although that may limit
// the potential uses of this particular macro
NON_EMPIRE_PARTITIONING
'''Or [
        ValueTest high = 0 testvalue = GalaxyMonsterFrequency
        ValueTest 
             low = Count condition = And [System Contains Capital]
             testvalue = Count condition = And [
                                                                MainPartition excluding = Or [ RootCandidate.System [[HEAVILY_GUARDED_SYSTEMS]] ]
                                                                Contains Capital
                                                          ]
]
'''
Seem like a good idea? Suggestions for better efficiency?
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: enabling a DoesNotPartitionEmpires scripting requirement

#2 Post by MatGB »

Definitely a good idea, with the observation that Ruins don't always get Sentinels, I think because they're too close to an empire? Of course, they could be restricted in such a way that they're not too close so they always get sentinels.

But yeah, I tend to restart games if I find I'm walled in, I know I can work my way out with just one homeworld, but it's not fun, and I'm playing for the fun.
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Post Reply