1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Infinite Loop BTS 1.01

Discussion in 'Civ4 - Better AI' started by rramstad, Oct 9, 2010.

  1. rramstad

    rramstad Chieftain

    Joined:
    Oct 9, 2010
    Messages:
    13
    Hey there. I've ran into a problem with BTS 1.01 and wanted to post.

    By way of introduction, I am new (obviously) but have been playing various Civ for many years. I was enjoying Civ IV quite a bit at first, but then the brain dead play of the AI started to bother me, so I fiddled around the Internet and found BTS 1.01. Wow, what a huge improvement! Really dramatically changes the game, for the better. Thanks.

    Anyhow, I'm playing a rather juicy game at the moment, I'm second on the scoreboard in the mid 1800s and wiping out my second enemy civilization (I think ranked fourth or fifth), when the leader on the scoreboard sneak attacks. It's cool to see the BTS code at work, as he's really got a great attack going, multiple Galleons protected by Frigates and Ships of the Line and so forth. I'm poorly defended at home because all my units are elsewhere, but I quickly build some Machine Guns (thanks Slavery) and dig in... After sending some reinforcements, I'm thinking "great, I'm going to make it to Combustion, and then I can cut off his troop resupply" but at the end of the turn...

    Waiting for other Civilizations

    and nothing. Hangs forever, with the little globe going around, all I can do is exit the program.

    I have a save file, and this is 100% reproducible. I load the file, pass (press space bar) for the two or three units that don't have commands, and blam, it happens again.

    I've also tried backing up a few years, and playing slightly differently... not sending so many troops abroad, etc, in an effort to change the exact situation that leads to the infinite loop, but that doesn't help either.

    With the creator apparently no longer working on the project, am I completely out of luck? Or is there someone out there who might want to take a look at this... I'd be happy to post the save file if that's helpful.

    BTS 1.01 on top of a fully patched BTS...
     
  2. Fuyu

    Fuyu Emperor

    Joined:
    Nov 5, 2009
    Messages:
    1,225
    Location:
    Austria
    I can't promise you a solution but you'd definitely increase the chances of getting this fixed if you upload that savegame.
     
  3. rramstad

    rramstad Chieftain

    Joined:
    Oct 9, 2010
    Messages:
    13
    Sure, here's the save file.

    Happy to help with any questions, but at least on my setup, if I just hit space bar for the couple three units that are left awaiting orders, the game loops with the Waiting message...
     

    Attached Files:

  4. rramstad

    rramstad Chieftain

    Joined:
    Oct 9, 2010
    Messages:
    13
    Hey there, just thought I'd top this thread in case anyone has any thoughts on how I might be able to debug the situation.

    I've seen references to "using a DLL with debug log enabled" -- is this something I can download somewhere, with instructions on how to use?

    I've also seen references (in other mods that integrate this mod) to a 1.02b version -- but the only downloadable version I've found is 1.01, and I thought that 1.01 was the last version. Is there somewhere I can get 1.02b? Is it likely that this version won't have the same problem?

    Any suggestions would be welcome. I'm very bummed out that I can't play this game through to the end, and I'm leery of starting a new one lest I run into the same problem after a few dozen hours of game play.
     
  5. peter450

    peter450 Prince

    Joined:
    Sep 24, 2006
    Messages:
    392
    A prev version BBAI had this, was caused by some transport code, got to a certain point and bang, a turn that never ended, it got fixed in the next version, hopefully this will get sorted too as dont want to upgrade to this latest version till it's proved 100% reliable
     
  6. jdog5000

    jdog5000 Revolutionary

    Joined:
    Nov 25, 2003
    Messages:
    2,601
    Location:
    California
    Sorry to have left you with this infinite loop possibility ... no one else has posted about it, so it's probably quite rare (the ones in the past required very specific unit combinations and circumstances, like Galleys joining Galleon groups).

    In the past this has always surfaced from endless grouping/ungrouping of AI units ... some unit decides to group with another, then after the grouping the leader of the group decides to ungroup, then the ungrouped unit regroups, etc. Debugging this in one of the hardest things to do, and requires attaching the visual studio debugger to the game and waiting for the infinite looping to start. You then have to 'break' the game progress, set a breakpoint in the UnitAI function which calls all the move functions, and then let the game run until it hits the break point. Then the fun begins: you have to watch the looping through UnitAI move functions over and over until you logically deduce what's happening and how to fix it. It's not easy, even when you know the code inside and out, and have experience running debuggers.

    Unfortunately my Civ4 modding computer broke a while ago and I don't have the time to get back in to it.

    You could try rolling back to 1.00 and seeing if the same result happens (the save should be compatible, you can get 1.00 from sourceforge). This would give a lot of clues, and hopefully let you progress in your game.
     
  7. rramstad

    rramstad Chieftain

    Joined:
    Oct 9, 2010
    Messages:
    13
    Trying 1.00 is an interesting suggestion, but the exact same thing happens. Grrr...

    I'm not sure if it's helpful, but there's a light grey diagonally slashed area, all on water, near some enemy ships. I suspect that the system is either doing what you've suggested -- trying to group or ungroup some transports (Galleons) that are organized with some other ships (mostly Frigates, plus one Ship of the Line) OR possibly he's considering moving some units. It's odd though in that the cross hatch almost looks like he's got a settler that wants to build a city... that's the kind of graphic it is. It does look to be an area three squares away from the unit in question.

    If there's anything else I can do to help, or anything else I can try, I'm all ears.

    I suppose the next possibility would be for me to jump back 20+ years, try to accelerate my navy, and do what I can to keep him from being able to execute this strategy... the suggestion that the endless loop might be due to him grouping and ungrouping ships is helpful.
     
  8. rramstad

    rramstad Chieftain

    Joined:
    Oct 9, 2010
    Messages:
    13
    Here's a really weird one. I went back 20 years or so, and did a few things differently. I knew he was coming with ships, to a particular area, so I moved some ships over that way. I managed to pick off his early arrivals, and migrated some land units there too, so that the units that landed were in trouble. Basically I got his first wave no problem.

    Second wave showed up, much bigger than the first, but now it wasn't able to merge with the first wave, figured the freeze out problem wouldn't happen, if it had to do with him grouping or ungrouping sea units. Used my land units to attack his newly landed units, pretty much crippled them, left maybe three or four units total with heavy damage.

    I had one turn to go to Combustion, passed on my last few units, and boom, the dreaded Waiting message, again, forever.

    Something seems to be happening specifically when I get Combustion. The scoreboard leader has top of the line sailing ships, but does not have Combustion. The game spin locks when I end the turn immediately before getting it. i.e. Combustion (1) on the top, nearly full green bar.

    All I can think of is that perhaps the AI is getting stuck in some odd logic having to do with me suddenly having an advantage with sea units, where earlier I definitely did not, as I don't have many sea units, and what I had was not as good as what he had.

    No idea what I should do, and frankly, pretty bummed out here. I was super excited when I found this mod -- it was so much better than vanilla BTS, it wasn't even funny. I had gotten totally burned out on vanilla BTS and probably would never have played it again, but this mod made things very challenging again, and I had four or five starts in a row where the AI played better than I did, and I had to pack it in early. This is the first game I've had where I feel like I'm at a reasonable spot vs the other civs, and of course they're all attacking me, but I like a challenge... I'd love to be able to play this one out, and I hate to start a new one knowing that I might just get to a juicy part and have the whole thing wedge like this.

    Bummer!
     
  9. rramstad

    rramstad Chieftain

    Joined:
    Oct 9, 2010
    Messages:
    13
    So, if I wasn't clear, in the previous save game, I was in 1866 and would receive Combustion at the start of the next turn. I went back to 1840s or 1850s and played through again, with different settings, and was in fact in 1868 when I was to get Combustion at the start of the next turn, but the system wedged again. It's really weird that this would happen with a totally different mix of units (because I built differently, and because I was actively defending, attacking his units as they landed) and in a totally different year, but exactly on the turn that Combustion was discovered.
     
  10. Woody1

    Woody1 Prince

    Joined:
    Feb 19, 2002
    Messages:
    468
    Location:
    Texas
    I've had endless loops, too, using the latest BBAI as well as prior versions. I've now given up on BBAI, because I hate having to give up on a game half-way through. I'm using the UP instead, hoping the same bugs aren't in it. If they are, I'll roll back to vanilla.

    I take it that any more work on BBAI or UP is not going to happen.

    At some point, I'll buy Civ5. I've bought every Civ game produced, right back to the original. But every one needed about 6-12 months before it was patched to a reasonably non-buggy version. I expect Civ5 is no different, so I'll probably wait for the "gold" version.
     
  11. Vanir

    Vanir Chieftain

    Joined:
    Oct 19, 2008
    Messages:
    8
    1.02b refers to a version of BBAI that Fuyu made that is merged with the BULL and BUG mods. I doubt the few changes it makes would make a difference with your problem, but since we don't know the cause you may want to give it a shot. You can download it here.
     
  12. NP300

    NP300 Prince

    Joined:
    May 18, 2004
    Messages:
    402
    Location:
    North America
    Have you modded your tech tree at all? I have seen infinite loops caused by certain tech tree mods.
     
  13. rramstad

    rramstad Chieftain

    Joined:
    Oct 9, 2010
    Messages:
    13
    Honest truth, I don't know. I'm running vanilla BBAI 1.01. If it includes some tech tree mods, then yeah, I'm running tech tree mods :D
     
  14. jdog5000

    jdog5000 Revolutionary

    Joined:
    Nov 25, 2003
    Messages:
    2,601
    Location:
    California
    If you're just running BBAI, then it can't be a tech issue. It's almost certainly unit grouping.

    I will try to sort this out, but it will be several weeks before I have a chance ... need to try booting a different computer off the hard drive of my old modding computer that died. It won't happen before mid-November though (when I'll have time and a back-up machine in case something goes wrong).
     
  15. rramstad

    rramstad Chieftain

    Joined:
    Oct 9, 2010
    Messages:
    13
    It's nice of you to offer to wade back into this. I am certainly in no rush, in fact, am kind of swamped. I'm a coach for a kid's football team, 7, 8 and 9 year olds, with a few 6 year olds. We're undefeated 7-0 and if we win our next playoff game, the championship is at Husky Stadium (University of Washington) so we're all pretty pumped here. Next couple of weeks at least are going to be a bit of a daze, and if I get the urge to play something after that, I've been meaning to try Rome: Total War.

    That said, it would be awesome for me to get the chance to play this through, and more importantly, I'm sure the community would really appreciate it if this mod was something that was actively being patched -- maybe not a bunch of new features or anything wacky like that, but if at the very least reported bugs would get fixed at some point, that would be really cool, even if it took a month or two.
     
  16. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    I noticed a wonky Unit Grouping issue in CvSelectionGroup, right here:

    Code:
    pLoopUnit->joinGroup(NULL, true);
    			pLoopUnit->ExecuteMove(((float)(GC.getMissionInfo(MISSION_MOVE_TO).getTime() * gDLL->getMillisecsPerTurn())) / 1000.0f, false);
    /************************************************************************************************/
    /* Afforess	                  Start		 07/31/10                                               */
    /*                                                                                              */
    /* Units Seem to be getting stuck here                                                          */
    /************************************************************************************************/
    			if (GC.iStuckUnitID != pLoopUnit->getID())
    			{
    				GC.iStuckUnitID = pLoopUnit->getID();
    				GC.iStuckUnitCount = 0;
    			}
    			else
    			{
    				GC.iStuckUnitCount++;
    				if (GC.iStuckUnitCount > 5)
    				{
    					FAssertMsg(false, "Unit Stuck in Loop!");
    					CvUnit* pHeadUnit = getHeadUnit();
    					if (NULL != pHeadUnit)
    					{
    						TCHAR szOut[1024];
    						CvWString szTempString;
    						getUnitAIString(szTempString, pHeadUnit->AI_getUnitAIType());
    						sprintf(szOut, "Unit stuck in loop: %S(%S)[%d, %d] (%S)\n", pHeadUnit->getName().GetCString(), GET_PLAYER(pHeadUnit->getOwnerINLINE()).getName(),
    							pHeadUnit->getX_INLINE(), pHeadUnit->getY_INLINE(), szTempString.GetCString());
    						gDLL->messageControlLog(szOut);
    					}
    					pLoopUnit->finishMoves();
    				}
    			}
    /************************************************************************************************/
    /* Afforess	                     END                                                            */
    /************************************************************************************************/
    I added two variables to keep track of it in CvGlobals and just sidestepped it by finishing the units moves, and reports of infinite loops vanished after I did that. It's a total hack and not a solution by any means, but it does "fix" the problem, in the loosest sense of the word.
     
  17. rramstad

    rramstad Chieftain

    Joined:
    Oct 9, 2010
    Messages:
    13
    Hey there, was just checking in on the forum to see if maybe there was a new version of Better AI to try, and seeing nothing, thought I'd bump this thread. Any further suggestions for things to try would be most welcome. Thanks and happy holidays!
     
  18. civjo

    civjo Chieftain

    Joined:
    Oct 3, 2010
    Messages:
    67
    Well, from the developers point of view indeed ... I speculate jdog5000 encountered this beast more than once. And painstakingly analyzed and solved each time the core problem of the current incarnation of the beast. Ie. avoid the AI generating such suspicious constellations of units like "Galleys joining Galleon groups"
    Surely this is the best approach while you are developing further and further ... simply try to let the AI always find the best steps it can. And clearly an inoperable unit, just sitting around isn't a good step, let alone the best step.

    Ok, from the players point of view one or even some defunc'ed units are not great, but tolerable. Especially if the alternative is the total show stopper.
    So I think this "hack" is precious, it is a big step forward. It skips the dangerous units, so the show can go on.
    Even more: Who likes, can check the log files and delete and/or replace those units (eg. change Galleys into Galleons) ...

    After looking into CvSelectionGroup.cpp I have a question: does this patch just help in cases 1 unit cannot decide to join or not (well endlessly joining & leaving) ... or prevents this also complicated interactions between several units?? (And if yes, why doesn't need every unit its own counter???)
     
  19. rramstad

    rramstad Chieftain

    Joined:
    Oct 9, 2010
    Messages:
    13
    I'd be totally psyched to try any solution if someone can provide explicit directions on how to install it.
     
  20. civjo

    civjo Chieftain

    Joined:
    Oct 3, 2010
    Messages:
    67
    Hi rramstad, it is great that you are still around & interested ... btw, you are a perfect protagonist of the mentioned player side :goodjob: ... yes, it is not at all funny to have a good game going and then STOP FOREVER.
    Unfortunately it is quite a long way from a dozen lines of changed C++ code to something you need 'directions on how to install it'. So probably your patience will be challenged for some more weeks.

    I want also get a solution, which of course will be suboptimal, I suppose at least in the eyes of the great creator of this mod, but avoids those absolute standstills in a general way ...
    Afforess did already a huge step, but a bit is still missing (standalone bbaiDLL, preferably based on rev597 sources and this patch).

    Reading in the thread jdog5000's comment about grouping and regrouping of galleys & galleons I thought counters would be a general way to limit this behavior ... 1 counter for every unit ...
    Maybe I am again on a woodway :D , because as I understand it, Afforess' check now compares the current unit with that memorized last time and stops after the 6th time.
    But what if unit A joins unit X, and unit B joins because of that too unit X, then because of that unit A leaves unit X, and unit B leaves because of that too unit X ...

    Hope I understand that issue before trying to go further.
     

Share This Page