PBWorks

From BotF2-Wiki
Jump to: navigation, search

Parts from http://supremacy.pbworks.com/w/browse/#view=ViewAllObjects (done in 2007 and before, might be out of date)

Artificial Intelligence in BOTFII

       Artificial Intelligence in BOTFII
   Introduction
   Core Ideas
   AI Techniques
   Major Races
   Minor Races
   Precedence and Hierarchy

Introduction

Core Ideas

Fitness Measure

Ships having two sets of instruction, one hard coded the other dynamic

AI Techniques

   Finite State Machines
   Fuzzy Logic
   Neural Networks
   Genetic Algorithms
   Bayesian Inference and Networks - Ship battles

Major Races

Buildings and Structures

Major Races need to be able to adapt to changing circumstances but also not always be dictated by them otherwise nothing would get built. Having two build queues one for ships and the other for structures helps alliviate some of these problems. However some constraints should be adhered to, for example food structures should take precedence in order for the colony not to starve, as well as energy structures when needed. Special structures should be built when researched and then comes the balance of industry, research and espionage.


Should there be Planet and Race specific criteria for building structures. For example should the Romulans focus on buliding more intel centres? and should the AI be intelligent enough to have specific planets with centres of research or large numbers of industry or just have every planet averaged out.


Finite state machines could prove useful in covering the wide range of actions a Planets build cycle could face over the duration of a game. A predefined Database which is perhaps race specific could hold values for which the state machine could use to decide what to build and when. However it could get bulky and most likely can't be adapted or evolved during game play.

Ship Building

Complex to say the least. The AI needs to be dynamic enough to adapt to differant needs at differant stages of the game, from balancing exploration, colonization, war and economics which can change throughout a games lifetime. To begin with the AI will or should start off like any other player if possible, like any player it will explore, and colonize to begin with as the likelyhood of attack is low. Perhaps a set of hard coded instructions to begin with could be beneficial. For example a ship list consisting of 4 scouts, 2 surveyors a colony ship and transport to begin construction during the first few turns.


How should the AI decide when to build and what to build? considering there doens't seem to be much of a penalty in the number of ships bar money keeping a small sized "Navy" isn't going to be necessary for the AI. In times of peace perhaps it would be best to explore and colonize whlie slowly accumulating ships and scrapping older designs while replacing them with newer ones. If at all possible though no doubt hard the AI should be able to forsee events and prepare for them, generally preparing for War. Normally this can be done by having the AI able to cheat and Know both the number of ships the enemy has and perhaps the relationship towards the AI. However if at all possible having this taken from ingame intel actually gathered by the AI would be a bonus though hard.


Should the balance between colonization and Warship buliding be hardcoded or dynamic and affected by the game. For example it can be hardcoded beforehand into the AI what inputs from the "Environment" trigger what to build. This can be a number accumualted from various sources ie race relations, Ship numbers and Ship types available, differances in technology between Ships built and ship designs available.


A dynamic system would be more artificial intelligence in design, with inputs from the environment still the deciding factor but there output not always the same. For example the effect certain inputs have change with regards to the results of previous runs. Input/Output configurations that give rise to Good results, ie result in good exploration/colonization or perhaps sufficient sized fleets are kept and reinforced. This is a Higher AI so is doubtful to be implemeted any time soon.


Where to build the ships, should be simple enough to begin with, considering the fidelity in the types of shipyards and there availability, ship building should be concentrated on those systems with suitable industry at first. More complex issues such as positioning, availability of training etc can be added later.


What type to build? should the AI be able to descern information gleened from previous battles won or lost.


To begin with a simple system probably based upon size of empire, economics and various other factors such as number of enemies and there ship numbers can help descern the size. The compliment could also just be a simple predefined ratio of scouts/light cruiser/Heavy Cruiser etc, or as mentioned before learnt and adapted throughout the game.

Exploration

