Influence and policies API overview

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

Moderator: Committer

Post Reply
Message
Author
User avatar
Cjkjvfnby
AI Contributor
Posts: 539
Joined: Tue Jun 24, 2014 9:55 pm

Influence and policies API overview

#1 Post by Cjkjvfnby »

I am inspecting what API could be used for working with influence and policies from Python.
  • It is not possible to reach an instance of the InfluenceQueue. Recommendation -> remove it. Influence purchases are applied in one turn. I don't see any use-case for AI.
  • I played for 6 tuns: all this outputs are 0.0. Is it a bug?

    Code: Select all

    empire.resourceProduction(fo.resourceType.influence)
    empire.resourceProduction(fo.resourceType.influence)
    empire.resourceProduction(fo.resourceType.influence)
  • I don't know how to get policy info (cost and cost per turn). I could hardcode this, since I will need hardcode policies effects.
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
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Influence and policies API overview

#2 Post by Geoff the Medio »

Cjkjvfnby wrote: Wed Aug 11, 2021 9:58 pm...InfluenceQueue. Recommendation -> remove it.
Can do.
I played for 6 tuns: all this outputs are 0.0. Is it a bug?

Code: Select all

empire.resourceProduction(fo.resourceType.influence)
empire.resourceProduction(fo.resourceType.influence)
empire.resourceProduction(fo.resourceType.influence)
IS this any different for other resource types? Either way, I think you need to do call universe.updateMeterEstimates() first, for thost values to be meaningful.
I don't know how to get policy info (cost and cost per turn). I could hardcode this, since I will need hardcode policies effects.
some_policy.adoptionCost(empire_id) should work. There is usually a cost to adopt apolicy, but there is no fixed cost per turn to keep it adopted. Policies can have effects that modify planets' influence output, but you'd have to adopt one and do a meter update and add up all the new empire target influence meters (and every other meter that might be affected) to know what the medium-term result of adopting is on influence output. It can also be a net positive to adopt a policy...

User avatar
Cjkjvfnby
AI Contributor
Posts: 539
Joined: Tue Jun 24, 2014 9:55 pm

Re: Influence and policies API overview

#3 Post by Cjkjvfnby »

Geoff the Medio wrote: Wed Aug 11, 2021 10:29 pm
Cjkjvfnby wrote: Wed Aug 11, 2021 9:58 pm...InfluenceQueue. Recommendation -> remove it.
Can do.
Cool.
I think you need to do call universe.updateMeterEstimates() first, for thost values to be meaningful.
Just moved my test after that block and it works.
some_policy.adoptionCost(empire_id) should work.
Missed this class.

Thank you.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

Post Reply