Problem: the focus change penalty is being exacted from just checking out a focus change (the only way to find out what the new targets would be) even if the planet is returned to its original focus prior to the end of turn.
This is observable if [edit] this first case was apparently a faulty memory of mine-- either (i) the meter corresponding to the continuing focus is not at max-- after a temporary focus change and immediate reversion the corresponding meter prediction will predict it to stay flat for a turn rather than increase towards max, and indeed that happens, or (ii) [/edit] an off-focus-meter is 2 ore more above minimum, in which case it will lose 2 points after a temporary focus change and reversion instead of 1.
Off the top of my head it is seeming that a solution would require that a ResourceCenter should also have a 'm_previous_turn_focus' attribute and a 'm_previous_last_turn_focus_changed attribute that get updated by a special function call at the beginning of each turn, and that SetFocus() sets m_last_turn_focus_changed equal to m_previous_last_turn_focus_changed if the new focus is the same as the m_previous_turn_focus, and only otherwise sets it to CurrentTurn() (which it always does now).
problem with focus change penalty
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.
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.
problem with focus change penalty
Last edited by Dilvish on Sat Apr 05, 2014 6:02 pm, edited 1 time in total.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13603
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: problem with focus change penalty
There are probably potential alternatives, but keeping track of the initial focus is probably easier and more reliable.
Re: problem with focus change penalty
here is a patch to fix this problem -- how's it look to you?
- Attachments
-
[The extension patch has been deactivated and can no longer be displayed.]
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13603
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: problem with focus change penalty
A bit unclear with variable naming. The meaning of "memory" in "m_focus_memory" is vague... I initially thought it would contain a historical record of focus settings. I suggest m_turn_initial_focus or m_focus_turn_initial, or somesuch... Similarly, m_last_turn_focus_memory_changed could be renamed... m_last_turn_focus_changed_turn_initial perhaps? Not a very simple concept to describe briefly, unfortunately...Dilvish wrote:here is a patch to fix this problem -- how's it look to you?
Re: problem with focus change penalty
How about m_turn_end_focus (or just m_end_focus) and m_last_turn_end_focus_changed? If you don't like those then I guess I'd prefer to maximize parallelism to the existing terms and go with your proposals m_focus_turn_initial and m_last_turn_focus_changed_turn_initial (just adding "_turn_initial" to the existing attribute names).Geoff the Medio wrote:I suggest m_turn_initial_focus or m_focus_turn_initial, or somesuch... Similarly, m_last_turn_focus_memory_changed could be renamed... m_last_turn_focus_changed_turn_initial perhaps? Not a very simple concept to describe briefly, unfortunately...
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13603
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: problem with focus change penalty
Maybe m_previous_turn_focus? "turn end" doesn't really mean much to me... But I think "turn initial" is more accurate than "previous turn".Dilvish wrote:How about m_turn_end_focus (or just m_end_focus) and m_last_turn_end_focus_changed?
Re: problem with focus change penalty
ok, I went with your proposals m_focus_turn_initial and m_last_turn_focus_changed_turn_initial. Committed.Geoff the Medio wrote:... But I think "turn initial" is more accurate than "previous turn".
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0