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).
How "Empire" AI was made?
Stellar Monarch (4X, turn based, released): GDN forum topic - Twitter - Facebook - YouTube
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:
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.
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.)
*/
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement