[AI Design] The basics

Past public reviews and discussions.
Message
Author
Crimson Rider
Krill Swarm
Posts: 12
Joined: Wed Jul 16, 2003 8:06 am
Location: The Netherlands

[AI Design] The basics

#1 Post by Crimson Rider »

Time to restart the AI design.

Here goes nothing.

I am in charge of the AI it seems. Cool, can someone add my name to the sourceforge list and can someone give me a list of the other people that want to work on the AI.

I propose the division of the AI into seperate parts. I've already written a partial design for the fleet/military AI. I am trying to recover that document.

But for now, we will have to start over from basicly scratch. I am going to make a few very broad descriptions and then we will discuss from that. Based on that I will write up a design, based on that design we will start to program the AI part by part. If nobody objects anymore, we are using C++ to code the AI in.

The AI, at start, will be mostly seperate from the actual program itself. This is to facilitate testing and simulation. Also, the concepts used in the programming of the AI will be very different from the ones used in the programming of an 4/5X game. We already had the confusion about AI and game universe on the last forums. No need to repeat that. This also means that there, eventually must be written an interface that will make it possible for the AI to affect the game and also read information from it.

More in the next post.
Crimson Rider takes out a purse and carefully picks two coins. With an elegant move he tosses them on the table. A slight smile is upon his face as he points at them and says : "Those are mine"

Crimson Rider
Krill Swarm
Posts: 12
Joined: Wed Jul 16, 2003 8:06 am
Location: The Netherlands

#2 Post by Crimson Rider »

AI Model

The AI, or rather all the AI's will consists of individual modules, these modules will read and write data to and from the AI universe, thus affecting the world around them. This affection of the world is the only way they can change anything.

For example, if an AI at some level needs more ships to defend a system, it doesn't directly request such ships from an other AI, but rather it changes a state in the AI universe so that it states that in system X, Y ships are needed. Another AI sees this change and can, or can not send those ships. But direct communication between this AI is never taking place. Altough often it will seem that it is.

This will facilitate the complete division of individual AI modules, they need not be aware of each other. Only to be aware of the universe they can see and write to.
Crimson Rider takes out a purse and carefully picks two coins. With an elegant move he tosses them on the table. A slight smile is upon his face as he points at them and says : "Those are mine"

Tyreth
FreeOrion Lead Emeritus
Posts: 885
Joined: Thu Jun 26, 2003 6:23 am
Location: Australia

#3 Post by Tyreth »

When you say C++ for the AI, what do you mean? I'm still very much wanting the AI to be done in python according to our earlier decision. Some parts of this will be done in C++ to expose the AI code/API to python.

I intend to learn python sometime in the near future to help this happen. I want our game to be flexible, and putting the entire AI in C++ is not going to help that goal as much as using python.

I'm going to see if I can locate that gamasutra article that was posted on the old forums. Anyway, I'd appreciate hearing what your thoughts regarding C++ were.

Crimson Rider
Krill Swarm
Posts: 12
Joined: Wed Jul 16, 2003 8:06 am
Location: The Netherlands

#4 Post by Crimson Rider »

Empire AI

At the highest level of the AI, meaning in authority for human logic. Is the Empire AI. This AI consists of various entities, each with their own area of expertise. These entities are very broad, and can only change things on a very broad scale.

Examples of these entities are:

Leader, can set such globals as who is at war with the empire.

Military, can set such globals as what kind of military contructions should be build and what systems should be attacked.

Science, can set such globals as what to research and what to apply.

These are of course mere examples, and they are interactive.

Meaning, if the military AI put forward a request that empire wide tanks should be build, then science might initiate tank research.

For now, the following AI have been tought up by me

OverMind Leader
IronBeard Military
PointDexter Science
OutSource Foreign
HomeStead Domestic
Crimson Rider takes out a purse and carefully picks two coins. With an elegant move he tosses them on the table. A slight smile is upon his face as he points at them and says : "Those are mine"

Crimson Rider
Krill Swarm
Posts: 12
Joined: Wed Jul 16, 2003 8:06 am
Location: The Netherlands

#5 Post by Crimson Rider »

I tought it was up to me wether to use Python or not ?

Anyway, I am very open to discussion about the topic wether to use Python or C++ or both. But rather not in a design thread.

Very basicly my reason for preferring C++ for now, is that I already know it and thus can come up with some basic code relativly fast that way.

If the other members of the AI team (who ever they are :) ) want to do Python, we need to discuss that.
Crimson Rider takes out a purse and carefully picks two coins. With an elegant move he tosses them on the table. A slight smile is upon his face as he points at them and says : "Those are mine"

