Artificial Unintelligence

It requires that the AI have any idea whatsoever that it's at a disadvantage. When it is, I think it should place a higher value on fortifying infantry units on difficult terrain tiles adjacent to its cities. This should significantly slow advances into an AI's territory and substantially help city states, which often have fewer units and can't afford to be making too many risky assaults.
Features like these are much easier said than done. Humans can often just look at a battlefield an be able to see whether they're in a good position or not within a few hundred milliseconds, but an AI would have to run a boatload of calculations to do the same thing. There are a lot more actual factors that go into determining which positions are best for defense, especially considering rivers and the blocking of ranged attacks by rough terrain, and having all the AIs constantly calculate these each turn would slow down turns significantly even if I knew where to start.
On the plus side, I can make the AI realize that it is better off fortifying on a tile than attacking with a melee unit: it's already in as a part of the newly remade DangerPlots, though it still has a few small issues (if a unit is already fortified, the AI does not currently consider that it will lose its fortification bonus if the unit attacks).

Oh, and is it possible to tell the AI that if:
1. All religions have been founded and
2. It didn't found a religion that it
3. Should not attempt to build the Hagia Sophia?
That's kind of the problem with wonders and the flavor system: a lot of wonders are so conditional that a flavor system is never good enough for them.
Basically, everything the AI can produce or build has a set of flavor values that is multiplied by the AI leaders' intrinsic flavor to produce final flavor values, which then get summed up and compared with one another to determine what the AI wants to produce. For example, Barracks have one flavor value, Military Training, so whether the AI wants to build Barracks in their cities relies primarily on the value of the leader's Military Training flavor. Note that currently, flavors for individual buildings cannot be changed throughout the game, so eg. Barracks do not get Happiness flavor if the AI selects the Autocracy tenet that makes Barracks give +2 happiness. Buildings that unlock future buildings also don't get any additional flavor modifications: Celts AI does not give any additional priority to amphitheaters, even though they are required to unlock the Celts' UB opera house replacement.
Wonders have the additional problem of their effects being very situational: AI cities will assign Petra the same flavor values whether the city only has one flatland desert or 6 desert hills. Pyramids get the same flavor whether the AI has two workers for five cities or five workers for two cities. Terracotta has the same flavor whether the AI has five units around the city or no units.

Once I have a closer look at flavors and the flavor system in general, you can be sure I'll have something in place that will reduce the AI's willingness to build wonders that give free GP's if it couldn't use those GP's for anything worthwhile. Right now though, I'm concentrating on my DangerPlots and TacticalAI stuff. Plus, I have a life outside of modding, and currently that life will contain four fairly difficult exams in the near future.

In the meantime, I discovered one more problem with the way the AI handles attack targets: because attack targets are looked for at the beginning of the tactical AI's turn, any units that are not visible to the AI at the beginning of its turn are never attacked on that turn. Once again, this hurts naval combat the most, not just because it gives submarines a huge advantage, but also because there are more cases of naval units discovering an enemy unit during their turn due to their high movement speeds. Between this and the AI's inability to handle units that can push or withdraw (Winged Hussars, Slingers, Scouts with Survivalism III), guess what's going on the chopping block next for v10's TacticalAI changes...
 
This is covered by "Active AI in MP", I believe? If so, I am planning on implementing it as an XML-enabled option for v10 (meaning you could toggle it on or off, because I imagine not everyone would like to be bombarded with AI deals in MP).

Awesome - the game is so lonely without the AI scheming.
 
This is covered by "Active AI in MP", I believe? If so, I am planning on implementing it as an XML-enabled option for v10 (meaning you could toggle it on or off, because I imagine not everyone would like to be bombarded with AI deals in MP).
In the current version of my mod the AI proposals don't pop up as they do in singleplayer. There only is a notification that can be removed with a right click or opened with a left click.

Still haven't worked on merging my mod though, because I am working on a very special mod right now that will hopefully remove some problems with mp mods and probably with mp stability. I expect a testing version to hit this weekend and want to discuss possibilities to enhance dll modding with mayor dll modders if it works out as I expect.
 
In the current version of my mod the AI proposals don't pop up as they do in singleplayer. There only is a notification that can be removed with a right click or opened with a left click.

