Weapon update timing (turn processing order)

Describe your experience with the latest version of FreeOrion to help us improve it.

Moderator: Oberlus

Forum rules
Always mention the exact version of FreeOrion you are testing.

When reporting an issue regarding the AI, if possible provide the relevant AI log file and a save game file that demonstrates the issue.
Message
Author
User avatar
alleryn
Space Dragon
Posts: 259
Joined: Sun Nov 19, 2017 6:32 pm

Weapon update timing (turn processing order)

#1 Post by alleryn »

Loosely related github issue: https://github.com/freeorion/freeorion/issues/2572 (This issue deals more specifically with displayed values of enemy ships in multiplayer games).

Due to, i believe, the order of events being processed, it can feel like a very long time between researching a weapon upgrade and seeing the effects of that upgrade applied.

For example, in the attached save below, the following events occur:
  • On Turn 12, Mass Driver 2 is researched. A fleet sits in supply awaiting the upgrade, so that it is prepared to engage a sentry, which sits guarding a system one jump (but two turns) away. If the fleet departs on Turn 12, it will not upgrade before the battle with the sentry.
  • Now my understanding of the mechanics (some of which i believe have changed recently) is somewhat hazy, but, i believe on Turn 13, the effects of Mass Driver 2 are "active". The display at this point still shows that ships have MD1, but if the fleet departs on Turn 13, the upgrade to MD2 will occur "midflight" in time for the battle.
  • If we leave the fleet where it is, on Turn 14, the fleet actually upgrades to MD2 fully (the display has updated to reflect that the ships have the MD2 weapon value of 4).
None of this is too terrible, but i feel like it could be tightened up, so that it's easier for the player to "feel" when the ships are "really" upgraded and ready to go. In the current state, without a good understanding of the mechanics, or save/reload, it is difficult to determine on which turn the upgrade actually occurs in order to deliver appropriate tactical directives.
Attachments
FreeOrion_alleryn_alleryn_0012_20191002_005633.zip
(268.77 KiB) Downloaded 100 times

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

Re: Weapon update timing (turn processing order)

#2 Post by Ophiuchus »

Not Sure what your suggestion is. We could send a sitrep on the turn the upgrades start to happen.

So without looking.
Turn 13 tech researched message

Turn 14 weapon upgrade message. E.g. all your mass drivers in supply get upgraded to damage 5 this turn

Turn 15 combats already have the new damage level
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
alleryn
Space Dragon
Posts: 259
Joined: Sun Nov 19, 2017 6:32 pm

Re: Weapon update timing (turn processing order)

#3 Post by alleryn »

Ophiuchus wrote: Wed Oct 02, 2019 7:15 am Not Sure what your suggestion is.
I don't have a specific suggestion yet. I feel like there are a lot of issues related to this (e.g. https://github.com/freeorion/freeorion/issues/1927), so i thought it could start a larger discussion if it's a topic that interests anyone.

It's not a huge deal, it just feels pretty unintuitive that the best turn to send your ships is the turn between when you research the tech and when the display changes to reflect the upgrade.

The sitrep could work, though it's a little confusing because, as i understand it, the upgrade happens between turns. A sitrep the turn before the upgrade happens (at the start of the turn after the tech is researched) would probably be more useful (but probably difficult to implement?).

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

Re: Weapon update timing (turn processing order)

#4 Post by Ophiuchus »

alleryn wrote: Wed Oct 02, 2019 5:00 pm It's not a huge deal, it just feels pretty unintuitive that the best turn to send your ships is the turn between when you research the tech and when the display changes to reflect the upgrade.
There is way complicated implementation which would predict meter changes not only for max and target meters but also for normal meters like the weapons and show that accordingly. But i think this overkill and has lot of subtleties.
alleryn wrote: Wed Oct 02, 2019 5:00 pm The sitrep could work, though it's a little confusing because, as i understand it, the upgrade happens between turns. A sitrep the turn before the upgrade happens (at the start of the turn after the tech is researched) would probably be more useful (but probably difficult to implement?).
The upgrade happens by a meter effect which is invoked twice, once basically after combat and once after e.g. researching tech, building ships, .... This helps initialise ship values on the turn it is built.

With the recent changes, newly researched tech does not influence the second invocation anymore. Also TurnTechResearched changed IMHO.

So if you research your MD2 technology on turn 10 (so it is shown as a turn 10 sitrep), it is possible to show a custom sitrep on turn 11. Currently the upgrade first happens on turn 12. So we should definitly add the sitrep (or shift the upgrade to turn 11).
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
alleryn
Space Dragon
Posts: 259
Joined: Sun Nov 19, 2017 6:32 pm

Re: Weapon update timing (turn processing order)

#5 Post by alleryn »

Ophiuchus wrote: Sun Oct 06, 2019 11:11 am So if you research your MD2 technology on turn 10 (so it is shown as a turn 10 sitrep), it is possible to show a custom sitrep on turn 11. Currently the upgrade first happens on turn 12. So we should definitly add the sitrep (or shift the upgrade to turn 11).
This makes sense to me.

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

