The Civilization IV AI mod project

As an experienced programmer I recommend starting the project by shamelessly copying someone else's work.

Most of the code ever needed in a typical programming project has been written a thousand times before. This of course doesn't apply too well here since we are talking about a very unique and special project. Still it might be a good idea to look for some other open source AI development project to use as a basis.

If nothing else, it could give us a good framework to start building the cIV-specific "thinking" routines by taking care of the more mundane stuff.
 
You know, if you were really ambitious, you would write a really generic AI that acted on a set of given parameters (really many). Then, you'd randomize the parameters and play out a game between you and some AIs, pick the AIs that did the best, make a new set of AIs by altering these just slightly, and continue the process. Evolutionary algorithm. Beats me if this is not the future of real artificial intelligence. Might be a fun project. :)
 
Brain said:
@vbraun: That's a good start, but you're getting slightly ahead. Before making specific strategies we must first create a system that can evaluate the game and choose a strategy. It might sound simple but that's actually the hardest part. I'll present my ideas for this shortly.

What we really need is the code to the default AI and we could get a good idea of whats going on.

Brain said:
@Reinhard: You're correct, but some languages may be easier/more natural for the task at hand. Also, if several people are going to work on a mod it's better to agree on common language.

I think a version of C would best fit what we are trying to do. Plus alot of languages are based off of C so any one with some programming experance could help.
 
Reinhard said:
As an experienced programmer I recommend starting the project by shamelessly copying someone else's work.
Yes, it's true that doing everything from scratch is needless borring work, but we probably won't start from scratch. The AI will already be built and we're only going to add stuff on top of it to do some additional processing.

TheBB said:
Evolutionary algorithm.
I actually thought about this. The problem is that Civ strategies are too complex to represent using evolutionary methods. Another problem is that the AI would have to play thousands of games against itself before making any kind of progress.

Genetic programming can be a usefull tool for some specific parts that can be isolated and paramererized, but I wouldn't try it on a large scale.
 
vbraun said:
I think a version of C would best fit what we are trying to do. Plus alot of languages are based off of C so any one with some programming experance could help.

Why not use the C++ that the SDK will be natively written for? That way you could make best use of any example code that Firaxis gives and keep from having to translate the headers (possibly introducing errors).
 
vbraun said:
I think a version of C would best fit what we are trying to do. Plus alot of languages are based off of C so any one with some programming experance could help.

Probably pretty undoable in C, at least I can't see myself touching a non-object oriented language ever again... C++ however could be a good choice, or C# since there are very good free C# tools for Windows available.
 
warpstorm said:
Why not use the C++ that the SDK will be natively written for? That way you could make best use of any example code that Firaxis gives and keep from having to translate the headers (possibly introducing errors).
I agree. And AI is very well suited to object-oriented programming. Plus I can program C++ in my sleep. ;)

There are many other languages that could do a very good job too, some more obscure than others, but it's better to settle for one.
 
Reinhard said:
Probably pretty undoable in C, at least I can't see myself touching a non-object oriented language ever again... C++ however could be a good choice, or C# since there are very good free C# tools for Windows available.

I think it could be done in C. Remember that the Win32 API is not C++, but C.

Even though it could be done in C, I think C++ would be a better choice.
 
@Vael: Thank you for responding, Vael. You know, I'm not certain that your assertion is entirely correct--that the a-intels of these other genres do nothing more than merely react to player-actions. This seems especially true in the case of the rts. Let's take a look at the very, very old classic rts, "Starcraft," and compare one of the ai behaviors between this game and C3C. Now Starcraft may not have a great ai, but in some respects, the game demonstrates better ai and mind you it did come out years before Civ3.

Civ military units should have all the same kinds of general abilities and behaviors as Starcraft units are supposed to have. But they don't. I'm not referring to any specific ability, like the ability to cover your enemy in a mass of goo. I am talking about general stuff. For instance, both games use transports to ferry troops across gaps in land terrain. Now, let me share my observations on how the ai of these two games differ in their approaches to transporting.

By the mid-late game in Starcraft, on maps where transporting is necessary, the ai frequently attempts to rally a large and varied force at some specified site from which the force will board a fairly large number of transports that will take them to or behind your front. Btw, by varied force, I mean a nice combination of melee, ranged, and specialized units. The transports are sometimes sent to a destination outside your perimeter where they unload the entire army, at which point the amassed land units begin a combined assault. Otherwise, the fleet is sent directly into the heart of your defensive position and the army is unloaded where you are most vulnerable. After the units are diembarked, the fleet returns home where they ready a second wave if necessary. This is what the ai seems to attempt anyway.