Still haven't worked on merging my mod though, because I am working on a very special mod right now that will hopefully remove some problems with mp mods and probably with mp stability. I expect a testing version to hit this weekend and want to discuss possibilities to enhance dll modding with mayor dll modders if it works out as I expect.
Don't worry about trying to merge on your end, I'd prefer to do my own merging anyway. I'm fine with the AI submitting proposals like a human player would (ie. through a notification instead of through a leader scene). Besides, my mod is probably the only fairly big DLL mod that isn't based on WHoward's DLL. I don't want to burden anyone other than myself with trying to comb through my code and merge it into WHoward's stuff, especially since I'd like to update the AI code to take advantage of WHoward's additions when I do end up eventually merging WHoward's stuff into AuI.

Good luck on your special mod. Given how busy my life outside of modding is going to be for the next few weeks, I do not know how well I'll be able to participate in any of your planned discussions.
 
Is there anything in particular you'd like me to look at Delnar? I had been spending all my time forcing the flavor values and actions to make brute force correct decisions, but this is a waste of time if we're going to address the flavor system.

I'd rather work on something of value.
 
Is there anything in particular you'd like me to look at Delnar? I had been spending all my time forcing the flavor values and actions to make brute force correct decisions, but this is a waste of time if we're going to address the flavor system.

I'd rather work on something of value.
You work on whatever you want to work on, I am definitely not your boss. I honestly cannot think of anything that I would want to address but cannot do on my own eventually, though naturally someone who is experienced at working with certain types of code will be able to perform the same tasks I could, but at a much faster pace. It really is all just a matter of time, so your time spent on tweaking flavors helps as much as time spent redesigning the pathfinder for multithreading (eg. currently, because the pathfinders use internal A* node data for constructing two doubly linked lists, running more than one pathfinder check at once is impossible) or time spent fiddling with diplomacy constants. So long as you share your information with others somehow (through your own mod maybe?), everything has some value.

Even if a lot of wonders have situational uses, there are still plenty of wonders that could still work just fine with a flavor system, eg. Stonehenge, Leaning Tower, Himeji Castle, Temple of Artemis, Hanging Gardens, Notre Dame, and Parthenon.

Besides, even though I am planning on making adjustments to the flavor system (eg. allowing belief and policy entries to adjust the flavors of certain units and buildingClasses is a must), I doubt it will happen anytime soon. My DangerPlots stuff and life are keeping me quite busy as it is.
 
Ran a test game with latest dev version, and you can radar with settlers because if you set a path with them, they will go around enemies. Normal units will "move" path straight through them.

Way better than before, but noticed it in my test.
 
Ran a test game with latest dev version, and you can radar with settlers because if you set a path with them, they will go around enemies. Normal units will "move" path straight through them.

What exactly do you mean by the bolded bit? That they automatically change their path to one that doesn't match what was shown in the UI? That their automatic path through fog avoids enemy units, essentially letting players radar indirectly?
 
What exactly do you mean by the bolded bit? That they automatically change their path to one that doesn't match what was shown in the UI? That their automatic path through fog avoids enemy units, essentially letting players radar indirectly?

If I set a move 10 turns a way with an archer through fog, and an enemy unit, it moves in a direct line.

If I set a move 10 turns a way with a settler through fog and an enemy unit, it moves around the enemy unit.

Without moving, just viewing the move with a settler, I know there's an enemy in the way.
 
You work on whatever you want to work on

I've started work on improving Hybrid mode. It currently works like this.

player 1, and 2 not at war, player 3 and player 4 at war, player 5 and player 6 at war.

Player 1 and 2 play simel turn. Then player 3 sequential, player 4 seq, player 5 seq, player 6 seq.

Instead I am trying to make it go..

Player 1, 2, 3, and 5 Simel
Player 4 and player 6 Simel.
 
If I set a move 10 turns a way with an archer through fog, and an enemy unit, it moves in a direct line.

If I set a move 10 turns a way with a settler through fog and an enemy unit, it moves around the enemy unit.

Without moving, just viewing the move with a settler, I know there's an enemy in the way.
Found the issue, it's another one of those annoying "loop through all units in a plot" checks that does not consider tile visibility; this time, it's in CvUnit::canMoveInto() when the attack flag is not set (which is why it only works for non-combat units, since combat units use canMoveOrAttackInto(), which returns true if canMoveInto() with attack flag set returns true). Thanks for pointing it out, I'll try to have a fix uploaded in a day or two.