Exploration could be as simple as just telling the Ships to explore as far out as range permits and then have them patrol along the borders. This is one simple way of allowing the AI to remove shroud in it's borders. Next the AI needs to designate ships to go from unknown system to unknown system within its borders.


Other things such as making sure no more then one ship goes to a system, that the AI doesn't send ships criss crossing through space and only gets the ship to pick nearby systems. Also what to do when another races space is found, should the AI tell the ship to ignore all other factors and just search as much of the space as possible in order to get enough intel on the race in question?

Colonization

Colonization can be simple to begin with and then expanded upon later no doubt. One system could simply scan a list of known planetary systems, each one would be given a "Score metric" affected by resources, population etc. The this a run down by some kind of "distance measure" in order to try and find a true value for the system based on how far it is and how good it is. Basically a balanced system of having the AI colonize nearby systems first and only go for the Very Best systems that are Very far away if they still score high after distance is factored. It should help keep Empires more compact and not colonizing to far and wide an empire to maintain.


One more thing to consider is contact with other races, should the AI in times of peace try and colonize nearby to the "borders" of another empire so as to facilitate some kind of buffer? If so then adding another metric which increases the score of a planetary system depending on distance from another Races planet so as to give the AI incentive to colonize the system.

Espionage, Resarch and trade

Diplomacy

Diplomacy is a keystone to any 4X game, with many out there utilising simple systems to others more complex.

Within BOTF2 there are two facets of diplomacy to take into account, that of the diplomacy between a Major or Minor race, with the decision of whether both should have the same level of detail, in terms of 'diplomacy comlexity' and options, or whether one is simpler then the other.

Taking into account the artificial intelligence of the game, we need to decide what impact both in terms of inputs towards diplomacy and also outputs (i.e impact) of diplomacy has on the game/race/player. In the simplest terms we need some measure of relationship between the various races, what inputs effect this relationship, what outputs diplomacy will have on this and other races relationships. Next comes the simple treaty system, what level of relationship allows what treaty, be it peace, trade or alliance etc. Increasing in complexity we can make these levels dynamic, ie does the effect of being at peace with a race for a number of turns lower the 'threshold' needed to aquire an alliance, or threshold in which a trangression may lead to war?

How should the AI make these choices, simply look at the relationship quotent and then offer or accept based on this solely? This makes it easier to implement and has the advantage of being easily interpreted by a player, for example i see our relationship with race A is 70% therefore an acceptance of an alliance is assured. This no doubt seems to simplistic and doesn't take into account a multitude of factors which should play a role.

Perhaps a Fuzzy based system though a neural network would incorporate better in terms of having to deal with the wide variaety of inputs.

It is not possible to list the many things one would want included in a diplomacy portion of a 4X game like BOTF2, nor possible to implement them all. Therefore concentrating on the AI, we look to one which we hope best models a human player, though perhaps more akin to real life diplomacy then how a human would play in game ie cheat :). The AI must not be contradictive, ie go to war willy nilly, with a previous ally or friend unless given a clear reason, even so i would hope that the change of relationship would play out over some number of turns. If at all possible, past relations and events should play a role in any diplomatic discorse though with diminishing returns over time. The AI needs to be able to trade with races it likes, embargo or 'hard diplomacy' those it doesn't ie give money and research to an 'enemy of an enemy' in order to reach a coexistant goal.

The AI should be able to perceive threats and through diplomacy find a means to combat them, be it through adjoining alliances or disruption through diplomatic means. It should also, come the other extreme know when to quit, and not fight to the death or prolong a needless war if it can stop one. No doubt a human player may be able to exploit this.

War and Peace

Minor Races

Colonization

Diplomacy

Precedence and Hierarchy

The AI of the game needs to be able to set precedence on what portion gets control at a specific time. For example one influence tells the AI to bulid more research structures but because the AI is at war another influence is telling it to build ships. who should win out in this scenario, probably ships.


