FreeOrion

Forums for the FreeOrion project
It is currently Wed May 23, 2018 5:18 am

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Mon Jan 08, 2018 9:03 am 
Offline
Space Floater

Joined: Sat Jul 01, 2017 4:54 am
Posts: 32
I am wanting to experiment with custom meters for trade and infrastructure (and probably population later on).

I would like to get some help with where/what to modify.
It looks like I should create something like PopCenter for both trade, infrastructure to do custom calculations for the meter targets and growth values.
Not seeing how target_meter_value is set/determined ATM. Where would I find that? Having trouble back tracking: float target_meter_value = target->Current(); That is, where is population taking specials and tech into consideration?

For trade I want to iterate over all colonies/planets of current empire( and trade allied empires).
Info I want to use: distance as uu, distance as jumps(supply limit), pop size, species, planet type, planet focus
Where is good example that I can copy+modify?

In ResourceCenter.h I see METER_CONSTRUCTION but no infrastructure, is METER_CONSTRUCTION === infrastructure?


Top
 Profile  
 
PostPosted: Mon Jan 08, 2018 9:45 am 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12188
Location: Munich
Gault.Drakkor wrote:
Not seeing how target_meter_value is set/determined ATM. Where would I find that? Having trouble back tracking: float target_meter_value = target->Current(); That is, where is population taking specials and tech into consideration?
Not sure exactly what you're asking. Are you aware that scripted effects are used to set meter values? Are you asking in what functions effects are executed? Or where / when those functions are run? Or where the API for effects scripting is defined? Or how meter-setting effects work internally when executed?
Quote:
For trade I want to iterate over all colonies/planets of current empire( and trade allied empires).
Info I want to use: distance as uu, distance as jumps(supply limit), pop size, species, planet type, planet focus
Most of that is accessible in scripted effects. There are lots of examples in the scripting directory, eg. https://github.com/freeorion/freeorion/ ... D.focs.txt or https://github.com/freeorion/freeorion/ ... H.focs.txt and https://github.com/freeorion/freeorion/ ... macros#L57
I'm not sure whether you want / need to add new meters to something, or just change / add effects that determine existing meters' values.
Quote:
Where is good example that I can copy+modify?
If you can be more clear / specific about what you're trying to do, a relevant example can probably be found. I'm not yet sure if you want / need to modify C++ code, or just effect scripting.
Quote:
is METER_CONSTRUCTION === infrastructure?
Yes.


Top
 Profile  
 
PostPosted: Tue Jan 09, 2018 6:31 am 
Offline
Space Floater

Joined: Sat Jul 01, 2017 4:54 am
Posts: 32
Geoff the Medio wrote:
I'm not sure whether you want / need to add new meters to something, or just change / add effects that determine existing meters' values.
Quote:
Where is good example that I can copy+modify?
If you can be more clear / specific about what you're trying to do, a relevant example can probably be found. I'm not yet sure if you want / need to modify C++ code, or just effect scripting.


Thank you for your reply.

I'll describe what I want to try doing. Hopefully it will be clear enough for you to point me in the right direction.

Trade:
I want to implement something along the lines of an inverse square law:
Code:
def update_planet_trade(current_planet):
    trade = 0
    for planets in empire:
        if planet in supply_range:
            trade += empire_trade_bonus * current_planet.pop * planet.pop/
                        (distance_in_uu(current_planet, planet)**2)
    current_planet.target_trade = trade

With additional values going into it. such as:
  • The supply of current planet and other planet.
  • The infrastructure of current planet and other planet.
  • If trade is current focus of either planet.
  • Species of current planet and other planet, (and their trade bonus/malus).
  • Planet type, different types would be a small bonus.
I would want to keep track of, say top 5, trade partners and display that in the tool tip.

I don't believe I can do this in the FOCS.

Infrastructure:
I haven't firmed up my formulas yet.
So far:
  • Cost of each point of infrastructure to be exponential.
  • Production multiplier for each unit of infrastructure to have diminishing returns.
  • Perhaps a capacity factor like what moo3 had. (will probably not include this)
  • Maintenance cost.
  • Current infrastructure to be used for current trade, current trade to be used to determine next/increment of infrastructure.
  • Planning to siphon off 10% of trade /production every turn.

Population:
Control population not by determining population cap, but by determining population growth. So probably a creation of an additional meter: population growth. With one unit of the growth meter being 0.1% growth to apply to the population meter. I would also need to modify techs, specials too affect growth not population cap, but that I know how to do If there is a separate growth meter.
I am pretty sure I can figure out creation of an additional meter, not sure how to display that in the UI though, but haven't looked into that at all.