Re: Weapon update timing (turn processing order)

#6 Post by Ophiuchus »

So I had a look at it. And actually it is not as bad.
As i wrote, effect application happens after combat; in effect the values shown for the weapons are always the ones which will be used in the next combat.

Anyway I think it would be good to write an informational message on the (first) turn the upgrade happens as a help to new players and to reduce confusion.

And we should shift the upgrade a turn back to the turn after research.
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
alleryn
Space Dragon
Posts: 259
Joined: Sun Nov 19, 2017 6:32 pm

Re: Weapon update timing (turn processing order)

#7 Post by alleryn »

Ophiuchus wrote: Thu Oct 10, 2019 8:09 am So I had a look at it. And actually it is not as bad.
As i wrote, effect application happens after combat; in effect the values shown for the weapons are always the ones which will be used in the next combat.

Anyway I think it would be good to write an informational message on the (first) turn the upgrade happens as a help to new players and to reduce confusion.

And we should shift the upgrade a turn back to the turn after research.
The main thing for me would be having a sitrep appear on the turn before the upgrade happens. E.g. if the upgrade happens between turns 100 and 101, then a sitrep would be issued on turn 100. (Currently this is the case if the tech is researched on turn 99).

I'm not sure how to word it. Maybe something like "Your <Mass Drivers> will upgrade to <Mass Driver 3> between this turn and next turn." ?

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

Re: Weapon update timing (turn processing order)

#8 Post by Ophiuchus »

alleryn wrote: Thu Oct 10, 2019 9:30 am"Your <Mass Drivers> will upgrade to <Mass Driver 3> between this turn and next turn." ?
I think you are still confused (or I do not understand you). In my understanding this "between turns" does not matter for weapon upgrades.

Without the PR I put up:
  • Client Turn 99: Message: Tech MD4 was researched
  • Client Turn 100: nothing happens; combats in combat reports used MD3 tech
  • Client Turn 101: mass drivers are shown with MD4 damage ; combats in combat reports used MD3 tech
  • Client Turn 102: combats from in combat reports used MD4 tech
with PR
  • Client Turn 99: Message: Tech MD4 was researched
  • Client Turn 100: combats in combat reports used MD3 tech; mass drivers are shown with MD4 damage; Message: Your mass drivers on supplied ships were updated to MD4. This means 1 extra damage per shot.
  • Client Turn 101: ; combats in combat reports used MD4 tech
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
alleryn
Space Dragon
Posts: 259
Joined: Sun Nov 19, 2017 6:32 pm

Re: Weapon update timing (turn processing order)

#9 Post by alleryn »

Maybe i'm missing something, but here's why i think it matters. Consider my example from the first post:

Turn 12: MD2 researched
Turn 13: Fleet departs (display still reads MD1)
Between 13 and 14: Fleet's weapons are upgraded, fleet moves, leaving supply

If "between turns" didn't matter then either the ships weapons would have upgraded on turn 13 (they didn't) or on turn 14 (when the ships are out of supply). Clearly neither is true.

This is, of course, for the pre-PR case. I have not had the chance to examine the PR in detail or to test post-PR.

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

Re: Weapon update timing (turn processing order)

#10 Post by Ophiuchus »

alleryn wrote: Thu Oct 10, 2019 10:42 pm Maybe i'm missing something, but here's why i think it matters. Consider my example from the first post:

Turn 12: MD2 researched
Turn 13: Fleet departs (display still reads MD1)
Between 13 and 14: Fleet's weapons are upgraded, fleet moves, leaving supply

If "between turns" didn't matter then either the ships weapons would have upgraded on turn 13 (they didn't) or on turn 14 (when the ships are out of supply). Clearly neither is true.

This is, of course, for the pre-PR case. I have not had the chance to examine the PR in detail or to test post-PR.
I still do not get the "between turns" part - I think that term could many things and it does not help clarify anything. If you move out of supply on turn 13 and the upgrade happens afterwards, they will simply not be upgraded.

I think the mismatch comes from the client concept of turn (you press next turn and then you get a new result) and the technical concept of turn (the moment turn increase happens).


With the PR the upgrade would happen on turn 13 if they are in supply. So if you send them out of supply on turn 12, they will not be upgraded on turn 13.

The relevant part of order is: player finishes turn 12, fleets move, combat happens, weapon upgrades happen, turn is increased to 13, player make turn 13
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
alleryn
Space Dragon
Posts: 259
Joined: Sun Nov 19, 2017 6:32 pm

Re: Weapon update timing (turn processing order)

#11 Post by alleryn »

