# How "Empire" AI was made?

This topic is 2593 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I wonder how the old classic Empire game AI was made http://en.wikipedia.org/wiki/Classic_Empire_%28computer_game%29 Take a note that it was made in 1977, so the hardware limitations were severe then, so it probably was using some nice tricks worth learning...

To people not familiar with the game, it is like the predecessor of Civilization. There is a map (grid), with cities and units moving on it. There is land and water (land units move on land, sea units move on water, air units move on both). Each city can produce one unit at a time. The game is played in turns.

If you don't know this one but know how similar games work, post too (but I would want to exclude all "overly right" games like FreeCiv where they spend a huge amount of time to polish the AI, I'm more interested in learning the dirty hacks that you use when writing AI for such games when you are limited by time and resources).

##### Share on other sites
on the wiki page there is a link to an open source version: link .The compmove file, i think, has all the ai. After a quick glance it seems to be nicely documented.
I'm just copying now:

/* compmove.c -- Make a move for the computer. For each move the user wants us to make, we do the following: 1) Handle city production; 2) Move computer's pieces; 3) Check to see if the game is over. */

/* Handle city production. First, we set production for new cities. Then we produce new pieces. After producing a piece, we will see if we should change our production. Our goals for city production are first, not to change production while something is in the process of being built. Second, we attempt to have enough city producing armies on a continent to counter any threat on the continent, and to adequately explore and control the continent. Third, we attempt to always have at least one transport producer. Fourth, we attempt to maintain a good ratio between the number of producers we have of each type of piece. Fifth, we never build carriers, as we don't have a good strategy for moving these. */

the city production is regulated by how many cities the computer has, if very few(i.e. beginning of the game) it produces a lot of armies and transports for exploration, later it adds ships and fighters and so on. There is a table of ratios for each of the phases.

/* Move an army. This is a multi-step algorithm: 1) See if there is an object we can attack immediately. If so, attack it. 2) Look for the nearest land objective. 3) If we find an objective reachable by land, figure out how far away that objective is. Based on the found objective, also figure out how close a loadable tt must be to be of interest. If the objective is closer than the tt must be, head towards the objective. 4) Otherwise, look for the nearest loading tt (or tt producing city). If the nearest loading tt is farther than our land objective, head towards the land objective. 5) Otherwise, head for the tt. 6) If we still have no destination and we are in a city, attempt to leave the city. 7) Once we have a destination, find the best move toward that destination. (If there is no destination, sit around and wait.) */

##### Share on other sites

on the wiki page there is a link to an open source version: link .The compmove file, i think, has all the ai. After a quick glance it seems to be nicely documented.
I'm just copying now:

/* compmove.c -- Make a move for the computer. For each move the user wants us to make, we do the following: 1) Handle city production; 2) Move computer's pieces; 3) Check to see if the game is over. */

/* Handle city production. First, we set production for new cities. Then we produce new pieces. After producing a piece, we will see if we should change our production. Our goals for city production are first, not to change production while something is in the process of being built. Second, we attempt to have enough city producing armies on a continent to counter any threat on the continent, and to adequately explore and control the continent. Third, we attempt to always have at least one transport producer. Fourth, we attempt to maintain a good ratio between the number of producers we have of each type of piece. Fifth, we never build carriers, as we don't have a good strategy for moving these. */

the city production is regulated by how many cities the computer has, if very few(i.e. beginning of the game) it produces a lot of armies and transports for exploration, later it adds ships and fighters and so on. There is a table of ratios for each of the phases.

/* Move an army. This is a multi-step algorithm: 1) See if there is an object we can attack immediately. If so, attack it. 2) Look for the nearest land objective. 3) If we find an objective reachable by land, figure out how far away that objective is. Based on the found objective, also figure out how close a loadable tt must be to be of interest. If the objective is closer than the tt must be, head towards the objective. 4) Otherwise, look for the nearest loading tt (or tt producing city). If the nearest loading tt is farther than our land objective, head towards the land objective. 5) Otherwise, head for the tt. 6) If we still have no destination and we are in a city, attempt to leave the city. 7) Once we have a destination, find the best move toward that destination. (If there is no destination, sit around and wait.) */

That was the worst explained explanation of AI I've ever heard in my life.

##### Share on other sites

That was the worst explained explanation of AI I've ever heard in my life.

How about, instead of making useless snide remarks, you provide a better explanation instead?

• 22
• 10
• 19
• 15
• 14