Debugging BetterAI (and Chipotle cheat mode)

Iustus

King
Joined
Jul 18, 2006
Messages
609
Location
Sunnyvale, CA
If you set cheatcode = chipotle in your ini file, there are quite a few pieces of information that are visible, intended to help determine what is going on, and track things that need improvement.

For example, if you hold down the alt and shift key, and hovering over a city, you get some extra information, including the values the governor places on each plot and for every citizen the city can run. I had debug mode active also for this screenshot (ctrl-z), which is why the unit AI is listed twice. As these are really debugging tools, it is considered alright to have this duplication in some cases, the idea is to be able to get the information when you want it, not to make it 100% pretty.
governorvalues.JPG


Holding the alt key over your name in the scoreboard will show extra information, showing the power of each player (and the total power of that player and its allies). When a player is in financial trouble, it shows a red ($$$). The barbarian numbers are not as meaningful, but I decided to leave them in. (Observant folks might notice this is a not yet released build):
scoreinfo.jpg


Holding down the shift key shows things like what resources are connected to this plot by routes, if there is a river, which direction is it flowing, what is the city founding value for the active player, what is the stack strength calculation for that plot (both offensively and defensively):
resources.jpg


holding down the alt key when mousing over a plot will show any non-zero city founding values (areas are basically continents, islands, oceans or lakes):
playerfoundvalues.jpg


If there is a d={n}, where n is some number, usually 1-4, then n is the number of bonus resources that will be 'deadlocked' that is unavailable to any future city (for example, if you found a city near the coast where there is a fish resource, but not close enough to work that fish resource.)

Spoiler more detail about founding values :

First is the player name. The color gives information. Green is used for plots that are explored by the player. Light blue means that the plot is unexplored. Yellow means it is the best plot on that continent for that player.

The first number is the cached value (from map creation if the plot is unexplored), the first value in parenthesis is the value if it were explored and recalculated right now (values are recalculated only once per turn), the second value is the value if it were recalculated right now for a civ start plot (for turn 0).

The second line is provided if the cached area best value is non zero. The Area Best is the best cached value on that continent. The Best value is the best cached value on the whole map.

So, from this picture, we can see this plot is the best plot for Roosevelt to found a city on this continent. It is a so so spot for Iustus and Napoleon. All three of these have explored this plot.

Isabella is on the same continent, but has not explored this plot yet (her Area Best is 5100).

Brennus, Huayna Capac, Churchill, and Shaka have not discovered this continent yet, they started elsewhere. They would have high values for founding a city here, because founding a city on a new continent has a high value.



While I said we do not try to make things look pretty, I am pretty happy with the new info that will be shown when you hold down ctrl key over a stack, it shows which units are grouped together, and which units are loaded on which transports, the mission of the group, the mission ai of the group, and more!
groupinginfo.jpg


When available, it will show things like the destination:
workermission.jpg


War analysis info (alt mouseover a player in the scoreboard):
warinfo.JPG


At the top of this listing, is the power of this player, (the defensive power of this player - all its vassals and defensive pacts), and if the player is in financial trouble ($$$).

Spoiler more detail about war analysis display :

If you look at the leftmost picture, that player has already decided to war with Roosevelt (his war value for starting that war is 128). If he had not already started a war, he has a 2% chance of deciding to start a total war. If he decides to start a total war, then there is only a 30% chance that he will be willing to war with Brennus or Mehmed, otherwise, he has a 100% chance of going to war with either Iustus or Ramesses. These are in sorted order of the value of going to war with each player, so the net result is there is a 30% chance of going to war with Brennus, because he is the best target (224), but if this check fails, the 100% chance of going to war with Ramesses will kick in, because he is the second best target (184). Memhed and Iustus are off the hook, because their values are too low given the 100% chance for Ramesses. The 30%/100% number here is basically based on attitude. If the 2% chance for total war fails, then there is a 2.5% chance for a limited war, with Brennus as the only possible target, and if that fails, a 2% chance for a dogpile war with Brennus. These checks are done every turn the AI is not already at war (or already planning a war that they have not declared yet). Planned wars can fail to be declared if the AI does not build enough units and get them to the enemy quickly enough to declare war. (War is declared by units that are crossing the border when the AI wants to war).