Ophiuchus wrote: Fri Oct 11, 2019 9:26 am
If you move out of supply on turn 13 and the upgrade happens afterwards, they will simply not be upgraded.
Isn't that exactly what happens in my example, though? Or am i not understanding you?
I think the mismatch comes from the client concept of turn (you press next turn and then you get a new result) and the technical concept of turn (the moment turn increase happens).
Well a lot of the processing happens between turns (by which i mean after a player has pressed the 'Next Turn' button and before issues can be ordered for the subsequent turn)....among other things, all of HandleColonisation, HandleInvasion, etc... fleet movement, and, the way i understand it, weapon upgrades.
With the PR the upgrade would happen on turn 13 if they are in supply. So if you send them out of supply on turn 12, they will not be upgraded on turn 13.

The relevant part of order is: player finishes turn 12, fleets move, combat happens, weapon upgrades happen, turn is increased to 13, player make turn 13
I still haven't gotten the opportunity to test this, but it's on my todo list.

User avatar
em3
Vacuum Dragon
Posts: 630
Joined: Sun Sep 25, 2011 2:51 pm

Re: Weapon update timing (turn processing order)

#12 Post by em3 »

alleryn wrote: Fri Oct 11, 2019 10:06 am
Ophiuchus wrote: Fri Oct 11, 2019 9:26 am I think the mismatch comes from the client concept of turn (you press next turn and then you get a new result) and the technical concept of turn (the moment turn increase happens).
Well a lot of the processing happens between turns (by which i mean after a player has pressed the 'Next Turn' button and before issues can be ordered for the subsequent turn)....among other things, all of HandleColonisation, HandleInvasion, etc... fleet movement, and, the way i understand it, weapon upgrades.
That's the mismatch, you see. There are two interpretations of "turn":
  • When the players make decisions and choose orders for their empire
  • When stuff happens and orders are executed
So "between turns" is either all the updates and combat etc... or "between turns" is when you place your order for the upcoming turn.
https://github.com/mmoderau
[...] for Man has earned his right to hold this planet against all comers, by virtue of occasionally producing someone totally batshit insane. - Randall Munroe, title text to xkcd #556

User avatar
em3
Vacuum Dragon
Posts: 630
Joined: Sun Sep 25, 2011 2:51 pm

Re: Weapon update timing (turn processing order)

#13 Post by em3 »

Consider a board game analogy - you don't discard cards down to your hand's size between turns, but at the end of your turn.
https://github.com/mmoderau
[...] for Man has earned his right to hold this planet against all comers, by virtue of occasionally producing someone totally batshit insane. - Randall Munroe, title text to xkcd #556

User avatar
alleryn
Space Dragon
Posts: 259
Joined: Sun Nov 19, 2017 6:32 pm

Re: Weapon update timing (turn processing order)

#14 Post by alleryn »

em3 wrote: Sat Oct 12, 2019 7:18 am That's the mismatch, you see. There are two interpretations of "turn":
Ophiuchus wrote: Fri Oct 11, 2019 9:26 am I think the mismatch comes from the client concept of turn (you press next turn and then you get a new result) and the technical concept of turn (the moment turn increase happens).
I think it's reasonable that sitreps are geared toward the client-side interpretation of "turn". Sitreps are meant for players not for coders.
Ophiuchus wrote: Fri Oct 11, 2019 9:26 am With the PR the upgrade would happen on turn 13 if they are in supply. So if you send them out of supply on turn 12, they will not be upgraded on turn 13. [emphasis added]

The relevant part of order is: player finishes turn 12, fleets move, combat happens, weapon upgrades happen, turn is increased to 13, player make turn 13
I updated, loaded the save file i provided in this thread, tested, and your statement is incorrect.
If you issue them move orders on turn 12 which send them out of supply, at the beginning of turn 13 the weapons have been upgraded.

User avatar
alleryn
Space Dragon
Posts: 259
Joined: Sun Nov 19, 2017 6:32 pm

Re: Weapon update timing (turn processing order)

#15 Post by alleryn »

em3 wrote: Sat Oct 12, 2019 7:32 am Consider a board game analogy - you don't discard cards down to your hand's size between turns, but at the end of your turn.
I suppose this depends on the board game, and ultimately just upon semantics.

In my mind, it just makes more sense to break things down as
  1. Input is occuring while the turn is going on.
  2. All input is finished. Now the turn is over.
  3. "Between turn" processing occurs, but there is no input from the players.
  4. Processing finishes, ready for new input. New turn begins.
You can consider step 3 the "end of the turn" instead of "between turns", but i think it's helpful to differentiate when there is possible input and when there in not. My terminology succeeds in including this differentiation.

In contrast the "end of the turn" terminology is vague. You could be talking about the no-input part of the turn, or something occurring towards the tail-end of a turn but still during the possible-input phase. This is fine in a simple game like, say, gin rummy, where you are taking one single action (discarding a card) at the very end of every turn (literally at the end of the turn -- the very last action), but is more problematic (in my opinion) when you are describing a longer phase where multiple processes may be occurring.

Post Reply