Help needed with scripting supply ships

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

Moderators: Oberlus, Committer

Message
Author
dbenage-cx
Programmer
Posts: 389
Joined: Sun Feb 14, 2016 12:08 am

Re: Help needed with scripting supply ships

#16 Post by dbenage-cx »

I rebased the code.
Something went wrong, if "git rebase master" does not resolve, it may be easier to cherry-pick to a clean branch (could probably clean it up with reflog, but that may be tricky).
e.g. (what I typically do)

Code: Select all

git branch -m scripting-supply-ships old_supply-ships
git checkout master
git checkout -b scripting-suppy-ships
git cherry-pick 2a63ea2  8195371 8b7f24a ec726d2
git push ---force --set-upstream origin scripting-supply-ships
Splitting out the population center change
cherry-pick should do fine, the new branch should base off of master.
...where industry is below zero...
The meter clamp for industry on resource centers is a minimum of 0.0f.
I'd say it is a safe assumption that industry will not be negative, without tracking it down further.
...not decided on what kind of planets...
To help decide, you might count the existing playable species by planet type (and maybe even weight each species by how often you play them).
Edit: Rough pass on existing species

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

Re: Help needed with scripting supply ships

#17 Post by Ophiuchus »

dbenage-cx wrote:
I rebased the code.
Something went wrong,
So I think I cleaned up the mess:
diff scripting-supply-ships
diff industrious-outposts
dbenage-cx wrote:
...where industry is below zero...
The meter clamp for industry on resource centers is a minimum of 0.0f.
I'd say it is a safe assumption that industry will not be negative, without tracking it down further.
Removed the min and max
dbenage-cx wrote:
...not decided on what kind of planets...
To help decide, you might count the existing playable species by planet type (and maybe even weight each species by how often you play them).
Edit: Rough pass on existing species
Wow, thats a great document. I shifted to radiated planets as it is a nice niche and it fits the theme of the species as well to hide on undisputed planets (at least as long as there are no exobots).

What is the next step? To send pull requests so others can test?
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!

dbenage-cx
Programmer
Posts: 389
Joined: Sun Feb 14, 2016 12:08 am

Re: Help needed with scripting supply ships

#18 Post by dbenage-cx »

What is the next step? To send pull requests so others can test?
Supply ships probably needs some discussion on if it should be included.
Could you provide a proposal (e.g. "how and why the idea improves the game") to help fuel feedback?
The existing implementation will help clarify what is being proposed.

I would go ahead with a PR for industrious-outposts, as no issues have been raised about it so far.

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

Re: Help needed with scripting supply ships

#19 Post by Geoff the Medio »

dbenage-cx wrote:...for industrious-outposts, as no issues have been raised about it so far.
Except for the reasons, as far as I can recall, why thing were implemented so that outposts had clamped 0 industry output.

I believe it was so that a planet that is depopulated doesn't continue producing industry (or other resources) for several / many turns after losing its population, as the current meter change mechanics have a relatively slow decay (and growth) rate, so that even if the target is 0 due to having no population, it would still take a long time to decay to 0 if it started out relatively high.

After a brief search, I also found this argument:
http://www.freeorion.org/forum/viewtopi ... 523#p49523
which was that it was partly to avoid the micromanagement of having to put outposts everywhere to get the resulting resource output from them.

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

Re: Help needed with scripting supply ships

#20 Post by Ophiuchus »

I wrote in game design to start discussion about the supply ship feature:
http://www.freeorion.org/forum/viewtopi ... =6&t=10308
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!

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

Re: Help needed with scripting supply ships

#21 Post by Ophiuchus »

Hi Geoff,
Geoff the Medio wrote:
dbenage-cx wrote:...for industrious-outposts, as no issues have been raised about it so far.
Except for the reasons, as far as I can recall, why thing were implemented so that outposts had clamped 0 industry output.

