Implementing stockpile "project" build item

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

Moderator: Committer

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

Implementing stockpile "project" build item

#1 Post by Ophiuchus »

Hi i try to find out the feasibilty for adding PP to the stockpile via an item in the build queue.

This could be probably be simulated by building self-destructing ships (adding 1PP to the stockpile each), but that would really suck (lots of unnecessary artifacts: the ships (probably would need also need special ship hulls not influenced by upkeep costs and should not partake in combat at all), the sitreps, one extra turn delay; and also would be incompatible with stockpile input limits). Creating hidden ships not being part of your own empire would solve some of those artifacts i guess...

So there was the idea that there could project build items in the queue for which you can specify an amount and a number of turns/repetitions (similar to building the ships),

Design discussion is happening currently here: Feedback Imperial Stockpile (Rev 4,5). Unlimited input Rulez

First talk about such a feature Refining the imperial stockpile

So there are many issues at hand, which i dont know how to start about
  • adding a new type besides buildings and ship for the build queue.
  • instead of creating a finished project, transfer the PP amount into the stockpile when processing (and predicting) production queue
  • UI - somehow reuse the ship UI
  • adding the project to the build options, so you can drag'n'drop into the queue
  • FOCS/parser support(?)
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
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Implementing stockpile "project" build item

#2 Post by Dilvish »

I share the desire to have more fine-tuning available for how much PP gets sent into the stockpile. If I am playing sly, I don't like the situations where I have to pause all my homeplanet construction (like if I am only building something big like a colony ship) and send 20PP/turn into the stockpile when all I really needed/wanted was to send 9PP/turn. The challenge is to do it in a way that is not too much clutter.

A new build type, which would actually just be a single thing-- a 1PP stockpile transfer (could be stacked in blocks for larger amount, and set to repeat for however many turns) seems OK to me. I wouldn't require that the project have to "complete" before the PP is sent-- the Production queue would every turn the project was active hold back from construction PP up to that amount (less if less than that amount was available at this project's point in the queue) and transfer to the stockpile however much was held back.
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
Oberlus
Cosmic Dragon
Posts: 5704
Joined: Mon Apr 10, 2017 4:25 pm

Re: Implementing stockpile "project" build item

#3 Post by Oberlus »

I like Dilvish idea.

If the PPs of uncompleted stockpiling batches are hold until it is finished it has less utility.

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

Re: Implementing stockpile "project" build item

#4 Post by Ophiuchus »

Oberlus wrote:I like Dilvish idea.

If the PPs of uncompleted stockpiling batches are hold until it is finished it has less utility.
Excellent that means regarding Question-A: What does it mean to specify higher amount of PP-into-stockpile-project than is supply-locally available?

The amount means: transfer up to this amount PP per turn.
The number of repetition means: do this transfer for the specified number of turns

That means an amount of 10 with repetition 3 does not necessarily transfer 30PP into the stockpile.
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
Oberlus
Cosmic Dragon
Posts: 5704
Joined: Mon Apr 10, 2017 4:25 pm

Re: Implementing stockpile "project" build item

#5 Post by Oberlus »

Yeah. We'll make the project go further, changing remaining turns, if we need more PPs.

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

Re: Implementing stockpile "project" build item

#6 Post by Dilvish »

Ophiuchus wrote:
Oberlus wrote:The amount means: transfer up to this amount PP per turn.
The number of repetition means: do this transfer for the specified number of turns

That means an amount of 10 with repetition 3 does not necessarily transfer 30PP into the stockpile.
I think it will be much simpler to implement and understand if the repetition works the same as it does with other items, i.e., amount 10 with repetition 3 does indeed mean that 30 PP total will be transferred to the Stockpile, it just might take longer than 3 turns. This stockpile build item would still track its progress the same way any build item does, it's simply that the code that determines the stockpile change from one turn to the next will scan the queue for build items of this nature, and the amount of their allocation (the amount put into them this turn) would be added to the stockpile.
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
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Implementing stockpile "project" build item

#7 Post by Dilvish »

I think that the bulk of work involved in implementing this idea would simply stem from updating all the various places where the code says "if this item is a BT_BUILDING then do X, else if it is a BT_SHIP do Y, else log an error or throw an exception.

If there are no objections, let's call the new item type BT_STOCKPILE.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

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

Re: Implementing stockpile "project" build item

#8 Post by Ophiuchus »

Dilvish wrote:
Ophiuchus wrote:
Oberlus wrote:The amount means: transfer up to this amount PP per turn.
The number of repetition means: do this transfer for the specified number of turns

