Project

Profile

Help

HostedRedmine.com has moved to the Planio platform. All logins and passwords remained the same. All users will be able to login and use Redmine just as before. Read more...

Bug #857459

AIs never complete Wonders with too many save/restores (2.6.1+)

Added by Chippo Elder over 2 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Category:
AI
Sprint/Milestone:
Start date:
Due date:
% Done:

0%

Estimated time:

Description

I'm waiting for an AI to complete a Wonder (for me to test something for another ticket). When I see other bugs (or potential bugs), I save, test with multiple clients, raise tickets, reload and continue. After pressing Turn Done, the AIs mostly stop building their Wonders. Next turn, they mostly continue with the SAME Wonder in the SAME city - for no loss of production or 'anything' - I thought. And this latter 'mostly', I explained away, by noticing that without any save/restoring, AIs sometimes just want to stop building a Wonder, unrelated to me, for some good reason probably.

I was wrong. They must be losing shields or 'something' whenever they stop/start the same Wonder in the same city (we (the players) don't lose anything), because they never finish them. In the attached savegame (2.6.1+ (modified b31d594a73)), 9 fairly healthy AIs have been trying to build The Great Library for 30 turns and haven't succeeded. If I don't save/restore for 5 turns, one of them will succeed.


Related issues

Related to Freeciv - Bug #855145: AI units sometimes "frozen" but wake up after a save/reload cycleNew

<a title="Actions" class="icon-only icon-actions js-contextmenu" href="#">Actions</a>
Blocks Freeciv - Task #673656: S3_1 datafile format freeze (d3f)Closed

<a title="Actions" class="icon-only icon-actions js-contextmenu" href="#">Actions</a>
Blocked by Freeciv - Bug #923658: Savegame loading calls building_advisor() before AI flag setClosed

<a title="Actions" class="icon-only icon-actions js-contextmenu" href="#">Actions</a>

History

#1 Updated by Jacob Nevins over 2 years ago

  • Related to Bug #855145: AI units sometimes "frozen" but wake up after a save/reload cycle added

#2 Updated by Jacob Nevins over 2 years ago

  • Category set to AI

This is a very longstanding bug -- see gna bug #13557 in the old tracker (referencing RT#40412 in the even older tracker).

(But it's right that we should have a copy in this tracker.)

That bug has some observations from George Koehler which don't look like they were followed up, and sound interesting; I wonder if they are still true.

As I said in #855145, it's not surprising that AI behaviour is affected by a save/load cycle. It would help if new-AI could assume that old-AI probably knew what it was doing and not second-guess decisions like these, though.

#3 Updated by Chippo Elder over 2 years ago

Jacob Nevins wrote:

That bug has some observations from George Koehler which don't look like they were followed up, and sound interesting; I wonder if they are still true.

The code has changed too much in the intervening time to apply George's patch. I can't even be sure which file needs to be patched, possibly ai/default/daidomestic.c.

#4 Updated by Marko Lindqvist over 2 years ago

  • Sprint/Milestone set to 3.1.0

George's patch was described as "failed attempt", so it's not very important.

OTOH his general finding that the issue is related to the fact that it's AI's missing wonder_city assignment that is causing the problem is very valuable. AI stops building the wonder in a city that it does not consider its wonder_city.
We could try to arrange code so that AI would choose wonder_city after loading a savegame early enough not to abandon wonder building before it, but that would probably require quite a big changes, and would only work when AI does select the same wonder_city as when (in possible quite different situation) it decided to start the wonder building.

Probably the best thing to do is to save the wonder_city information to the savegame, in AI type specific sections. Unfortunately this means that the issue won't be fixed before 3.1 as savegame format for earlier branches has been frozen.

#5 Updated by Marko Lindqvist over 2 years ago

  • Blocks Task #673656: S3_1 datafile format freeze (d3f) added

#6 Updated by Chippo Elder over 2 years ago

Marko Lindqvist wrote:

Probably the best thing to do is to save the wonder_city information to the savegame, in AI type specific sections. Unfortunately this means that the issue won't be fixed before 3.1 as savegame format for earlier branches has been frozen.

But the information is somehow already in the savegame. When you load a savegame, you can see which cities all the wonders are being built in. Why can't the AI's trust that what they were doing was fine, and continue doing it for 2 turns, and then re-think about it all?

Currently, when they think about it all, they usually choose the same wonder and the same wonder-city. When I stop and restart a wonder without doing something else inbetween, it completes in the same number of turns. Why do the AIs seldom complete wonders when they choose the same wonder and same city?

It would be sad if this can't be fixed before 3.1. Currently, if you want to have a fair game against AIs, you can't save.

#7 Updated by Marko Lindqvist over 1 year ago

Debugging the behavior it seems that it's not about not saving wonder_city, or at least not only about that. The big problem seems to be that the turn to do the recalculation is saved, so that AI will recalculate wonder wants only turns later, not immediately. The wants themselves are not saved (and I don't particularly like the idea of growing size of savegames with all that data), so they are 0 until the turn they get recalculated.

#8 Updated by Marko Lindqvist over 1 year ago

  • Blocked by Bug #923658: Savegame loading calls building_advisor() before AI flag set added

#10 Updated by Marko Lindqvist over 1 year ago

  • Status changed from Resolved to Closed
  • Assignee set to Marko Lindqvist

Also available in: Atom PDF