I believe it was so that a planet that is depopulated doesn't continue producing industry (or other resources) for several / many turns after losing its population, as the current meter change mechanics have a relatively slow decay (and growth) rate, so that even if the target is 0 due to having no population, it would still take a long time to decay to 0 if it started out relatively high.
Depopulation still works (I'm pretty sure I tested it), so when a planet gets depopulated all the meters are set zero.
Geoff the Medio wrote:After a brief search, I also found this argument:
http://www.freeorion.org/forum/viewtopi ... 523#p49523
which was that it was partly to avoid the micromanagement of having to put outposts everywhere to get the resulting resource output from them.
I didn't see that happening (production on gas giants etc), but I will test for that in my next game.
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!

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

Re: Help needed with scripting supply ships

#22 Post by Ophiuchus »

Hi,

I checked again:

Depopulation works, so when a planet gets depopulated all the meters are set zero.
Geoff the Medio wrote:After a brief search, I also found this argument:
http://www.freeorion.org/forum/viewtopi ... 523#p49523
which was that it was partly to avoid the micromanagement of having to put outposts everywhere to get the resulting resource output from them.
Unluckily outposts are affected by e.g. Nascent Artificial Intelligence and Adaptive Automation...
That is definitely not intended. I would like to refactor the freeorion code to change that. Should I close the pull request and start discussing ideas for implementation in this or a new thread?
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!

dbenage-cx
Programmer
Posts: 389
Joined: Sun Feb 14, 2016 12:08 am

Re: Help needed with scripting supply ships

#23 Post by dbenage-cx »

Would clamping the meters to the current target value during `Planet::Depopulate()`, instead of resetting, work for both cases?
e.g.

Code: Select all

GetMeter(METER_INDUSTRY)->ClampCurrentToRange(Meter::DEFAULT_VALUE, GetMeter(METER_TARGET_INDUSTRY)->Current());
I would keep the PR open if you still intend to work on it.
The c++ discussion probably belongs in programming, unless this becomes a huge discussion (or I get smacked on the back of the head again), I would continue here for now.
Any content posted should be considered licensed GNU GPL 2.0 and/or CC-BY-SA 3.0 as appropriate.

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

Re: Help needed with scripting supply ships

#24 Post by Ophiuchus »

dbenage-cx wrote:Would clamping the meters to the current target value during `Planet::Depopulate()`, instead of resetting, work for both cases?
e.g.

Code: Select all

GetMeter(METER_INDUSTRY)->ClampCurrentToRange(Meter::DEFAULT_VALUE, GetMeter(METER_TARGET_INDUSTRY)->Current());
I am not sure how that would help.
dbenage-cx wrote:I would keep the PR open if you still intend to work on it.
The c++ discussion probably belongs in programming, unless this becomes a huge discussion (or I get smacked on the back of the head again), I would continue here for now.
By mistake i closed the pull request #1080 (i did some coding and rebasing and couldnt push to the branch, so i deleted and repushed my code with the same name).

I went forward and tried cleaning up the scripts to be more specific whether population is needed in conditions or not. I also tried to unify the usage by using a macro as I found at least six different ways people coded this kind of condition.
I made commits in the branch to group different kind of issues. I guess the branch is in a state that can start the discussion. I will for example have to revisit the ProductionCenter vs PopulationCenter question.

industrious-outposts commits
industrious-outposts diff
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
Vezzra
Release Manager, Design
Posts: 6095
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Help needed with scripting supply ships

#25 Post by Vezzra »

Just want to sneak in a thought I had - I wonder if you're making things more complicated than they need to be.

Let me make sure I understand the problem correctly: What you want to achieve is that your supply ship mechanic works with outposts, right? And the problem is, that zero pop, species-less colonies (aka outposts) are hardcoded to reset their resource meters (industry, research) to 0, so your supply ship scripts don't work with outposts.

The obvious solution, to remove these hardcoded limit, doesn't work either, because then suddenly flat, pop-independent boni like Nascent Artificial Intelligence and Adaptive Automation are applied to outposts, which is definitely not what we want.

But wouldn't the most simple way to address the latter problem by just adding a condition to these flat-boni tech effects which ensures only colonies with a pop>0 get them? Then you can just remove the hardcoded limit, extend the activation condition of all the boni we don't want to be applied to outposts accordingly, and we're set.

Or am I missing something obvious here?

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

Re: Help needed with scripting supply ships

#26 Post by Geoff the Medio »

Vezzra wrote:...zero pop, species-less colonies (aka outposts) are hardcoded to reset their resource meters (industry, research) to 0...
[...]...adding a condition to these flat-boni tech effects which ensures only colonies with a pop>0 get them? Then you can just remove the hardcoded limit...
The point of the resetting the resource meters is that when planets change from having population to not, they shouldn't still have lingering resource output for many turns as it slowly decays to the new target of 0. Just ensuring that the target is 0 by adjusting scope conditions won't prevent this.

I suggest looking into using ships as resource centers. These won't have planet-like target/current meter mechanics to worry about, and should be a lot easier to get to generate the desired resource output than would attempting to manipulate target / current planet resource meters.

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

Re: Help needed with scripting supply ships

#27 Post by Ophiuchus »

Vezzra wrote:Let me make sure I understand the problem correctly: What you want to achieve is that your supply ship mechanic works with outposts, right? And the problem is, that zero pop, species-less colonies (aka outposts) are hardcoded to reset their resource meters (industry, research) to 0, so your supply ship scripts don't work with outposts.
Exactly
Vezzra wrote:The obvious solution, to remove these hardcoded limit, doesn't work either, because then suddenly flat, pop-independent boni like Nascent Artificial Intelligence and Adaptive Automation are applied to outposts, which is definitely not what we want.

But wouldn't the most simple way to address the latter problem by just adding a condition to these flat-boni tech effects which ensures only colonies with a pop>0 get them? Then you can just remove the hardcoded limit, extend the activation condition of all the boni we don't want to be applied to outposts accordingly, and we're set.

Or am I missing something obvious here?
Nope, that is basically what the branch tries to achieve.

Maybe I should not do the cleanup stuff, I don't know.
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!

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

Re: Help needed with scripting supply ships

#28 Post by Ophiuchus »

Geoff the Medio wrote:
Vezzra wrote:...zero pop, species-less colonies (aka outposts) are hardcoded to reset their resource meters (industry, research) to 0...
[...]...adding a condition to these flat-boni tech effects which ensures only colonies with a pop>0 get them? Then you can just remove the hardcoded limit...
The point of the resetting the resource meters is that when planets change from having population to not, they shouldn't still have lingering resource output for many turns as it slowly decays to the new target of 0. Just ensuring that the target is 0 by adjusting scope conditions won't prevent this.
No, lingering resource output has no essential connections with outposts. The depopulation method takes care of lingering resource output.
If you call it only for populated population centers, it works fine. But the scripts for some techs don't care if the population center is populated or not. I made an implementation in the mentioned industrious-outposts branch. Deciding for a tech etc if it should work only on populated places probably is good thing regardless of supply ships.
Geoff the Medio wrote:I suggest looking into using ships as resource centers. These won't have planet-like target/current meter mechanics to worry about, and should be a lot easier to get to generate the desired resource output than would attempting to manipulate target / current planet resource meters.
I will follow your suggestion out of curiosity, but I do not understand your concern about the meters.
The target/current meter mechanics work just fine the way they are coded.

Anyway will have a look at ships as resource centers, though I do not yet see how this will help with hidden disconnected empires and exploration.
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
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: Help needed with scripting supply ships

#29 Post by MatGB »

Vezzra wrote: But wouldn't the most simple way to address the latter problem by just adding a condition to these flat-boni tech effects which ensures only colonies with a pop>0 get them? Then you can just remove the hardcoded limit, extend the activation condition of all the boni we don't want to be applied to outposts accordingly, and we're set.
This is actually something we might need to do anyway—if/when we rework the growth/adaptation/terraform techs I want to be able to populate worlds with low population, probably max 1, then terraform upwards, but if you're getting the bonus from adaptive and nascent immediately then that could be a little overpowered.

Of course, it's fairly apparent that both nascent and adaptive are a little overpowered anyway, so gating them to give a max of the planet population or 2/5 might work and then remove this propblem as well (could gate adaptive to be twice population if we wanted).

That or give them Infrastructure based bonuses instead but that's a whole other discussion ;-)

(I haven't contributed much to this discussion, but I'm very much with Geoff on the micromanagement concerns here: if it's an advantage to send a supply ship with an outpost then it's a disadvantage to not do so, which is close to the definition of micromanagement: I can see the appeal for some players to want this sort of feature, different people want to play the game in different ways, but I'm not sold this is a balanced non-micro addition)
Mat Bowles

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

defaultuser
Juggernaut
Posts: 854
Joined: Wed Aug 26, 2015 6:15 pm

Re: Help needed with scripting supply ships

#30 Post by defaultuser »

MatGB wrote:Of course, it's fairly apparent that both nascent and adaptive are a little overpowered anyway, so gating them to give a max of the planet population or 2/5 might work and then remove this propblem as well (could gate adaptive to be twice population if we wanted).
That would, of course, be a significant change to game-play.

Post Reply