EDIT: Nope, it must be something else. That code section still lets you radar, but only under very specific circumstances.

I've started work on improving Hybrid mode. It currently works like this.

player 1, and 2 not at war, player 3 and player 4 at war, player 5 and player 6 at war.

Player 1 and 2 play simel turn. Then player 3 sequential, player 4 seq, player 5 seq, player 6 seq.

Instead I am trying to make it go..

Player 1, 2, 3, and 5 Simel
Player 4 and player 6 Simel.

Good luck; I poked about in the simultaneous/dynamic turns mode code, and I honestly couldn't make much out of it at first glance. The info I posted in the Hybrid mode thread in the NQ mod's Reddit page about a week ago is still correct AFAIK.
 
Hi, all. I played Civ 4 for years and years and what really kept me playing it was Kmod. Karadoc did an excellent job of making an AI that played like a ruthless human, it was almost exactly like playing MP against good players.

I haven't played much Civ 5, mostly because the AI is a complete joke, so I'm hoping to find a good AI improvement mod. I've heard good things about this one so I'm going to give it a go ;)
 
Hmm, I appear to have fixed the indirect radaring on my end, I believe it was caused by the pathfinder calculating ZOC for units that the player couldn't see, and settlers avoided units because ZOC paths are slower than regular ones. The fix does not seem to have any effect on ZOC when it matters, so that's good. I tested it by spawning a couple barbs in fog, spawning a Sipahi on a tile from which the barbs weren't visible, and had the Sipahi try to move to a tile that it could only move to if barb ZOC was not applied as it moved; sure enough, the Sipahi was stopped by the first barb's ZOC, even though the movement order happened without vision of the barb unit.

If this is not what originally caused it, I don't know what did, but I was not able to reproduce the bug on my updated build.

I'll be committing my changes within the next hour.

I haven't played much Civ 5, mostly because the AI is a complete joke, so I'm hoping to find a good AI improvement mod. I've heard good things about this one so I'm going to give it a go ;)

I'm still nowhere near getting the AI to play at a similar level as competent human players. You can thank Civ5's combat system for that: between 1UPT, ranged attacks, embarking, and attacks not instantly killing one of the participants, things get very complicated very fast.
It's still an improvement over the original AI, though: the current version will probably be enough to make whatever difficulty level you would otherwise be comfortable playing on feel noticeably more difficult, but not difficult enough to force you to drop a difficulty level.
 
Hey Delnar, quick (or not-so-quick) question if you will:

Would you know where in the GeneratePath function

Code:
GC.GetInternationalTradeRouteWaterFinder().GeneratePath(iOriginX, iOriginY, iDestX, iDestY, eOriginPlayer, false);