elfstone
Space Squid
Posts: 78
Joined: Fri Jun 27, 2003 9:00 am
Location: Germany

#6 Post by elfstone »

I'd like to see a self-learning AI sometime in the future. I know this is a little too much for the beginning, but maybe we should talk about this now, so the concepts will allow this to be added later.

It would be nice, if the player could save a demo of his game, so that all actions he made a saved to a file. The AI could take all files of Player A and look at what his weaknesses are, and what potentiall errors he made. Then the AI could try and exploit the mistakes he made. The Player gets a much more challenging gameplay after he plays some times with the same strategy, so he has either change the strategy or improve it to a point the AI doesn't see the mistakes.

There should be lots of changable variables that influence the behaviour of the overall AI, like values for:
different techs
how fast it expands
how much ships it builds
how big the ships are/what kind of ships

and so on... Those variables could be changed every other game, and the results stored somewhere. After playing some games, the AI learns, that this variable should be very high, and the other one about 5.
Maybe these files can be shared with others, so the AI will not only learn from one player, but from thousands of player simultaneus (spelled wrong, i know).

drekmonger
Space Kraken
Posts: 146
Joined: Mon Jul 07, 2003 10:17 am

#7 Post by drekmonger »

Genetic algorithms, neural nets, and other "self-learning" programs work best on small, well defined problems. There reason why self-learning programs aren't used more often in commercial games is that they simply aren't very good at solving the divergent set of problems in a modern strategy game.

That said, as Tyreth as said all along, it would be nice to expose some sort of API for scripts to interact with. The attempt to conjure a self-learning AI for FreeOrion would be a nice project for a CS or EE graduate student. (or at very least a subset of the AI, for example growing an AI to handle resource production or diplomacy).

Thumper
Space Kraken
Posts: 131
Joined: Sun Jul 06, 2003 3:48 am

#8 Post by Thumper »

Interesting ... A SMART AI!

Now if you were to use something like the Build Queue Managers that I'm proposing the AI could use the same script file for the AI races as the player. In SP games, say Hard to Impossible, you'd be playing against what you consider the best game setup. In Impossible the AI opponents would be given certain other advantages.

Thumper

Nightfish
FreeOrion Designer / Space Monster
Posts: 313
Joined: Thu Jun 26, 2003 7:07 am

#9 Post by Nightfish »

We don't need to use a scripted build queue manager to have the AI develop colonies in the same way the player does. There several other ways to achieve that goal.

Crimson Rider
Krill Swarm
Posts: 12
Joined: Wed Jul 16, 2003 8:06 am
Location: The Netherlands

#10 Post by Crimson Rider »

I am very much against scripted AI. It is not really AI, but a recipe.

I am planning to include some sort of genetic AI into the code. But that design is for a later stage.

Right now the first prioiry is to have a somewhat working general AI, I am working on a very basic unit now, it's what you might call a cybernetic AI.
Crimson Rider takes out a purse and carefully picks two coins. With an elegant move he tosses them on the table. A slight smile is upon his face as he points at them and says : "Those are mine"

FluffyKittens
Space Krill
Posts: 6
Joined: Tue Jul 22, 2003 6:40 pm
Location: UK

A.I - situational awareness, planning and feedback.

#11 Post by FluffyKittens »

What I think the A.I needs is some degree of situational awareness and feedback loop.

Most games use simple speedup bonus's to make the A.I harder, i.e. 20% production bonus, 15% faster research bonus etc... Ship designs are normally percentages as well i.e. 30% of ships space fill with missiles, 30% with beam weapons, 10%ECM, etc...

Game A.I's therefore typically deploy poor campaign strategies and combat strategies against opponents. The game A.I has no sense of threats, strengths, weaknesses, or ‘prediction’ of future situations and therefore cannot plan effectively. (I know A.I’s usually do use some basic stats to assess threat / strength i.e. number of ships, researched techs, colonies, population etc.)

If at war are we winning? Who is attacking us the most or more important succeeding the most? What technologies are they relying on? Do we need to concentrate more on building ships? Or should we apply all our resources into gaining a particular tech over the next few turns (can we research it? Trade for it? Or risk stealing it?).

In Moo2 a player looks at what the opponent is sending against them and adapts there designs. E.g. If opponent is relying on missiles, use more point defence weapons and research lightning field. If weapons are shield piecing use triple armour and reinforced hull. In moo2 you could use spy’s to get a report on all the techs an opponent had researched and research techs to counter, or try and steal the tech.