That means an amount of 10 with repetition 3 does not necessarily transfer 30PP into the stockpile.
I think it will be much simpler to implement and understand if the repetition works the same as it does with other items, i.e., amount 10 with repetition 3 does indeed mean that 30 PP total will be transferred to the Stockpile, it just might take longer than 3 turns. This stockpile build item would still track its progress the same way any build item does, it's simply that the code that determines the stockpile change from one turn to the next will scan the queue for build items of this nature, and the amount of their allocation (the amount put into them this turn) would be added to the stockpile.
So in this case say you have locally 5 PP industry and 10PP max-industry. If you add at the top a 10PP and 3 repetitions PP-into-stockpile-project this means:
turn 1: 5PP is added to the project, i.e. the first repetition is halfway finished. 5PP get added to the stockpile
turn 2: 6PP is added to the project, i.e. the first repetition is finished, the second repetition gets 1PP. 6PP get added to the stockpile
turn 3: 7PP is added to the project, i.e. the second repetition has 8PP. 7PP get added to the stockpile
turn 4: 8PP is added to the project, i.e. the second repetition is finished, third repetition has 6PP. 8PP get added to the stockpile
turn 5: 9PP is added to the project, i.e. the last repetition is finished. 4PP get added to the stockpile. 5PP go to the next lower project in the same supply group.

Dilvish wrote:If there are no objections, let's call the new item type BT_STOCKPILE.
BT_STOCKPILE sounds great, probably easier to do than a general BT_PROJECT
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: 13586
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Implementing stockpile "project" build item

#9 Post by Geoff the Medio »

Are these stockpile projects going to be located somewhere in particular, so that they only take PP from a particular resource group? If not, how is PP allocated to them from any resource group while taking into account their position on a queue that contains only other items that are location restricted?

User avatar
Oberlus
Cosmic Dragon
Posts: 5704
Joined: Mon Apr 10, 2017 4:25 pm

Re: Implementing stockpile "project" build item

#10 Post by Oberlus »

Geoff the Medio wrote:Are these stockpile projects going to be located somewhere in particular, so that they only take PP from a particular resource group? If not, how is PP allocated to them from any resource group while taking into account their position on a queue that contains only other items that are location restricted?
Yes, they will be supply-group located.
Extra details from this message onwards.

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

Re: Implementing stockpile "project" build item

#11 Post by Dilvish »

To be a bit more specific than Oberlus, the build item would be located at a particular planet just like any other build item (no need to go trying to change things like that). And yes we'd let it draw from the full local supply group, with the current stockpile rules there is no reason not to let it draw like that, it is just more streamlined, and K.I.S.S. If there are, or come to be, game rules which would be in conflict with that (like local limits on stockpile contributions) then this stockpile item should be disabled (could try to have its location condition reference all such other GameRules, but it would be much simpler to just have a specific GameRule either enabling or disabling the buildability of stockpile projects).
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
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Implementing stockpile "project" build item

#12 Post by Dilvish »

As a further design planning detail, I'd have the stockpile item listed at top of the BuildWnd, not affected by the ships/buildings display buttons but affected by the available/unavailable display buttons.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

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

Re: Implementing stockpile "project" build item

#13 Post by Ophiuchus »

Dilvish wrote:As a further design planning detail, I'd have the stockpile item listed at top of the BuildWnd, not affected by the ships/buildings display buttons but affected by the available/unavailable display buttons.
I also think it doesnt make sense to add a third category there for a single nonstandard build type. Id be fine to consider it as ship and building as far as the BuildWnd is concerned.

The stockpile project would be part of the "available" category. Is there currently a reason why it could be unavailable?

I guess that some players might like to hide this stockpile project. For that i suggest in future to make the project obsoletable as soon as that category is available in the BuildWnd.
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
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Implementing stockpile "project" build item

#14 Post by Dilvish »

Ophiuchus wrote:The stockpile project would be part of the "available" category. Is there currently a reason why it could be unavailable?

I guess that some players might like to hide this stockpile project. For that i suggest in future to make the project obsoletable as soon as that category is available in the BuildWnd.
Since it is only a single item I don't think that anyone needs to be able to obsolete it, or even should be able to, really. It would be fine with me if it were just always visible regardless of any of the ship/building/available/unavailable buttons, but it seemed simplest and most logical to just consider it always 'available' and lets its display be subject to the state of the 'available' and 'unavailable' buttons.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

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

Re: Implementing stockpile "project" build item

#15 Post by dbenage-cx »

From what I've followed so far, there are two different options proposed for this new item type.

One option is to have the item define a goal amount to send to stockpile, where the new progress each turn is transferred and the item removed once the goal is reached.
e.g. "Stockpile 50 PP" (Though this will probably first be implemented as 50 * Transfer to Stockpile)
This would need some way to distinguish that the previous progress was already spent/transferred.
The batch controls (e.g. ships) could be used for this option.

Another is for the item to complete each turn (when not paused and has some progress) with the value altered to the amount of progress.
e.g. "Stockpile up to 5 PP/turn" (Again, likely 5 * Transfer to Stockpile)
These should either default to or have an option for infinite repetition.
Would help if the height on queue can be reduced to a bare minimum and/or have controls to filter the queue (with a separate option for projects here).

These may not be mutually exclusive options, but the later would be my first choice.
Any content posted should be considered licensed GNU GPL 2.0 and/or CC-BY-SA 3.0 as appropriate.

Post Reply