Sign in to follow this  
Acharis

How "Empire" AI was made?

Recommended Posts

Acharis    5979
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 this post


Link to post
Share on other sites
frederiksen    119
on the wiki page there is a link to an open source version: [url="http://freshmeat.net/projects/vms-empire/"]link[/url] .The compmove file, i think, has all the ai. After a quick glance it seems to be nicely documented.
I'm just copying now:

[code]/*
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.
*/[/code]


[code]/*
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.
*/[/code]

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.

[code]/*
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.)
*/[/code]

Share this post


Link to post
Share on other sites
AndyHarglesis    202
[quote name='frederiksen' timestamp='1302363943' post='4796381']
on the wiki page there is a link to an open source version: [url="http://freshmeat.net/projects/vms-empire/"]link[/url] .The compmove file, i think, has all the ai. After a quick glance it seems to be nicely documented.
I'm just copying now:

[code]/*
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.
*/[/code]


[code]/*
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.
*/[/code]

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.

[code]/*
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.)
*/[/code]
[/quote]

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

Share this post


Link to post
Share on other sites
issch    479
[quote name='AndyWonHarglesis' timestamp='1302993616' post='4799285']
That was the worst explained explanation of AI I've ever heard in my life.
[/quote]
How about, instead of making useless snide remarks, you provide a better explanation instead?


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this