Not to nitpick here, but you mentioned it up above that there are two seperate build queues (which is correct) but this seems to contradict that. Granted, it's simply the example you used as the problem still exists. This is a great start to developing the framework for the AI. To help flesh it out and so we can analyze which algorithms to use, I think we need to come up with some specific core decisions that the game will have to make. We'll also need to determine some sort of importance level for each decision that compares to other possible decisions of the same type. Then we can analyze which method of AI to utlize as we may very well wind up using different methods for different decisions.

-Azh


--You're Right, but i think you get the jist of what i mean :). I'll look to fill in the rest and then create a seperate page on Core decisions, you are right though the earlier we can agree on a consensus on essential features needed by the AI the better no doubt for Mstrobel, but the buck stops with him :D

Oh and feel free to add anything to the above, the more info the better, i need to brush up on everything else as i'am only really good at Genetic Algorithms and they have little use.

--Wolfe

AI Scripting (IronPython-option)

I've been looking into different options for dynamically compiling (scripting) the AI logic in Supremacy. There are two possible ways to do this. The first is to have dynamically compiled C# code. The second is to use IronPython. IronPython is pretty fast, so I doubt it would be noticably slower than C#. The real question is, which language would modders prefer to use? IronPython still requires working knowledge of the .NET platform, and it has some syntax additions that the CPython implementation does not have. Dynamically compiled C# would work the same as regular C#. There's probably more modders out there that already know regular Python, but knowing C# would help modders who want to modify the game core as well, since it the game itself is developed in C#. What do you guys think?


I'd probably just stick wtih C#. I don't really see the point in switching to Python if it does not offer any advantages. It would require people to know two seperate langauges to make changes, plus it'd likely require some C# code to interface with the Python portions of the program. Keeping it C# allows you make everything completely seamless.

-Azh


edit - Azh*

In response to the BotF response from Mike, Python would be able to seamlessly integrate. But that would still require two seperate languages for people to know in order to make modifications. It might also cut down on syntax mistakes to stick with C#, heh.

AI Agent Knowledge

What level of knowledge should AI Agents have?


There are three conventions:

  • AI Agents have no more knowledge than a human player, and are forced to use statistical inference to make deductions about the other players' assets and movements;
  • AI Agents have perfect knowledge of the game universe and all of the other players' assets;
  • or some middle ground between the two.

I tend to think that the AI should be able to 'cheat' to a certain extent, as long as it does not become obvious to the human players and take the fun out of the game.


  • Line of Sight

I think the AI should have to explore the galaxy and have the same visual restrictions as a human player. I wouldn't want the AI players to be aware of cloaked ships in their space if a human player would not be aware of them.


  • Diplomacy

I think the AI should have perfect knowledge of the relations between any of the races it has come in contact with. I think this is necessary to make interspecies relations more challenging.


  • Research and Construction

AI agents in this type of game almost always get bonuses to production. Generally, the AI's greatest strength is in raw numbers. Since an AI can't hope to match human wit, the best way to keep the player challenged is by making sure the AI can consistently throw around sufficient numbers of ships. This is hard to do if they get bogged down in production. To that end, I was considering giving AI players automatic upgrades to all production facilities (Food, Industry, Energy, Research, Intel) once a new tech level has been reached. Also, the AI needs to be able to reassess its production queues and active build projects due to changes in circumstances. It's therefore best to avoid any prolonged construction projects, as it would be difficult for the AI to assess whether it's best to let his Mass Replicators finish upgrading, or to cancel them and work on something else. This isn't as much of a problem for shorter construction projects.


Azh: I agree on these points. Another thing to consider is determining the value of resources and credits for AI players. Fuel and other ship-building resources might be something we want to keep "real" to aid the player in strategic victories or grant a small bonus or boost every so often, but I think the AI should have more access to credits than a human player. This can also aid in production if the AI should come to the conclusion that it should purchase ships and buildings instead of building them, if such a purchase option will exist. This really isn't an issue about knowledge so to speak, but I find it related to the research and construction points.