Filter empty sitreps

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

Moderator: Committer

Message
Author
User avatar
vincele
Space Dragon
Posts: 341
Joined: Sun Mar 23, 2014 6:10 pm

Re: Filter empty sitreps

#16 Post by vincele »

Grrr
Damn those C++ containers, I assumed maps were average O(1) (I'm coming from python hashtables)

I'll try to implement it your way, then...

BTW, do you really see this making a difference in practice ?
All the patches I'll provide for freeorion will be released under the GPL v2 or later license.
Let's unleash the dyson forest powa!

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

Re: Filter empty sitreps

#17 Post by Geoff the Medio »

vincele wrote:...I assumed maps were average O(1) (I'm coming from python hashtables)
There are hashed containers available in Boost or newer revisions of the C++ STL. unordered_map or unordered_set I think.
BTW, do you really see this making a difference in practice ?
Probably not... but I do quite dislike the look of those do while loops... and it's not really a major amount of rewriting... and you've apparently learned something from the discussion... and what ends up being slow is sometimes surprising so one might as well do the "better" thing if it's not substantially more work... and this is a hobby project, so it's OK to be picky when it's not strictly necessary.

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

Re: Filter empty sitreps

#18 Post by Dilvish »

Hmm, I was going to try the patch, stepping back and forth through turns of sitreps while watching my process monitor to see if memory ballooned like you asked about in the segfault thread. I didn't see that happening, but the patch didn't seem to be working either. Looking at the code, I'm wondering, don't you want GetSitrepsFromEmpire() to be filtering according to m_hidden_sitrep_templates?
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: Filter empty sitreps

#19 Post by Dilvish »

Just to confirm, in GetSitrepsFromEmpire(), changing

Code: Select all

        int turn = sitrep_it->GetTurn();
to

Code: Select all

        if (m_hidden_sitrep_templates.find(sitrep_it->GetTemplateString()) != m_hidden_sitrep_templates.end())
            continue;
        int turn = sitrep_it->GetTurn();
made it work the way I had expected the feature to work.
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
vincele
Space Dragon
Posts: 341
Joined: Sun Mar 23, 2014 6:10 pm

Re: Filter empty sitreps

#20 Post by vincele »

I have seen that code in GetTurnSitrepsFromEmpire() but don't know what it does, can you explain ?
In my testing it worked without, but I only tested a few tens of turns at game beginning...

I'll put it in the revised version, which doesn't have the do/while loops nor the O(N^2) behavior...
All the patches I'll provide for freeorion will be released under the GPL v2 or later license.
Let's unleash the dyson forest powa!

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

Re: Filter empty sitreps

#21 Post by Geoff the Medio »

vincele wrote:I have seen that code in GetTurnSitrepsFromEmpire() but don't know what it does, can you explain ?
It checks whether a sitrep is one of the types that has been hidden by the player. If all the sitreps on a turn are hidden, it probably shouldn't stop at that turn to show no sitreps...

User avatar
vincele
Space Dragon
Posts: 341
Joined: Sun Mar 23, 2014 6:10 pm

Re: Filter empty sitreps

#22 Post by vincele »

OK, that makes sense, it's in.

BTW, I don't sees the segfault any more too, that's strange.
But I updated to latest svn and got a big parser/* update...
All the patches I'll provide for freeorion will be released under the GPL v2 or later license.
Let's unleash the dyson forest powa!

User avatar
vincele
Space Dragon
Posts: 341
Joined: Sun Mar 23, 2014 6:10 pm

Re: Filter empty sitreps

#23 Post by vincele »

Here is an updated version, it lost the do/while loops. And the complexity is O(N) for N sitreps, it does one loop over all the sitreps, filtering those that should, and then 2 loops over the turns, so O(N+2T), but as T is << N, this becomes O(N)...

I wanted to be able to get back to initial sitreps from beginning of game, because that info is interesting, at least to newcomers to the game... So it should handle that properly.

Please test, because I'm seeing strange segfaults at game exit time, and cannot correlate them with this patch...

EDIT: Dropped patch numbered 7, it was buggy, use this one :

[The extension diff has been deactivated and can no longer be displayed.]

All the patches I'll provide for freeorion will be released under the GPL v2 or later license.
Let's unleash the dyson forest powa!

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

Re: Filter empty sitreps

#24 Post by Geoff the Medio »

vincele wrote:Here is an updated version...
Should it have all that std::cout debugging code in it?

How does this handle observers, who should see sitreps from all empires, but probably would also want to skip turns with no sitreps?

User avatar
vincele
Space Dragon
Posts: 341
Joined: Sun Mar 23, 2014 6:10 pm

Re: Filter empty sitreps

#25 Post by vincele »

Geoff the Medio wrote:Should it have all that std::cout debugging code in it?
No, sorry, I'll rediff... BTW did you test it ?
Geoff the Medio wrote:How does this handle observers, who should see sitreps from all empires, but probably would also want to skip turns with no sitreps?
How does one test that ?
All the patches I'll provide for freeorion will be released under the GPL v2 or later license.
Let's unleash the dyson forest powa!

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

Re: Filter empty sitreps

#26 Post by Geoff the Medio »

vincele wrote:did you test it ?
No, I looked at the debugging code all there, and was unsure if it was the intended patch...
Geoff the Medio wrote:How does this handle observers, who should see sitreps from all empires, but probably would also want to skip turns with no sitreps?
How does one test that ?
Start a multiplayer game as a moderator, with several AI empires. Let them play out turns until you start getting sitreps from them.

User avatar
vincele
Space Dragon
Posts: 341
Joined: Sun Mar 23, 2014 6:10 pm

Re: Filter empty sitreps

#27 Post by vincele »

Geoff the Medio wrote:Start a multiplayer game as a moderator, with several AI empires. Let them play out turns until you start getting sitreps from them.
OK, I'll also test that with the new patch.
All the patches I'll provide for freeorion will be released under the GPL v2 or later license.
Let's unleash the dyson forest powa!

User avatar
vincele
Space Dragon
Posts: 341
Joined: Sun Mar 23, 2014 6:10 pm

Re: Filter empty sitreps

#28 Post by vincele »

I tried the observer, but is there a way to stop the turn autoadvancing, because I can't do anything in the UI in that mode, too much CPU consumption.

Here is the debug-less patch...

[The extension diff has been deactivated and can no longer be displayed.]

All the patches I'll provide for freeorion will be released under the GPL v2 or later license.
Let's unleash the dyson forest powa!

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

Re: Filter empty sitreps

#29 Post by Dilvish »

use moderator mode; it doesn't auto-advance the turn and it should have the same sitrep handling as Observer
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: Filter empty sitreps

#30 Post by Geoff the Medio »

vincele wrote:Here is the debug-less patch...
I'm not fond of some of the code design you've used. In particular, you seem to have set up the (oddly / confusingly named) GetTurnSkipListFromEmpire function to accept a vector parameter by reference in which to output results. This vector appears to be assumed to be of a particular size in the function. This is quite error prone, were someone else to use it. It would be better to just output the result or to assume an empty input vector, and fill it as needed within the function.

Furthermore, why do you need to fill this structure and return turn skip info for every turn, rather than just returning the next or previous turn for a turn specified as a parameter to a function?

Post Reply