• Civilization 7 has been announced. For more info please check the forum here .

Don't get your hopes too high on better AI

Joined
Mar 12, 2008
Messages
606
Location
Bohemia
There is essentially no AI in civ games at all.
It is all just endless IF-THEN scripts.
People say: look they did betterAI for civ4! it got eventually included in the game.
They did amazing job. But in the end it's just more scripts
(I hope the people who did this will not take offense and understand very well what i am saying - again amazing job)

IF - enemy SoD in cultural border
THEN - city closest to SoD
- whip militra unit
- or buy military unit
- or draft military unit
- or built military unit.

it is more difficult then this, but in the end, due to game mechanics of civ4, the game "AI" feel was significantly improved.

civ5 "AI" cn play the game quite well, just as civ4 did, with exception of tactical combat.

It is my belief, that with a complicated combat system of civ5, the good "AI" feel can never be established, because it is simply extremely comlicated.....

just try yourself to make a similar AI script for the hexagonal 1upt system, where positions of units relative to each other are important, it is just too much to want from the scripts
 
I cannot imagine how that would be done.
I understand what you mean, and that's exactly what I am trying to show here.

It is not reasonable that all these people will get what they wan't: "AI" that behaves like human in this hexagonal tactical 1UPT combat.

given these limitations it just isnť possible with rreasonable time and resources
 
just try yourself to make a similar AI script for the hexagonal 1upt system, where positions of units relative to each other are important, it is just too much to want from the scripts