In C3C, however, the ai most frequently uses the following tactic. The entire beach-landing assault force consists of a group of two, four, or eight ships--half of which are transports carrying just one land unit and the other half being an escort ship. Once the assault team has disembarked, the transport and escorts return home to ready another wave, thereby leaving the land units without the aid of bombardment defense from the escort ships. Furthermore, because ships take a long time to cross most bodies of water and the ai does not use any exploits, your forces are able to annihilate the invaders before the next bunch arrives.

The problem here is that unlike in Starcraft, C3C does not rally a large fleet of transports or embark more than one unit. The cost of building a large fleet may be one prohibitive cause which means that although vbraun's idea of separating the ai into components are a good idea, we shouldn't think of each branch of the ai as utterly separate. Whatever the reasons may be, I think that Civ4's ai modders could learn a lot from observing the ai of games from other genres, especially from rts's--genres which specialize in one of the many aspects Civ4 will employ.

@Brain: Brain, I apologize if you think I am hi-jacking this thread. I hope you don't mind because it seems like a related and relevant topic.
 
@Warpstorm: I know that you're a professional programmer, so I hope I didn't sound like a total idiot. But could you elaborate on what you meant by saying that rts ais' problem was that they were smarter simply because they were faster? Especially, can you explain why tb games like Civ cannot benefit?
 
No need to appologize SenJarJar. This is a discussion forum.

SenJarJar said:
You know, I'm not certain that your assertion is entirely correct--that the a-intels of these other genres do nothing more than merely react to player-actions. <snip>
It may not be obvious if you don't know how AIs work, but I can assure you that all of this is just responding to events. Something like this:

if there is any weak point exposed
find any available troops​
if shortest route to attack is by sea​
move the troups to the nearest available transport​
move the transport near the exposed area​
unload and attack​

That's why you're seeing only one troup per transport. The AI doesn't wait for trasports to fill up but just takes whatever is available and throws it at the opponent. It's all just event-response.
 
SenJarJar said:
@Warpstorm: I know that you're a professional programmer, so I hope I didn't sound like a total idiot. But could you elaborate on what you meant by saying that rts ais' problem was that they were smarter simply because they were faster? Especially, can you explain why tb games like Civ cannot benefit?
Well, I'm a professional programmer too so maybe I can help.

What Warpstorm means is that the RTS doesn't need to be smarter. It can beat the human player just because it's faster. However, this doesn't mean that RTS AIs are simpler. In fact, it's harder to make a time-constrained AI.
 
@Brain: Thank you for your responses. But if you would oblige me, can't you also say that even in tbs, ai is faster than human players, just like in rts. In terms of raw efficiency power, unless you want to beat C3C on Sid level, the ai will react "faster" than the human player: the difference between tbs and rts only being that the tbs ai is faster at a "slower" rate than the the rts ai.

What I'm trying to say is that, isn't it possible that in a paradoxical way the difference in "speed" is only in our assumption of the difference between rts and tbs?
 
Clearly I need to elaborate on above.

Just as the ai in rts can be so efficient as to shave fractions of seconds in reaction time, doesn't the tbs C3C shave numbers of turns in its ability to micromanage itself into an advantage?
 
[edit]Wow, I don't know how I posted this message three times.

@vbraun: You're of course correct in that during turns we can try to be as efficient as ai. But in C3C, I would guess that most people would refuse to micromanage such that for instance at the end of every scientific discovery, you would convert excess beakers into tax revenue. Not doing so had a way of drastically "slowing" your progress relative to the ai.
 
In a TBS game it doesn't matter how long you take to think about something so you can do more complex things (such as long term stratagy) instead of just reacting to what is happening in an RTS.
 
Brain said:
I actually thought about this. The problem is that Civ strategies are too complex to represent using evolutionary methods. Another problem is that the AI would have to play thousands of games against itself before making any kind of progress.

Genetic programming can be a usefull tool for some specific parts that can be isolated and paramererized, but I wouldn't try it on a large scale.

That's okay. It's just me visualizing the breakthrough of real AI. Your approach, however natural, just won't seem to meet my "demands" - if you could call it that. My point is that if you want to program an AI, program an AI, not just a program to carry out instructions written, more or less, in stone. That's not an AI... in my opinion. :(

Another obstacle for the evolutionary algorithm is that the thousands of test games would have to be against human opponents, not other AI too.
 
Back
Top Bottom