problem with focus change penalty

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.
Post Reply
Message
Author
User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

problem with focus change penalty

#1 Post by Dilvish »

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).
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

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

Re: problem with focus change penalty

#2 Post by Geoff the Medio »

There are probably potential alternatives, but keeping track of the initial focus is probably easier and more reliable.

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

Re: problem with focus change penalty

#3 Post by Dilvish »

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

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

Re: problem with focus change penalty

#4 Post by Geoff the Medio »

Dilvish wrote:here is a patch to fix this problem -- how's it look to you?
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...

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

Re: problem with focus change penalty

#5 Post by Dilvish »

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...
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).
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
Geoff the Medio
Programming, Design, Admin
Posts: 13603
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: problem with focus change penalty

#6 Post by Geoff the Medio »

Dilvish wrote:How about m_turn_end_focus (or just m_end_focus) and m_last_turn_end_focus_changed?
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".

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

Re: problem with focus change penalty

#7 Post by Dilvish »

Geoff the Medio wrote:... But I think "turn initial" is more accurate than "previous turn".
ok, I went with your proposals m_focus_turn_initial and m_last_turn_focus_changed_turn_initial. Committed.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

Post Reply