It's true that making an AI take into consideration the position of units relative to each other is an intensely more algorithmically-complex task than what was needed in prev civ games (e.g. civ4), but it doesn't mean it can't be done right by a competent AI programmer (something which at least 99.99% of civfanatics are not :p). The challenges for creating a civ5 AI are more significant than they were for each of the previous civ games, so I would agree with you that we're unlikely to see significantly improved AI unless Firaxis hires a dedicated, experienced AI programmer (I'm not sure who they have currently, but I suspect not an AI expert).

IMO the problem is that even if it can be done, the cost to the end-user of longer turn times could just make an improved AI an unattractive goal anyway. This is only speculation on my part.

In any case, once the C++ sdk is released, AI enthusiasts will be free to add to or modify the code to their desire. That is when you will see the big improvements.
 
yes, when I posted, that noobs have contradicting desires (better "AI" x faster turn times), they just laughed me off.

I belive this overrelyance on voluntarilly moders has gonne out of hand.
if it's really the case, i will just play games 2 years post release and start by asking what mods to get in the forums.

Also maybe even the moddders won't be able to significantly improve the tactical AI.
really just trying to think about how it could be done to remble human a bit makes me dizzy
 
There is essentially no AI in civ games at all.
It is all just endless IF-THEN scripts.

Isn't that what most, if not all, strategy game AI is? It's all I was expecting. They obviously need to keep adding if/then scripts for a much wider range of scenarios than they have at this point and, in doing so, my hopes for better (far from perfect, mind you) AI will be realized.
 
Isn't that what most, if not all, strategy game AI is?

More, that's what programming is. That's also what real intelligence is (or should be).
And that's also the same with what the computer Watson won at Jeopardy.

-> pointless point (the original one i mean)
 
Isn't that what most, if not all, strategy game AI is? It's all I was expecting. They obviously need to keep adding if/then scripts for a much wider range of scenarios than they have at this point and, in doing so, my hopes for better (far from perfect, mind you) AI will be realized.

Nope!

Many of them are switch statements!

Also there's way more to it than just IF THEN.

Many of the functions in the Civ4 AI SDK are weight checking functions. They assess the existing situation, assign weights based on the results to potential actions, possibly add a small error term (minor randomization is a key element in ensuring that the CPU doesn't do the same thing every time) and then selects the "heaviest" element as the course of action.

Which unit should it build? Check force composition, check garrison status, check war planner needs, check for unit which best fits these needs.

I don't do AI stuff for a living (bandwidth, baby, big ol' pipes!), but you can easily grab the Civ4 SDK and see for yourself that these aren't a bunch of static scripts. Or you could just play the game; notice how the computer doesn't do the same thing at the same time every time? That would be how you know!
 
More, that's what programming is. That's also what real intelligence is (or should be).
And that's also the same with what the computer Watson won at Jeopardy.

-> pointless point (the original one i mean)

Though I'm no programmer, that's kind of what I thought. A lot of elements of programming are covered up by UI's that aim at being user friendly, but under the hood, it's all if/then statements. Claiming that all it's going to be is more if/then statements is... Well, yeah, we know. I think they just need to add more if/then conditions and refine the way they interact so they don't conflict in gameplay - it'll take a lot of continual polishing and it'll always be imperfect, but, I can't imagine it doing anything but improving.
 
More, that's what programming is. That's also what real intelligence is (or should be).
And that's also the same with what the computer Watson won at Jeopardy.

-> pointless point (the original one i mean)

What are you, insane? What do you do in a situation where you have no prior experience?

If (noInfo) {
sh@t self}

Nope! You attempt to establish the relationship between the current situation and any and all prior situations that may be similar. Your (infinitely more intelligent) subconscious uses what us folks who studied statistics call a Bayesian inference to puzzle out the most suitable response.

That's what real intelligence is, reacting appropriately to situations as they emerge and change in response to the environment and the actions of other players. Not dogmatic responses to set in stone criteria.

It's also infinitely less time consuming and irritating than writing a hundreds of thousands of lines of code for each situation where the inputs are slightly different than an existing script.


edit: Dear lord you kids need to spend some time with the Civ4 SDK. Or in a math class.
 
There is essentially no AI in civ games at all.
It is all just endless IF-THEN scripts.

You are correct- it is impossible to create a perfectly human-like AI using if-then structures, mainly because our brain is much more complex than that. As a result, an AI programmer attempts not to create an AI which is capable of developing innovative solutions to a problem (as the human does when playing Civ 5) but rather to program the AI to recognize a wide variety of situations that arise during gameplay and program it to respond in a specific way depending on the situation. For example, here's a situation that tells ranged units to run away from enemy melee units (the actual program is obviously more complex than this):

if (getRangeOfUnit(currentUnit) > 1) {...................................................//if the current unit is a ranged unit
....for (n = 0; n < 7; n++) {................................................................//checks all adjacent 6 tiles
........if (getRangeOfUnit(getEnemyUnitInAdjacentTile(n)) == 1) {.............//if there is a melee unit in adjacent tile (meele range is 1)
............currentUnit.fleeFromUnit(getEnemyUnitInAdjacentTile(n));............//calls the aptly-titled "flee" member function
........}
....}
}

If a sufficient amount of "situations" are taught to the AI, it can cover, say, 97% of all situations which can arise in Civ 5 - an almost perfect amount. The

Unfortunately, the advent of 1upt makes the number of possible situations huge, and Firaxis did not have the time or talent to program a response for all of these situations. Hence the AI failure. (I must say, however, that I am STUNNED that Firaxis did not implement something like the mini-faux-program that I wrote. How hard would it be to implement something like this?)

So overall, my point is that no amount of if-then statements can not simulate the human brain, but with plenty of programming it can come somewhat close.
 
yes failing positronic brains we are stuck with simple heuristic algorithms with flavour weight factors and bunches of if ... then ... else.. statement

the ai will be gradually improved via adding more and more if this then do that statements until it reach that lofty state where it is not obviously suicidal. That's about as much as anyone can ask for from an ai from a commerical title selling for $50 a pop
 
Nope!

Many of them are switch statements!

Also there's way more to it than just IF THEN.

Many of the functions in the Civ4 AI SDK are weight checking functions. They assess the existing situation, assign weights based on the results to potential actions, possibly add a small error term (minor randomization is a key element in ensuring that the CPU doesn't do the same thing every time) and then selects the "heaviest" element as the course of action.

Which unit should it build? Check force composition, check garrison status, check war planner needs, check for unit which best fits these needs.

I don't do AI stuff for a living (bandwidth, baby, big ol' pipes!), but you can easily grab the Civ4 SDK and see for yourself that these aren't a bunch of static scripts. Or you could just play the game; notice how the computer doesn't do the same thing at the same time every time? That would be how you know!


Everything that you just stated is based on if-then. Switch statements are based on if then. So is weighting.
 
What are you, insane? What do you do in a situation where you have no prior experience?

If (noInfo) {
sh@t self}

Nope! You attempt to establish the relationship between the current situation and any and all prior situations that may be similar. Your (infinitely more intelligent) subconscious uses what us folks who studied statistics call a Bayesian inference to puzzle out the most suitable response.

edit: Dear lord you kids need to spend some time with the Civ4 SDK. Or in a math class.

Apparently they didn't teach you in your statistics class that calling someone "insane" during a mature discussion is probably not a good idea.
 
I think the point of the OP was not that the AI cannot be good because it only consists of IF THEN algorithms but that it cannot be good because Civ 5 combat is too complicated to actually make these IF THEN algorithms good enough.

I don't agree there, it all depends on programming and computing power.

But I do agree that the AI will never be good, simply for the reason that it would cost money to program it and they will not spend that money. After all they already got ours and most reviewers don't care about AI anyway as long as the game looks nice.
 
What are you, insane? What do you do in a situation where you have no prior experience?

If (noInfo) {
sh@t self}

Nope! You attempt to establish the relationship between the current situation and any and all prior situations that may be similar. Your (infinitely more intelligent) subconscious uses what us folks who studied statistics call a Bayesian inference to puzzle out the most suitable response.

That's what real intelligence is, reacting appropriately to situations as they emerge and change in response to the environment and the actions of other players. Not dogmatic responses to set in stone criteria.

It's also infinitely less time consuming and irritating than writing a hundreds of thousands of lines of code for each situation where the inputs are slightly different than an existing script.


edit: Dear lord you kids need to spend some time with the Civ4 SDK. Or in a math class.

I've just read through your two posts and here are my thoughts.

All you've really described is a situation of, if no information, then compare current data to previous instances looking for connection. If current situation bears similarity to previous situation, then data from previous situation is relevant to current. If data from previous situation suggests doing X, currently do X.

Add to this as many further if/then clauses as you want taking other sources into account , and you've built up a somewhat sophisticated system of A/B/C formally accountable deductive reasoning - as in, a complex succession of if/then statements which allows you to start from a variable position X, and apply weight to various possible responses, leading to an ultimate if/then of "if position X, perform action that has been assigned the most weight." You haven't got us out of an if/then procession, you've just shown that if/then situation can become increasingly complex.

Now, you brought up "Bayesian inference." Never dealt with it before - again, I'm no statistics/math guy - but I just did a bit of reading on it. It seems (at the base) to be a method of inference based on prior statistical probability with the intent of assigning weights to various potential probabilities... Of course, why do you assign probability weights to various possible courses of action/etc? In order to plug them into an if/then formula and come out with a course of action. I may be reading it wrong - and if I am, please feel free to correct me, and I'd appreciate it if you could explain how - but Bayesian inference seems like an inferential tool used to examine data and assign probabilistic weights to things. I don't see how this gets us out of the if/then deductive framework though - it's just a way to feed relevant information precisely into that framework.

And what's more, responding to my post, you informed us that they're not if/then statements, and rather "many of them are switch statements!"

Again, I'm no programmer, but I just looked up what a switch statement was... You talk like you know a lot on the subject (unlike us "kids") so perhaps you can correct me if I'm reading all this the wrong (again). It seems to me like it's just a programming method of compounding multiple if/then statements into a single coding structure so as to save code redundancies.

"In computer programming, a switch, case, select or inspect statement is a type of selection control mechanism ... Its purpose is to allow the value of a variable or expression to control the flow of program execution via a multiway branch (or "goto", one of several labels). The main reasons for using a switch include improving clarity, by reducing otherwise repetitive coding, and (if the heuristics permit) also offering the potential for faster execution through easier compiler optimization in many cases."

http://en.wikipedia.org/wiki/Switch_statement

Doesn't that just describe a method of compounding multiple if/then statements into a "multiway branch," and in doing so, turn multiple if/then statements into a single unified statement that performs the function of all at once?

My apologies for the delay in responding, but name dropping doesn't make you more right, particularly when your audience isn't educated in whatever area you're coming from - it just means that other reasonably intelligent parties are going to be stuck trying to unpack the meaning behind the names before they can possibly respond. That is, if they aren't just intimidated by the dropped names ("oh, that guy knows WAY more than me!") - which I often think is the reason people start name dropping in the first place.

Personally, I've got a Masters in continental European philosophy and am working on my PhD (thesis examining conflicting presentations of weight in Nietzschean philosophy [heaviness/lightness, the spirit of gravity, dance, etc]) - though admittedly, thinking I'll be switching over to literature as I've been working on projects comparing the Taoist notion of the sage to Rousseau's noble savage and arguing that Nietzschean philosophy is a *huge* influence in the poetry of Josh Malihabadi, and that Josh is an important figure in a comprehensive study of intra-culture existential philosophy. If there's one thing hanging around this and several other forums has taught me though, even if I'm reasonably well educated and reasonably intelligent, there are people here who are more educated, more well read, and outright more intelligent than I am - any combination of the three. Assuming that you're *ever* talking to just "kids," particularly around an erudite forum like this history-buff strategy-nut gathering place, is really, really presumptuous on your part. It's obvious you have some knowledge which most of us (myself included) don't, so share it in debate - right now, you're coming off as the know-it-all kid who took the class someone else hasn't.

But anyways, the OP says "we'll never get beyond if/then statements in Civ AI, so don't get your hopes up!" I found that statement a bit iffy because, in contemporary philosophical debate, there's no agreement that ANY intelligence is more than increasingly complex systems of if/then formulas acting upon presented data, that all seemingly analog systems of decision making are in fact just extremely complex networks of if/then binaries. If that IS the case - and it's certainly not clear that it's not - hoping for more than if/then statements from artificial intelligence seems a bit of a stretch, since that's what even human intelligence boils down to.

Well, I've wasted my posting time for the day. Must get back to real work :p
 
I think the point of the OP was not that the AI cannot be good because it only consists of IF THEN algorithms but that it cannot be good because Civ 5 combat is too complicated to actually make these IF THEN algorithms good enough.

I don't agree there, it all depends on programming and computing power.

But I do agree that the AI will never be good, simply for the reason that it would cost money to program it and they will not spend that money. After all they already got ours and most reviewers don't care about AI anyway as long as the game looks nice.

this.
 
Though I'm no programmer, that's kind of what I thought. A lot of elements of programming are covered up by UI's that aim at being user friendly, but under the hood, it's all if/then statements. Claiming that all it's going to be is more if/then statements is... Well, yeah, we know. I think they just need to add more if/then conditions and refine the way they interact so they don't conflict in gameplay - it'll take a lot of continual polishing and it'll always be imperfect, but, I can't imagine it doing anything but improving.

You're even more right than you might think ;).
UI is a "science" itself, because hiding the complicated stuff for "normal" users is essential, but the core still has to work. And that's the part which has to get improved here (besides that TMIT would disagree and would tell us the UI also needs to get improved :D).

What are you, insane? What do you do in a situation where you have no prior experience?

If (noInfo) {
sh@t self}

Nope! You attempt to establish the relationship between the current situation and any and all prior situations that may be similar. [...]

That's what real intelligence is, reacting appropriately to situations as they emerge and change in response to the environment and the actions of other players. Not dogmatic responses to set in stone criteria.

[...]

edit: Dear lord you kids need to spend some time with the Civ4 SDK. Or in a math class.

Math? The situation here is about logic ;).
And i knew i should have explained it more :p.
What i meant that (what you sure know because how i see you're talking here) computers have undoubtable advantages compared to humans, e.g. the flawless (theoretically, unless hardware defect) logic and memory. That doesn't contradict that humans have advantages in other areas, like what you mentioned associative things and incorporation of new data into existing systems.
The essence what i wanted to say: We would have less problems if all people were in the same way able to use logic like computers. Would lead to less conflicts.

I think the point of the OP was not that the AI cannot be good because it only consists of IF THEN algorithms but that it cannot be good because Civ 5 combat is too complicated to actually make these IF THEN algorithms good enough.

I don't agree there, it all depends on programming and computing power.

I think the current computers should be able to handle a minimum intelligent AI for Civ5 in a reasonable time.
But i guess this AI is what people are complaining about :D.
 
Personally, I've got a Masters in continental European philosophy and am working on my PhD (thesis examining conflicting presentations of weight in Nietzschean philosophy [heaviness/lightness, the spirit of gravity, dance, etc])

As someone with a Masters in Computer Science, I can confirm essentially everything you said. "Switch" or "Case" is just a fancy way of saying "If X then do A else if Y then do B else if C then do Z etc.."

Every computer program doing anything more complex than performing math that is handled natively by the CPU does, essentially, boil down to a series of If/Then statements, possibly with some loops involved. The variance lies in the sophistication of the program - how many layers of nesting = how deep the decision tree is - and the quality of the input. In theory, it could have been written in a high language that supports a more elegant representation, but that's merely masking the truth of how it will work in machine code. (Test register. Is value X? Go to code block A.)

One can argue that the Civ V AI could use more layers and/or better-quality input, but it will STILL be a series of If/Then statements. Or it will be a linear program that always performs the exact same tasks regardless of inputs. To argue that an AI cannot be represented by If/Then statements is, frankly, laughable.
 
Well, take it from a real coder.

Arrays contain so much parametric conditional statements that even whiles & constants aren't enough to fill the True AI definition.
If you're lowering the algorithms to an IF-THEN loop, you have absolutely no idea what nodes are.

It's not the amount of cycles a CPU can endure but rather if the stack slots are handled correctly in the dispatched routines and if some key functions applied in a variety of presets can modify decisions or reactions.
Flavors are just the tip of a huge iceberg that hides the fundamental mechanic behind any specific AIs - all of which stuck in arrays with at least 4 dimensional factors. The first being just the ruleset.
 
Top Bottom