Top
 Profile  
 
PostPosted: Tue Jan 09, 2018 9:27 am 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12188
Location: Munich
Gault.Drakkor wrote:
Trade:
I want to implement something along the lines of an inverse square law:
Code:
def update_planet_trade(current_planet):
    trade = 0
    for planets in empire:
        if planet in supply_range:
            trade += empire_trade_bonus * current_planet.pop * planet.pop/
                        (distance_in_uu(current_planet, planet)**2)
    current_planet.target_trade = trade

With additional values going into it. such as:
  • The supply of current planet and other planet.
  • The infrastructure of current planet and other planet.
  • If trade is current focus of either planet.
  • Species of current planet and other planet, (and their trade bonus/malus).
  • Planet type, different types would be a small bonus.
An effect like SetTargetTrade value = [stuff] can have arbitrarily complicated [stuff], which can (or can be made to on request) reference all of those properties.
Quote:
I would want to keep track of, say top 5, trade partners and display that in the tool tip.
That would require C++. Doing it in a sitrep message might be possible just in FOCS.
Quote:
Infrastructure:
  • Cost of each point of infrastructure to be exponential.
  • Production multiplier for each unit of infrastructure to have diminishing returns.
  • Perhaps a capacity factor like what moo3 had. (will probably not include this)
  • Maintenance cost.
  • Current infrastructure to be used for current trade, current trade to be used to determine next/increment of infrastructure.
  • Planning to siphon off 10% of trade /production every turn.
A SetTargetIndustry effect could refer to infrastructure (construction meter) with an arbitrary function to determine how to change the meter value. Similarly, SetConstruction (to increment construction meter) can refer to arbitrary combinations of meters. The rest are unclear / vague.
Quote:
Population:
Control population not by determining population cap, but by determining population growth. So probably a creation of an additional meter: population growth. With one unit of the growth meter being 0.1% growth to apply to the population meter. I would also need to modify techs, specials too affect growth not population cap, but that I know how to do If there is a separate growth meter.
I am pretty sure I can figure out creation of an additional meter, not sure how to display that in the UI though, but haven't looked into that at all.
If you want a separate growth meter to appear in the UI, it would require C++ modifications. The actual population changes are currently implemented in C++ code, https://github.com/freeorion/freeorion/ ... r.cpp#L102 although this should probably be moved into an effect regardless of your plans.


Top
 Profile  
 
PostPosted: Wed Jan 10, 2018 7:19 am 
Offline
Space Floater

Joined: Sat Jul 01, 2017 4:54 am
Posts: 32
Geoff the Medio wrote:
An effect like SetTargetTrade value = [stuff] can have arbitrarily complicated [stuff], which can (or can be made to on request) reference all of those properties.

Ok, underestimated what you can do in FOCS.

Geoff the Medio wrote:
If you want a separate growth meter to appear in the UI, it would require C++ modifications. The actual population changes are currently implemented in C++ code, https://github.com/freeorion/freeorion/ ... r.cpp#L102 although this should probably be moved into an effect regardless of your plans.

So something like this?
Code:
POPULATION_CHANGE
'''EffectsGroup
            scope = Source
            activation = Planet
            effects = SetPopulation value = min(Value  * ( Target.Population + 1 - Value) / 100, Target.Population - Value)
'''


I see via orbital drydock how to do functions. Not sure about looping. The web page and the existing scripts don't seem to have much.

I believe I have enough info to write up what I want to do and try some of them(infrastructure and population growth) In game. I'll come back later with a more complete writeup of what I want to do with trade, and better understanding of FOCS.
Thank you for your help.


Top
 Profile  
 
PostPosted: Wed Jan 10, 2018 7:38 am 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12188
Location: Munich
Gault.Drakkor wrote:
[So something like this?
Code:
POPULATION_CHANGE
'''EffectsGroup
            scope = Source
            activation = Planet
            effects = SetPopulation value = min(Value  * ( Target.Population + 1 - Value) / 100, Target.Population - Value)
'''
That would set the population equal to what is currently the change in population each turn.

Quote:
I see via orbital drydock how to do functions. Not sure about looping.
You don't need to loop; you need to sum, which is a statistic, eg. https://github.com/freeorion/freeorion/ ... ocs.txt#L2


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group