The terms 'sea war' and 'land war' are based on whether the AI considers the target to be close enough and on the same continent as its own cities. Land wars are prefered to sea wars.

If you look at the middle picture, you can see that Brennus is winning the war with Iustus (because 150 is lower than 210), losing the war with Ramesses (because 400 is higher than 40), and losing the war with Roosevelt (because 190 is higher than 60). These values very nearly translate into gold, so in this case, Brennus would ask Iustus for about 60g for peace, but you would pay Ramesses about 360g for peace, and pay Roosevelt about 130g for peace.

In the far right picture, Ramesses will not war with either Ragnar or Louis because they are not close enough, that is what 'not adjacent' means. These are drawn in a different color, and in parenthesis to indicate that until their cities/culture gets closer, war is not possible. Once they get close enough, the percentages displayed are those that would be used for attitudes.

In all cases, players whose power is too high to be a valid target are not listed at all. Nor are players whose attitudes are high enough to preclude war.


We put these things there for debugging purposes, I point them out so that you folks can use these features to give clearer descriptions of behavior that does not seem right.
 
Iustus/Blake

If possible are you able to give a brief rundown on other debugging methods, eg. logs; crash dumps. I'm still experiencing crashes (in every game); something has changed in the last month that is conflicting with the other mods I have merged BetterAI into.


There's a log called something like MPLog-2056_2-6-2007_22-34-34 which breaks down each turn in detail; is the last item on the list likely to be the cause of the crash?
 
Iustus/Blake

If possible are you able to give a brief rundown on other debugging methods, eg. logs; crash dumps. I'm still experiencing crashes (in every game); something has changed in the last month that is conflicting with the other mods I have merged BetterAI into.


There's a log called something like MPLog-2056_2-6-2007_22-34-34 which breaks down each turn in detail; is the last item on the list likely to be the cause of the crash?

Not necessarily. The second best thing to do in a case like this is to do an 'assert' build, and potentially add extra asserts to track down what is going on. For things that occur a bit too often to add asserts, you can add extra logging, take a look inside the CvRandom::get, to see how logging is done.

Building the 'Debug with release exe' target will add even more runtime error checking and allow you to run using the debugger if you have the commercial version (ie you paid for it) of Visual Studio 2003, which is the the best way to track down a reproducable crashing bug.

-Iustus
 
Next to the found values of a plot, I often see text such as d=x where x is 1 to 4. What does this mean? My guess is that it's the number of resources that will be made unworkeable by building a city on the currentplot. Is this true?

Also, what do the various percentages mean in left-most screen here:
warinfo.JPG


Particularly the 2.00% Total War, 30% land war and 100% sea war.
 
Next to the found values of a plot, I often see text such as d=x where x is 1 to 4. What does this mean? My guess is that it's the number of resources that will be made unworkeable by building a city on the currentplot. Is this true?

Also, what do the various percentages mean in left-most screen here:
{image}

Particularly the 2.00% Total War, 30% land war and 100% sea war.

I updated the first post to include the answers to these questions (look inside the spoiler tabs).

-Iustus
 
How does one go about enabling logging of everything to troubleshoot OOS errors? I know the log files might get to be in the hundreds of megs, but I know it is possible to enable. Is it in the build and if so, what file/line needs to be altered to make this possible?
 
Just tought I would mention that it is possible to enable the debug mod (chipotle mode) for the current game without actually editing the ini file. This can be useful if you are playing with this off normally, but come across something in game that you want to check out more careful.

Press Shift-Alt-D (or hit Esc and select game details)

This will bring up a window where you can set game name and admin password.. but it also has a checkbox with 'allow debug tools'.
Check this box (and clear the admin password if you had to use one to enter this screen).
After you press ok, the game will be like if you had cheatcode = chipotle in your ini file.
 
How do you get the info display to work.

I put in the chipotle code and it works fine as a place units and cities anywhere and adjust my money put I can't get any of the info displays to come up.
 
BTS doesn't have this information. Guess they removed it. Any chance to get this info reinstated to chipotle in BTS?
 
Back
Top Bottom