Excruciating FOCS doubts

Creation, discussion, and balancing of game content such as techs, buildings, ship parts.

Moderators: Oberlus, Committer

Message
Author
wobbly
Cosmic Dragon
Posts: 2010
Joined: Thu Oct 10, 2013 6:48 pm

Re: Excruciating FOCS doubts

#226 Post by wobbly »

Its 3 * ((Planets/most common focus) - 1)

Ophiuchus
Programmer
Posts: 3524
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Re: Excruciating FOCS doubts

#227 Post by Ophiuchus »

LienRag wrote: Thu May 23, 2024 11:38 am I tried to look for the function "HistogramMax" in the Detailed FOCS scripting page but it's not documented there.
in focs.txt it is the Max statistic. Why the rename? My guess: it is the ~same string used for the mathematic maximum function. As the python parsing is not context aware, every different thing needs a different name, so the statitiscs Max became more specific.
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13619
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Excruciating FOCS doubts

#228 Post by Geoff the Medio »

Code: Select all

Statistic Count condition = And [ Planet OwnedBy empire = Source.Owner]
Returns the number of planets owned by the owner of the source object. For a policy, the source object is the capital of the empire that adopted the policy.

Code: Select all

Statistic HistogramMax value = LocalCandidate.Focus condition = And [ Planet OwnedBy empire = Source.Owner]
Gets a set of planets owned by the source object's owner, finds the focus that each of them has, and calculates a histrogram of those values. So if there are 6 planets with foci [Industry, Industry, Influence, Research, Influence, Influence] then the histrogram would be [Industry: 2, Research: 1, Influence: 3]. HistogramMax then returns the number of times the most common value in the histogram appears, or 3 in this case. This is distinct from a Max statistic, which would take a list of numerical values like LocalCandidate.Population -> [1, 2, 5, 4, 2, 0] and return the largest value in that set, or 5 in that example.

Ophiuchus
Programmer
Posts: 3524
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Re: Excruciating FOCS doubts

#229 Post by Ophiuchus »

Geoff the Medio wrote: Sat May 25, 2024 9:33 am

Code: Select all

Statistic HistogramMax value = LocalCandidate.Focus condition = And [ Planet OwnedBy empire = Source.Owner]
Gets a set of planets owned by the source object's owner, finds the focus that each of them has, and calculates a histrogram of those values. So if there are 6 planets with foci [Industry, Industry, Influence, Research, Influence, Influence] then the histrogram would be [Industry: 2, Research: 1, Influence: 3]. HistogramMax then returns the number of times the most common value in the histogram appears, or 3 in this case. This is distinct from a Max statistic, which would take a list of numerical values like LocalCandidate.Population -> [1, 2, 5, 4, 2, 0] and return the largest value in that set, or 5 in that example.
thanks.
added following to the details page:

Code: Select all

HistogramMax       - Returns the count of the most common property value
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13619
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Excruciating FOCS doubts

#230 Post by Geoff the Medio »

All the available statistic types are described here: https://github.com/freeorion/freeorion/ ... Ref.h#L139 and the (non-Python) parser strings for those are here: https://github.com/freeorion/freeorion/ ... r.cpp#L111

Post Reply