Side note: (In moo2 the tech tree was excellent, key technologies could swing battles, change the out comes of war, and the techs were diverse enough that one could come up with new designs / strategies to better the opponent, their was no single design to beat all, and therefore you could have less ships but still win a war.) (Some technologies were major jumps in the tech race and in combination with other techs provided significant advantages for limited periods of time.)

Now I’m NOT saying we have to make a self aware conscious entity (the next H.A.L), however better A.I can be achieved by giving the A.I the ability to measure or assess aspects of the game, predict future outcomes, and provide some sort of ‘feedback’ mechanism.

E.g. (Threat from other opponents?) What techs do opponents have, ‘rate of change’ of opponent ship building (are they preparing for war?), rate of research (are they trying to rush ahead?), design of opponent ships (change our designs we don’t want to be producing in-effective designs), race abilities (e.g. are they good at ground combat, do we need tech to offset this?)

E.g. (Plan to attack an opponent?) Time till attack?(attack in 15 turn? Or opportunistic?), build ships to counter opponent designs, research tech needed, increase ship production, attack key production planets first, defend our key planets.

E.g. (Feedback) do new ship designs do more damage to enemy ships of (x) design? Ratio of ships we are losing in battle compared to them, estimate enemy strength based on performance rather than numbers. Are we winning war? Can we win war?

How do we do this?
Short term planning and long term planning of goals?
Feedback metrics, did last decision improve situation? Improve our position?
Allow A.I to test ship designs by simulating combat during game turns?
Use relational database, of game properties / strategies e.g. counter heavy use of missiles with tech x,y,z and strategies a,b,c.
Fill this database with cunning strategies supplied by us and players!!!

This is just all food for thought! So don’t grill me!

PS: Sorry I whaffled a bit on this one.
"If you can't explain it simply, you don't understand it well enough." :Albert Einstein

elfstone
Space Squid
Posts: 78
Joined: Fri Jun 27, 2003 9:00 am
Location: Germany

#12 Post by elfstone »

with self-learning i didnt mean totally self learning, but there are some variables, that influence on how fast your empire grow, and if a player always attacks after round 150 the ai could use this knowledge of past games and doesnt have to spend anything in defense till round 130 and could develop much faster this way.

Crimson Rider
Krill Swarm
Posts: 12
Joined: Wed Jul 16, 2003 8:06 am
Location: The Netherlands

#13 Post by Crimson Rider »

basicly i plan to use genetics to some degree, most simply said, if an AI did well or won, the aspects that it used are going to be used again.

But that is all much to far away, right now we need to focus on very basic things, much more boring I know, but very important.

Things as simple as this one for instance :
Diplomatic AI

Is dependent of a variety of functions.

First task, to make it respond, responses are for now.

Positive I like you
Neutral I don't care
Negative I don't like you

It will work out this very basic response from 2 factors.

History
Did I like you before

Military
How strong are you
How strong am I
This is quoted right from my todo list, and yes, the first steps will be this shockingly simple. Well simple to write down, not simle to make.
Crimson Rider takes out a purse and carefully picks two coins. With an elegant move he tosses them on the table. A slight smile is upon his face as he points at them and says : "Those are mine"

OceanMachine
Pupating Mass
Posts: 95
Joined: Thu Jun 26, 2003 12:09 pm
Location: Chicago

#14 Post by OceanMachine »

Crimson Rider wrote:basicly i plan to use genetics to some degree, most simply said, if an AI did well or won, the aspects that it used are going to be used again.

But that is all much to far away, right now we need to focus on very basic things, much more boring I know, but very important.

Things as simple as this one for instance :
Even that much is somewhat premature. There is no diplomacy for v0.1. As far as I can tell things break into three modules for this release:

1. Exploration and colonization. Use some basic algorithms to determine next system to explore and next system to colonize.
2. Management of production. Try to match up colony needs and production capacities with empire level goals to make build selections.
3. Strategic fleet management. Manage fleet to attack enemy systems and defend against enemy attacks.

Part 1 should be fairly trivial. Part 2, a bit more complicated, but not terribly difficult. Part 3 could prove quite challenging...
Programming Lead

Crimson Rider
Krill Swarm
Posts: 12
Joined: Wed Jul 16, 2003 8:06 am
Location: The Netherlands

#15 Post by Crimson Rider »

Actually non of the parts are trivial.

Basic exploration is not that simple even. Altough it can be made simple. As long as it has one scout for instance.

But that part was just pasted from my todo list anyways.
Crimson Rider takes out a purse and carefully picks two coins. With an elegant move he tosses them on the table. A slight smile is upon his face as he points at them and says : "Those are mine"

Locked