FreeOrion

Forums for the FreeOrion project
It is currently Sat Dec 16, 2017 10:43 pm

All times are UTC




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Mon Dec 28, 2015 7:28 pm 
Offline
Release Manager, Design
User avatar

Joined: Wed Nov 16, 2011 12:56 pm
Posts: 4303
Location: Sol III
To follow up on the issue that came up when testing this PR where I ran several test games for ~100 turns with the default quickstart settings and got quite a lot error messages in the AI logs about ships with apparently no valid design (see line comments and discussions in that PR).

I investigated a bit further and it looks like we might actually not dealing with a bug here. Additional info I added to the log messages indicate that those ships had no name, no owner, no design, all stats zero, no nothing. Looking at the code of Ship::Copy...
Code:
    if (vis >= VIS_BASIC_VISIBILITY) {
        if (this->m_fleet_id != copied_ship->m_fleet_id) {
            // as with other containers, removal from the old container is triggered by the contained Object; removal from System is handled by UniverseObject::Copy
            if (TemporaryPtr<Fleet> oldFleet = GetFleet(this->m_fleet_id))
                oldFleet->RemoveShip(this->ID());
            this->m_fleet_id =              copied_ship->m_fleet_id; // as with other containers (Systems), actual insertion into fleet ships set is handled by the fleet
        }

        if (vis >= VIS_PARTIAL_VISIBILITY) {
            if (this->Unowned())
                this->m_name =              copied_ship->m_name;

            this->m_design_id =             copied_ship->m_design_id;
...reveals that if an empire has only basic visibility of an unknown/enemy ship it does not know the ship design (design id isn't copied). According to the additional info I logged, although there are quite a lot of these error messages, they only refer to very few ships, it's just that the same few ships trigger that error over and over again. It also appears only in some AI logs, so all in all this seems to be a rare case.

But apparently now and then it does happen that an empire can "see" a ship with only basic visibility, so it basically only knows that it's there, but that's it - no stats, no info about the owner or the design, nothing. Causing errors whenever the AI code tries to access the design of such a ship of course. As far as I can tell this currently happens in two places, the one in AIstate.py Morlic fixed in the PR mentioned above, and the other one in GetEffectsAndTargets, which apparently gets called when the AI client runs meter estimates:
Code:
2015-12-28 18:24:29.868592 [debug] AI : Universe::InitMeterEstimatesAndDiscrepancies
2015-12-28 18:24:29.868618 [debug] AI : IMEAD: updating meter estimates
2015-12-28 18:24:29.877236 [error] AI : Universe.cpp:2092 : GetEffectsAndTargets couldn't get ShipDesign
2015-12-28 18:24:29.877289 [error] AI : Universe.cpp:2093 : OBJ_SHIP 1122:   at: Hewish γ owner: (Unowned)  created on turn: 65 specials:   Meters: Target Industry: Cur: 0 Init: 0  Target Research: Cur: 0 Init: 0  Target Trade: Cur: 0 Init: 0  Max Fuel: Cur: 0 Init: 0  Max Shield: Cur: 0 Init: 0  Max Structure: Cur: 0 Init: 0  Industry: Cur: 0 Init: 0  Research: Cur: 0 Init: 0  Trade: Cur: 0 Init: 0  Fuel: Cur: 0 Init: 0  Shield: Cur: 0 Init: 0  Structure: Cur: 0 Init: 0  Stealth: Cur: 0 Init: 65536  Detection Range: Cur: 0 Init: 0  Speed: Cur: 0 Init: 0   design id: -1 fleet id: 1123 species name:  produced by empire id: -1 fighters:  part meters:
The question now is, is that intended behavior (ships empires have only basic visibility of), or is something amiss here? In the former case we should stop throwing errors if a ship without design is encountered, as this is a case that actually can happen and must be accounted for in the respective code sections (both Python and C++).


Top
 Profile  
 
PostPosted: Mon Dec 28, 2015 7:54 pm 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12045
Location: Munich
I think you get basic visibility of otherwise-stealthy opponent ships that attack you in combat.

Don't know why this would be more or less prone to happening in a moderated game, though, as was reported.


Top
 Profile  
 
PostPosted: Mon Dec 28, 2015 10:05 pm 
Offline
Creative Contributor
User avatar

Joined: Fri Jun 28, 2013 11:45 pm
Posts: 3295
Geoff the Medio wrote:
I think you get basic visibility of otherwise-stealthy opponent ships that attack you in combat.

I believe this is correct and iis intended, IIRC Dilvish was the most recent to do some work in that area as there were some issues with the way it was working, we decided we wanted to have something visible to players to let them know/remind them of issues (specific example, very early game Asteroid Snails get marked as a white ship if they kill something).

I think it's good that we show something, and I'm not certain it's working reliably for empire owned vessels, thus it would be good if the AI can handle knowledge that something is there without knowing what.

_________________
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.


Top
 Profile  
 
PostPosted: Wed Dec 30, 2015 4:01 pm 
Offline
Release Manager, Design
User avatar

Joined: Wed Nov 16, 2011 12:56 pm
Posts: 4303
Location: Sol III
Geoff the Medio wrote:
I think you get basic visibility of otherwise-stealthy opponent ships that attack you in combat.
Ah yes, that could be the cause for these "basic visible" ships.

Well, this means that having a ship without a design isn't an error, but a possible (albeit rare) case. Consequently it needs to be handled as such. From what I've seen, there are two code sections that currently log errors when encountering this case. First one is the fix Morlic provided for AIstate.py:
Code:
                if not design:
                    print "ERROR: Ship appears to have no valid design..."
                    continue
                for partname in design.parts:
                    if partname and fo.getPartType(partname).partClass == fo.shipPartClass.shortRange:
                        damage = ship.currentPartMeterValue(fo.meterType.capacity, partname)
                        stats['attack'] += damage
                        stats['attacks'][damage] = stats['attacks'].get(damage, 0) + 1
@Morlic, I guess that error log message can go?

The second one is in Universe::GetEffectsAndTargets (line 2092 in Universe.cpp):
Code:
    // 5) EffectsGroups from Ship Hull and Ship Parts
    if (GetOptionsDB().Get<bool>("verbose-logging"))
        DebugLogger() << "Universe::GetEffectsAndTargets for SHIPS hulls and parts";
    type_timer.restart();
    // determine ship hulls and parts of each type in a single pass
    // the same ship might be added multiple times if it contains the part multiple times
    // recomputing targets for the same ship and part is kind of silly here, but shouldn't hurt
    std::map<std::string, std::vector<TemporaryPtr<const UniverseObject> > > ships_by_hull_type;
    std::map<std::string, std::vector<TemporaryPtr<const UniverseObject> > > ships_by_part_type;
    ships = m_objects.FindObjects<Ship>();
    for (std::vector<TemporaryPtr<Ship> >::const_iterator ship_it = ships.begin(); ship_it != ships.end(); ++ship_it) {
        TemporaryPtr<const Ship> ship = *ship_it;
        if (m_destroyed_object_ids.find(ship->ID()) != m_destroyed_object_ids.end())
            continue;

        const ShipDesign* ship_design = ship->Design();
        if (!ship_design) {
            ErrorLogger() << "GetEffectsAndTargets couldn't get ShipDesign";
            continue;
        }
As that function apparently gets also called by the clients (only AI?) to run estimates, it too shouldn't log an error here. Maybe necessary to check if that happens in the server or a client process, as the server probably should log an error in this case? Geoff?


Top
 Profile  
 
PostPosted: Thu Dec 31, 2015 8:14 pm 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12045
Location: Munich
Vezzra wrote:
As that function apparently gets also called by the clients (only AI?)
Should be used everything, I think.
Quote:
...to run estimates, it too shouldn't log an error here. Maybe necessary to check if that happens in the server or a client process, as the server probably should log an error in this case? Geoff?
It's problematic to make different things happen on clients vs. the server in this type of code because it's supposed to be all in the common module, which is compiled as neither client nor server code. Just removing the error message is probably fine, as it's occasionally expected behaviour.


Top
 Profile  
 
PostPosted: Sat Jan 02, 2016 8:50 pm 
Offline
Release Manager, Design
User avatar

Joined: Wed Nov 16, 2011 12:56 pm
Posts: 4303
Location: Sol III
Ok, removed both error messages. Commit 9a5b4b3.


Top
 Profile  
 
PostPosted: Thu Jan 07, 2016 3:19 pm 
Offline
Space Floater

Joined: Tue Mar 10, 2015 8:23 am
Posts: 26
Would it be possible to create an "unknown" ship design so that the server can specifically tell a client that a ship exists but nothing is known about it? Simply removing the error messages would make it more difficult to diagnose actual errors in the future.

_________________
Unless stated otherwise, code and scripts provided by me are released under GNU GPL 2.0 (or later) and other content is released under CC BY-SA 3.0.


Top
 Profile  
 
PostPosted: Thu Jan 07, 2016 3:36 pm 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12045
Location: Munich
mel_o wrote:
Would it be possible to create an "unknown" ship design so that the server can specifically tell a client that a ship exists but nothing is known about it?
That's what a ship with design id = INVALID_DESIGN_ID means... its design is not known to the player.


Top
 Profile  
 
PostPosted: Thu Jan 07, 2016 5:10 pm 
Offline
Release Manager, Design
User avatar

Joined: Wed Nov 16, 2011 12:56 pm
Posts: 4303
Location: Sol III
Geoff the Medio wrote:
mel_o wrote:
Would it be possible to create an "unknown" ship design so that the server can specifically tell a client that a ship exists but nothing is known about it?
That's what a ship with design id = INVALID_DESIGN_ID means... its design is not known to the player.
Hm, shouldn't we then have another constant that specifies "does not have a design assigned" that the design id is set to on object construction? That way we could catch cases where due to whatever bug a ship didn't get a design assigned.

Just tossing a thought around, no idea if that's really reasonable.


Top
 Profile  
 
PostPosted: Thu Jan 07, 2016 5:37 pm 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12045
Location: Munich
Vezzra wrote:
...another constant that specifies "does not have a design assigned" that the design id is set to on object construction?
Not necessary as far as I know, and a bunch of awkward-to-add extra tests / checks would be required.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group