determines if a particular plot (during it's pathfinder search) is valid?
 
Hey Delnar, quick (or not-so-quick) question if you will:

Would you know where in the GeneratePath function

Code:
GC.GetInternationalTradeRouteWaterFinder().GeneratePath(iOriginX, iOriginY, iDestX, iDestY, eOriginPlayer, false);

determines if a particular plot (during it's pathfinder search) is valid?

CvAStar::TradeRouteWaterValid() in the experimental branch, regular TradeRouteWaterValid() in the master branch and the original DLL code. Either way, you'll find it in CvAStar.cpp.

Functionally, pathfinder classes contain a number of delegates for node validation, node cost heuristic, node cost, etc., then assign those delegates to functions in the pathfinder's Initialize() call. In the original and pre-v10 code, this is done via a bunch of function pointers assigned to memberless functions like TradeRouteWaterValid(). I shuffled things around a bit for v10 and made the pathfinder actually use the FastDelegates system that Civ5 already implemented for RNG delegates, mainly just so I have a clearer picture of what's going on in the pathfinder. Admittedly, it should theoretically work faster than before as well, because the function pointer dereferences are compiler-optimized, the actual functions do not need to constantly dereference pointers to the pathfinder, and the functions contain few enough arguments that they can be stored in the eax-edx registers on the first go. I have not tested it for performance though, so it may or may not actually be faster, I just did it because I was trying to organize the pathfinder's code, plus doing the reshuffling helped me understand the pathfinder a bit more.
 
Love your mod and have been using it. Im careful what other mods I try and play at the same time as im aware anything where the AI has to make decisions will be affected.

Does the Promotions expansion work with this mod? I noticed you talking about it on steam but couldn't find an answer, nothing worse than starting a game only to realise later its broken.
 
Can you help carriers try to sink enemy carriers? Also, planes tend to go after insignificant targets. They should go after enemy artillery, enemy carriers and the like. The AI does use some air sweep, but not enough. Aside from my few complaints it is excellent. I will use this mod for every game I play. And I realize it is not an easy task to code all of this. :)
 
Love your mod and have been using it. Im careful what other mods I try and play at the same time as im aware anything where the AI has to make decisions will be affected.

Does the Promotions expansion work with this mod? I noticed you talking about it on steam but couldn't find an answer, nothing worse than starting a game only to realise later its broken.
Promotions expansion works with the mod, but the AI will never select any of the new promotions... at least, not until v10 is released.
I honestly would not worry that much about compatibility issues: almost all mods that are incompatible with AuI are incompatible because they are also DLL mods, not because they change the AI in anyway. Non-DLL mods that change AI behaviors should work fine: worst case scenario, you'll have unintentional interplay with the other mod expecting a behavior that I changed in AuI, and you'll usually be able to spot this pretty easily. Mods that add new stuff are usually fair game, the worst case scenario is that the AI does not know how to use the new stuff.

Can you help carriers try to sink enemy carriers? Also, planes tend to go after insignificant targets. They should go after enemy artillery, enemy carriers and the like. The AI does use some air sweep, but not enough. Aside from my few complaints it is excellent. I will use this mod for every game I play. And I realize it is not an easy task to code all of this. :)
Air sweeps are being tweaked a bit for v10, since they are part of the larger ExecuteAttack() overhaul. No guarantees for having the AI relocate fighter units to where air sweeps are needed though: I can definitely add it in, but it's really outside of what I'm currently focusing on (DangerPlots, ExecuteAttack, and citizen management).

As for choosing which units to target, that's actually more on the side of complete overhauls than minor tweaking. The AI only has three priorities for units: units that can capture a city next turn are High priority, units that can damage a city next turn are Medium priority, and all other units are Low priority. If I were to change the AI so that it weighs targets on a continuum scale, ie. not in a static state "High-Medium-Low" system, I'd have to write target scoring algorithms, completely change the logic of when the AI is willing to attack against unfavorable odds, mess with the algorithms that determine which units are used for which attacks, etc. Once again, it's doable, as is pretty much everything, and it's also fairly important, but it's a lot of work, so I'd rather just add it onto my (incredibly long) todo list to tackle for later.
 
Quick question Delnar, will the AI routines (DangerPlots especially, but other stuff as well) in v10 be compatible (i.e. checks all units on plot) if MUPT-enabled?
 
Quick question Delnar, will the AI routines (DangerPlots especially, but other stuff as well) in v10 be compatible (i.e. checks all units on plot) if MUPT-enabled?

The game won't crash if that's what you're asking, but because so much of the AI code including the new DangerPlots relies on the getBestDefender() function instead of scrolling through all unit nodes in the plot, enabling MUPT will definitely cause AI miscalculations. The AI might think it can destroy a unit, for example, when there is actually another combat unit in the tile who will defend the first unit once it gets too damaged. Although replacing getBestDefender() with unit node loops is definitely a step in allowing the AI to handle MUPT, it isn't the only necessary step: for example, if the AI wants to kill a unit that is stacked with another combat unit, executing attacks in a certain order is important.

In other news, I've been messing around trying to implement my own version of Active AI in multiplayer, and I think I've got a good framework down, I just need to test it to make sure it works and doesn't cause unintentional side-effects before I commit it to the Experimental branch. Basically, the way it works is that whenever the AI wishes to contact a human player who has simultaneous turns, it will send a notification to that player saying "A deal has been proposed". Once the player clicks on that notification, the leaderhead scene pops up as if it were singleplayer, essentially letting the player control when they want to respond to AI diplomacy stuff. I need to test it quite thoroughly because I messed around with a lot of code that controls how AI diplomacy requests are sent, both in singleplayer and in multiplayer, and I need to make sure everything still works despite my reshuffling. If things are working fine, I'll see if I can add in localizations for "[player] wishes to contact you", which will be used for notifications about non-deal leaderhead diplomacy.
 
Top Bottom