AI Tactics

Post your best tactics and strategies for getting the big bux in Vega Strike
Post Reply
ezee
Intrepid Venturer
Intrepid Venturer
Posts: 703
Joined: Tue Feb 11, 2014 12:47 am
Location: FRANCE
Contact:

AI Tactics

Post by ezee »

I don't play so much with VS .
Well i play more with the ideas i have about it , and work to try to materialize dem .
I wanted to talk about the AI tactics , and this is perhaps the right place .
An other thread of mine talk also about AI , but from a code perspective :
http://forums.vega-strike.org/viewtopic ... 27&t=19807

But without regards to any kind of code , i think here about the strategy .
Human strategy front of an actual AI that only have this file :
#ifndef TACTICS_H_
#define TACTICS_H_
#include "order.h"

class CloakFor : public Order
{
float time;
float maxtime;
bool enable;
public: CloakFor( bool enable, float seconds = 0 ) : Order( CLOAKING, 0 )
, time( 0 )
, maxtime( seconds )
, enable( enable ) {}
void Execute();
~CloakFor();
};

#endif
... as Tactics .

I said that i won't talk about code , so this previous argument is good enough to introduce the subject of this thread .

AI TACTICS

Chapter 1 : Following orders AND "think" pass .

Today , AI is only able to follow orders , not to think .
We , human players , have individual tactics , and skills for pilot a vessel or trade or fight
or ... etc . Between each Action pass ( you press a button , moove joystick etc ...) , we
think to what we gonna do next .

AI today is living in an Action event context , triggered by a script .
Perhaps there is a limited think time in the actual orders ( compute relationship , vessel
control ) , but not linked to the dynamic universe .
It's like if the universe generated the AI only for events , not for persistence .

I agree with the fact that if your AI lives and die only in a vessel cockpit , for only one
mission or quest script , you don't need to give him a brain : SHUT UP , TURN LEFT , ACQUIRE TARGET , FRIEND OR FOE , OPEN FIRE , MISSED ->DO IT AGAIN UNTIL DEATH

But if we want to have NPC Persistency in the gameplay , they ideally could be perceived
as Players . And players have time to think .

Chapter 2 : AI TIME FOR THINK.

In the core of the c++ engine , i've read that render operations + physics occurs at frame
level . It will try to find that part of code to show you . But ...
What i want to introduce as idea is a AI TIME , in that main loop .

Before trying to define quantity ( how much cost of time/frames/physics_steps because of the AI CALLBACKS LOOPS ) , i will try to find " when to think " .

Thinking is not apply orders .
The AI will ALWAYS follow orders , send by itself . :lol:
What kind of orders ?

_REST : automation mode , mean set-autopilot-on for vessels , sleep for NPC .
With a REST order , the AI will never think . ( Make the AI have a dream is very challenging ... :lol: ) .

_ATTACK :
Say i am a AI agent : It's time for me to think . ( without thinking you are all deads :lol: )
I received the order to attack ,
first question is :
WHO ?
second question :
WITH WHAT ? ( perhaps that is the question in my signature , and it should be the first question , strategically speaking ) .
If i have no more missiles or guns damaged , i must answer to my AI Authority : " NEGATIVE " .
I stay safe by keeping my distance , and wait for orders :
They want me to die , i follow ( i am a stupid AI ) .
They want me to live , i follow ( i am a stupid AI but i had chance this time )
The question 3 ( free ) will never occur : " what the hell am i doing here ? " :wink:

exception :
Perhaps a very special pirat's AI NPC unit should be able to think the 3rd stage of thinking
And this numeric guy ( male or female ) could be a only thinking unit .
Other AI units execute orders , with different levels of freedom ( time to think ) .
The same could apply for all the Factions .

Chapter 3 : Different ways of thinking .

In the case of Aera's faction , theMeritocracyis something sexy to modelize ( for a geek ofcourse :lol: ) .
Meritocracy (merit, from Latin mereō: “earn” + -cracy, from Ancient Greek κράτος, kratos: “strength, power”) is a political philosophy that holds power should be vested in individuals according to merit.[1] Advancement in such a system is based on intellectual talent measured through examination and/or demonstrated achievement in the field where it is implemented.
A blank page in the wiki to fill in about it : http://wiki.vega-strike.org/Terminology:Meritocracy

But oligarchy is sexy also : http://en.wikipedia.org/wiki/Oligarchy
Oligarchy (from Greek ὀλιγαρχία (oligarkhía); from ὀλίγος (olígos), meaning "few", and ἄρχω (arkho), meaning "to rule or to command")[1][2][3] is a form of power structure in which power effectively rests with a small number of people. These people could be distinguished by royalty, wealth, family ties, education, corporate, or military control. Such states are often controlled by a few prominent families who typically pass their influence from one generation to the next, but inheritance is not a necessary condition for the application of this term.
That notion of states is a basic requesite in a AI system .
We have two examples of way of thinking , each depending on states .
That is enough to begin to draw a root for thinking .
Then push branches from it , with different implementation of states .
To each governement , a state machine ... with rules that children AI agents apply ,
thinking or not .
:wink:

A practical example with a fighter squadron :

Who is thinking ?
The authority in a fighter group is the leader .
So the Leader has thinking attribute set on .
Others are following orders .
But ... The Leader is also a Follower , and he reports status to the authority that has
the THINKING PRIVILEGE .

Chapter 4 : THINKING PRIVILEGE .

How is done the attribution in each Faction .
Describe the specialization in thinking ;
Economy , Astronomy , Military , Spirituality or Moorality etc ...
Thinking is for a goal , so what is to be defined are goals , the core of the AI cycle .
THINK : " What is my goal " -> read in XML
THINK : " Can i do that now " -> use c++ evaluation code or previous record in the timeline ( i know the ennemy vessel will be in my sight in 1/10 secondes if i keep that way , so just wait and return ok )

Or in a trade context :
I am in a merchant guild and received orders to buy some rare gaz elements in that system , but the prices are very high .
THINK : " Can i do that now " -> look in the priorities table and ask authorities() .
Authorities in economy will think and reflect the economical situation in their selling prices.

Back to this chapter , the privilege of thinking should be attributed to persistent NPC ,
ideally that can't die . ( They have a fleet all around them that are their remparts , they
will never go in front line etc ... But you can talk to them in bases or stations )

Code: Select all

 if (!track.HasWeapons())
            {
                // So what are you going to threaten me with? Exhaustion gas?
                return ThreatLevel::None;
            }
Vegastrike evolved
DEV YOUTUBE CHANNEL
Vegastrike evolved wiki
ezee
Intrepid Venturer
Intrepid Venturer
Posts: 703
Joined: Tue Feb 11, 2014 12:47 am
Location: FRANCE
Contact:

Re: AI Tactics

Post by ezee »

Chapter 5 : Game theory .

See wikipedia : http://en.wikipedia.org/wiki/Game_theory
Game theory is a study of strategic decision making. Specifically, it is "the study of mathematical models of conflict and cooperation between intelligent rational decision-makers".
Great .
So if we have AI agents able to think , the Game theory could help to define the goals .
Game theory is mainly used in economics, political science, and psychology, as well as logic and biology. The subject first addressed zero-sum games, such that one person's gains exactly equal net losses of the other participant(s).
That is good in term of balance for the gameplay with the different Factions in Vegastrike :
The games studied in game theory are well-defined mathematical objects. To be fully defined, a game must specify the following elements: the players of the game, the information and actions available to each player at each decision point, and the payoffs for each outcome. (Rasmusen refers to these four "essential elements" by the acronym PAPI.)[3] A game theorist typically uses these elements, along with a solution concept of their choosing, to deduce a set of equilibrium strategies for each player such that, when these strategies are employed, no player can profit by unilaterally deviating from their strategy. These equilibrium strategies determine an equilibrium to the game—a stable state in which either one outcome occurs or a set of outcomes occur with known probability.
A strategical situation can be viewed as a mesh in 3d :
Actors or agents are like vectors in a 3d space , at an instant t .
This is very useful to be able to see a global situation in one object .
I was surprised to learn that this strange idea i had of a mesh object for holding a AI scene is somehow used today :
The extensive form can be used to formalize games with a time sequencing of moves. Games here are played on trees (as pictured to the left). Here each vertex (or node) represents a point of choice for a player. The player is specified by a number listed by the vertex. The lines out of the vertex represent a possible action for that player. The payoffs are specified at the bottom of the tree. The extensive form can be viewed as a multi-player generalization of a decision tree. (Fudenberg & Tirole 1991, p. 67)

Code: Select all

 if (!track.HasWeapons())
            {
                // So what are you going to threaten me with? Exhaustion gas?
                return ThreatLevel::None;
            }
Vegastrike evolved
DEV YOUTUBE CHANNEL
Vegastrike evolved wiki
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Re: AI Tactics

Post by klauss »

Long post, but let me mention something that I think you've missed.

The tactics you mention are coded as "superorders", check the ai/aggressive.cpp, where you will see an order that is the AggressiveAI. This kind of AI follows the FSM specified by AI scripts (xml).

It's a pretty obscure part of the code, mostly because the AI scripts have a horribly unreadable representation, but thing is, they specify local tactics well - engage ap, fly there, wait, follow this, target, approach, attack, retreat, etc..

Simulating long-lived NPC individually would be complex an inefficient. What you want, is what we discussed under the term of "Faction AI". Some kind of government AI that dictates the movement of assets and faction-wide policy.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
Deus Siddis
Elite
Elite
Posts: 1363
Joined: Sat Aug 04, 2007 3:42 pm

Re: AI Tactics

Post by Deus Siddis »

klauss wrote: Simulating long-lived NPC individually would be complex and inefficient.
Although a very desirable feature for distant future development, IMHO.
ezee
Intrepid Venturer
Intrepid Venturer
Posts: 703
Joined: Tue Feb 11, 2014 12:47 am
Location: FRANCE
Contact:

Re: AI Tactics

Post by ezee »

Deus Siddis wrote:
klauss wrote: Simulating long-lived NPC individually would be complex and inefficient.
Although a very desirable feature for distant future development, IMHO.
Well , i think i am a kind of eternal student , that never finish to learn .
So i can't make promesses or deals , as my work is based first at research level .

Application domain occurs after the Experimentation domain .
The probability of successful creation of a new AI system coded by me in VS is very low ,
but that is not a problem actually :

I consider that one could use my experimentations ( or just my research in documentation ) to effectively make it . I am not the kind of genius guy like Ace123 or Hellcatv .
But these kind of guys are able to do incredible things just because they like it !
:lol:

So " Simulating long-lived NPC individually would be complex and inefficient. " apply well
in my single case , but hope exists that this could be done by an artist of the code .

But i won't wait defeated , i will stand up and fight .
Fight against ignorance i mean .
My ignorance .
And my AI should benefits from that .

Also , i try to bring the background of VS " tales " in the game .
And we need AI actors to interpret these stories .

Technically , persistent NPC is challenging , from their life in the game loop to the storage
of their situations on disk .

I know that i have entered a multiplayer context now , and i know that to continue i must
look to the actual server code .
Perhaps then new doors will be opened .
:)

Code: Select all

 if (!track.HasWeapons())
            {
                // So what are you going to threaten me with? Exhaustion gas?
                return ThreatLevel::None;
            }
Vegastrike evolved
DEV YOUTUBE CHANNEL
Vegastrike evolved wiki
loki1950
The Shepherd
Posts: 5841
Joined: Fri May 13, 2005 8:37 pm
Location: Ottawa
Contact:

Re: AI Tactics

Post by loki1950 »

There are a few persistent NPC's in jackS story line but their interaction with the player are minimal but necessary to the story their appearance could be a few cut scenes(news casts maybe).

Enjoy the Choice :)
my box::HP Envy i5-6400 @2Q70GHzx4 8 Gb ram/1 Tb(Win10 64)/3 Tb Mint 19.2/GTX745 4Gb acer S243HL K222HQL
Q8200/Asus P5QDLX/8 Gb ram/WD 2Tb 2-500 G HD/GF GT640 2Gb Mint 17.3 64 bit Win 10 32 bit acer and Lenovo ideapad 320-15ARB Win 10/Mint 19.2
ezee
Intrepid Venturer
Intrepid Venturer
Posts: 703
Joined: Tue Feb 11, 2014 12:47 am
Location: FRANCE
Contact:

Re: AI Tactics

Post by ezee »

loki1950 wrote:There are a few persistent NPC's in jackS story line but their interaction with the player are minimal but necessary to the story their appearance could be a few cut scenes(news casts maybe).
News cast is a good idea .
But no need for AI in that stuff .
Persistent NPC are good candidates for AIML or similar interactive dialog based technology .
If we can link the brain ( AI text engine ) with actions ( actual AI orders ) , they could start to be tactical agents .

Example :

You talk to a pirate in a station , you are provocating him to the point where he decide
to eliminate you . ( your level of relationship is low low low now ).
If he got units under his orders , he can launch a contract on you .

It's a variation of the actual comm system , available in bars for example , with a less linear dialog approach .

An other example could be that you talk to someone in a base , and talk too much .
Tha NPC learned from you what is your cargo , and your final destination .
If he is a spy , the adverse AI faction could decide an interception .

That is the INFORMATION part of the previous chapter , one of the prerequisite for AI
analysis and balance . Spies are a good idea , imagine that the AI tries to fool you by sending to you wrong information ? Like in the real world , you don't know who to trust .
And find friend or foe in the NPC would be a part of the gamePlay :

You need to talk to make alliances , find contracts .
But the way you talk and the things you say are critical ( information is the base of the
AI computation ) . The bartender is cool and look gentle , but he talks too much to a lot of people .
One could be a spy or scout , that is like a bee in a field of flowers , pollen being the information and honey being money . FLowers are planets , stations , moons , where the information is .
Poetry , you got me !
:)

Code: Select all

 if (!track.HasWeapons())
            {
                // So what are you going to threaten me with? Exhaustion gas?
                return ThreatLevel::None;
            }
Vegastrike evolved
DEV YOUTUBE CHANNEL
Vegastrike evolved wiki
TBeholder
Elite Venturer
Elite Venturer
Posts: 753
Joined: Sat Apr 15, 2006 2:40 am
Location: chthonic safety

Re: AI Tactics

Post by TBeholder »

klauss wrote:The tactics you mention are coded as "superorders", check the ai/aggressive.cpp, where you will see an order that is the AggressiveAI. This kind of AI follows the FSM specified by AI scripts (xml).
...and those XML themselves are selected via combat role setup in data/ai/VegaEvents.csv (used together with VegaPriorities.csv)
klauss wrote:Simulating long-lived NPC individually would be complex an inefficient. What you want, is what we discussed under the term of "Faction AI". Some kind of government AI that dictates the movement of assets and faction-wide policy.
On the intermediary level there should be at least Flightgroup AI. That is, support for NPC processing mission objectives.
"Two Eyes Good, Eleven Eyes Better." -Michele Carter
ezee
Intrepid Venturer
Intrepid Venturer
Posts: 703
Joined: Tue Feb 11, 2014 12:47 am
Location: FRANCE
Contact:

Re: AI Tactics

Post by ezee »

Thank you for that complement of information TBHolder .
:wink:

For the next chapter , i will use the reference of our expert in alien Weaponry and tactics
These precious datas are to be considered to set up the different AI Factions .

Chapter 6 : Weaponry and Tactics ( Jacks )

Weaponry-wise, the Rlaan were set up to have no projectile or missile weapons whatsoever, heavy weaponization of gravitics, and lasers sprinkled in for good measure. The high-level idea was that, while Rlaan "fighters" featured lower peak accelerations than Human/Aera fighter-craft, the drop in peak acceleration as ships scaled up wasn't as steep for the Rlaan, which, combined with omni-directional acceleration profiles, lead to Rlaan capital ships employing highly maneuver-and-pursue oriented tactics leading to knife-fight range engagements and exercises in tanking damage. The Rlaan are the only group that has a ship that is (human-designated) a BB rather than a BC.

The Aera were a bit heavier on driver tech than humans for their capital weaponry, but were otherwise not terribly picky. Preferred tactics are standoff range artillery duels, wherein the drivers and missiles (same damage at any distance) can be employed to full advantage. The Aeran fleet is organized a bit differently than the human ones, with packs of corvette-scale torpedo launching ships being one of the mainstays of their offensive thrusts rather than "bomber" class strike craft. Strike craft are more intercepter/superiority oriented, designed to be employed defensively and as torpedo-boat escorts while the capital employ their axial weapons and missile batteries. The primary Aeran fighter guns were combination damage weapons designed to have at least some shield penetration. I think a theme that was intended to be played on was that the Aeran weapons always wanted to make sure that any given shot would hurt at least a little whether or not shields were involved.

Humans definitely have some high-end particle-beam weaponry in their arsenal, but faction-by-faction vary a bit on capital weapons loadouts. Unadorned weaponry tends toward gravitics (because the math was interesting for them), missiles are ubiquitous, etc. Lots of strike craft employed as interceptors, superiority, and bomber mission craft. Forsaken fleet loadout is very differently oriented due to economic constraints (largest ship class is effectively a DE) with heavy use of glass-cannon style gunboats for anti-capital purposes rather than their own capital vessels.

Uln craft were intended to be highly divergent among the lower order and higher order craft (peasant mobs on the one hand, armored knights on the other). The latter vessels, while very few (small economy) are covered in what amounts to the Ancient equivalent of aluminum siding, but which still makes better armor than anything anyone else can produce. Sadly for the Uln, not only is it a non-renewable resource, but its armoring properties make it very difficult to work with. The pride of the Uln navy thus has the dubious honor of likely being battered to bits internally, or deprived of all of its radiator surfaces, long before its armor gives out. Ulnish weaponry on these capital vessels is an eclectic mix of what they could repurpose from their homeworld, develop themselves, or buy from the other polities. Aside from their missile barges, weapons tend toward whatever is either cheaper to fire (for ships meant to see use) or more impressive to fire (for those mostly there to be menacing). The bulk of their capital fleet is deployed around their homeworld, so logistics has never been required to be terribly advanced for the Uln. Ulnish small craft are cheap, flimsy, and considered highly expendable. The Uln, like the Shmrn, heavily employ in-system ships, with their most common lacking in any form of FTL drive. The Uln have not seen major naval combat for generations. Most Ulnish fleet actions are internal political events and/or related to interactions between the Uln government and organized crime elements (none of the previous categories are distinct).

As for why the guns are so far apart... that's probably mostly a question of symmetry and redundancy. The Aera build their vessels around what is essentially an armored tube core that houses the primary fore/aft engines and primary reactor(s). There surely would be some minimum distances between electromagnetics, but that wasn't a design constraint I was actually considering at the time.

Code: Select all

 if (!track.HasWeapons())
            {
                // So what are you going to threaten me with? Exhaustion gas?
                return ThreatLevel::None;
            }
Vegastrike evolved
DEV YOUTUBE CHANNEL
Vegastrike evolved wiki
ezee
Intrepid Venturer
Intrepid Venturer
Posts: 703
Joined: Tue Feb 11, 2014 12:47 am
Location: FRANCE
Contact:

Re: AI Tactics

Post by ezee »

The next chapter will introduce an answer , or a " howto " to this previous comment :
What you want, is what we discussed under the term of "Faction AI". Some kind of government AI that dictates the movement of assets and faction-wide policy.
Dictate is hard and is coded . :wink:
Other solutions exists , but they are still experimental .
To Govern is not Dictate , a governor is able to listen to the information an judge for the body benefits ( the faction ) and not only for its own benefits ( the head of the body ) .
So the system i will describe is a system that reproduce the biological way the information
is processed in the head ( neurones are units , link between neurones are synapses ) to the rest of the body . ( in other words the Faction ).

Chapter 7 : Architecture for Think - Neural Network

First , a very good tutorial for those are curious about it :
http://www.codeproject.com/Articles/164 ... rs-Part-of
It is also the source of inspiration of this chapter ( what i will describe is not the reality
of the Neural Network in his application , but a free and creative derivative idea )

As i was talking about THINKING PRIVILEGE , it's time to go deeper in practical exemples .
I will use for that a previous comment :
On the intermediary level there should be at least Flightgroup AI. That is, support for NPC processing mission objectives.
That is a perfect starting point , as in the hierarchy scale the Leader of a squadron is
at the bottom of the PRIVILEGIED UNITS hierarchy , near the units that can only follow and report .

So , what is the point with neural networking AI and our exemple ?
Look that Picture , and imagine E is the leader, x are units of the flightgroup.
Image

We see that E receive reports ( signals + or - ) from different unit's outputs .
The leader just received status reports from his group :
This configuration is actually called a Perceptron. The perceptron (an invention of Rosenblatt [1962]), was one of the earliest neural network models. A perceptron models a neuron by taking a weighted sum of inputs and sending the output 1, if the sum is greater than some adjustable threshold value (otherwise it sends 0 -
In detail :
The perceptron itself, consists of weights, the summation processor, and an activation function, and an adjustable threshold processor (called bias here after).
Image

The bias could be in our exemple a signal that indicate the critical level of an event .
With that informations , the Leader can compute if it's better to give new orders or report to the above neuron/Authority . ( for example )

How thinking privilege could be attributed , by a non hardcoded way ?
The answer is : BY THE LEARNING LEVEL
A foreword on learning

Before we carry on to talk about perceptron learning lets consider a real world example :

How do you teach a child to recognize a chair? You show him examples, telling him, "This is a chair. That is not a chair," until the child learns the concept of what a chair is. In this stage, the child can look at the examples we have shown him and answer correctly when asked, "Is this object a chair?"

Furthermore, if we show to the child new objects that he hasn't seen before, we could expect him to recognize correctly whether the new object is a chair or not, providing that we've given him enough positive and negative examples.

This is exactly the idea behind the perceptron.
This property could serve ingame in a FLIGHTGROUP ACADEMY , where bots learn different
flight-nav-fight problems and solve them .
EDIT : A FANTASTIC TUTORIAL+ CODE at http://www.ai-junkie.com/ show that in a live application mixing genetic algorithm and neural net :
Image
As you can see it's a very simple display. The minesweepers are the things that look like tanks and the land-mines are represented by the green dots. Whenever a minesweeper finds a mine it is removed and another mine is randomly positioned somewhere else in the world, thereby ensuring there is always a constant amount of land-mines on display. The minesweepers drawn in red are the best performing minesweepers the program has evolved so far.

How is a neural net going to control the movement of a minesweeper? Well, just like the control of a real tank, the minesweepers are controlled by adjusting the speed of a left track and a right track. By applying various forces to the left and right side of a minesweeper we can give it a full range of movement. So the network requires two outputs, one to designate the speed of the left track, and the other to designate the speed of the right track.
I LOVE IT !! :wink:
( there were errors in the project compilation , fixed easily , bad initialisation in a for(i= etc ... )

But back to the Perceptron :
"The perceptron is a program that learn concepts, i.e. it can learn to respond with True (1) or False (0) for inputs we present to it, by repeatedly "studying" examples presented to it.

The Perceptron is a single layer neural network whose weights and biases could be trained to produce a correct target vector when presented with the corresponding input vector. The training technique used is called the perceptron learning rule. The perceptron generated great interest due to its ability to generalize from its training vectors and work with randomly distributed connections. Perceptrons are especially suited for simple problems in pattern classification."
That term introduce the next chapter , that will talk about Strategy Pattern for AI
:wink:

Edit : I've found a second tutorial , with c++ code and solution for MSVC2008 .
The cool thing is that the example make use of .csv to store the learning sessions .
Basic Neural Network Tutorial : C++ Implementation and Source Code
inside :
neural network class (has CSV logging, and has supports for momentum and batch/stochastic learning)

Code: Select all

 if (!track.HasWeapons())
            {
                // So what are you going to threaten me with? Exhaustion gas?
                return ThreatLevel::None;
            }
Vegastrike evolved
DEV YOUTUBE CHANNEL
Vegastrike evolved wiki
jackS
Minister of Information
Minister of Information
Posts: 1895
Joined: Fri Jan 31, 2003 9:40 pm
Location: The land of tenure (and diaper changes)

Re: AI Tactics

Post by jackS »

Without going into too much detail, perceptrons are a rather limited form of neural network, even among feed-forward networks - they basically attempt to model a single neuron. You'd presumably want a multi-layer (probably at least one hidden layer) approach for a feed-forward neural net. You'd also need to derive objective functions with which to train the network weights.
ezee
Intrepid Venturer
Intrepid Venturer
Posts: 703
Joined: Tue Feb 11, 2014 12:47 am
Location: FRANCE
Contact:

Re: AI Tactics

Post by ezee »

Yeah , that is what the " Smart Sweepers " example from AI junkie do .
The weights are updated coupled with the genetic algo :
We can now use crossover and mutation as normal with one difference: the mutation rate for genetic algorithms using real numbers is much higher… a value of between 0.05 and 0.2 is recommended.

Before I show you the definition of the CGenAlg class let me quickly show you the genome structure:

struct SGenome

{

vector <double> vecWeights;



double dFitness;



SGenome():dFitness(0){}



SGenome( vector <double> w, double f): vecWeights(w), dFitness(f){}



//overload '<' used for sorting

friend bool operator<(const SGenome& lhs, const SGenome& rhs)

{

return (lhs.dFitness < rhs.dFitness);

}

};
In practice , the tanks at generation 0 are only able to turn around their location
( the tank has a Perceptron that has 4 inputs , 2 pairs of float that are vectors2D( x,y )
defining the closest vector to a mine and the actual lookAt of the tank )

The learning phase is done using the genetic formulas (crossover and mutation) to find out the best WEIGHT for match the inputs .
At the generation 5 , you can see some tanks that have gained a lot of hability .
Beautiful !

I really want to use this method in the future , because the gameplay would be fantastic:
_ New units are trained in an Academy ( they are the reserve of units )
_ Units that have been trained can go to trade or fight .
Now , imagine a cadet AI that is persistent , he is always evolving and getting better :
more precision with the vessels commands , better aim and reflexes .
IF YOU DON'T SHOOT HIM DOWN QUICK , HE SOON BE DARK VADOR eh eh .
When you shoot him down , a new mature unit leaves the academy and the academy is filled with a new young cadet .

Again , if you have time , have a look to this site that is a very good reference for AI :
http://www.ai-junkie.com/index.html

I have found also a great book with exemples by this master of AI ,Mat Buckland, freelance programmer and writer : http://www.jblearning.com/Catalog/97815 ... 4/student/

Features & Benefits
Techniques covered:

state- and goal-based behavior
inter-agent communication
individual and group steering behaviors
team AI
graph theory
search
path planning and optimization
triggers
scripting
scripted finite state machines
perceptual modeling
goal evaluation
goal arbitration
fuzzy logic
The code samples are even offered :wink: :
http://samples.jbpub.com/9781556220784/ ... Source.rar

The chapter about " Autonomous agents " is very impressive .
What is an Autonomous Agent?
I've seen many definitions for what an autonomous agent is, but probably the best is this:

An autonomous agent is a system situated within and a part of an environment that senses that environment and acts on it, over time, in pursuit of its own agenda and so as to effect what it senses in the future.
A kind of me ... :lol:

Code: Select all

 if (!track.HasWeapons())
            {
                // So what are you going to threaten me with? Exhaustion gas?
                return ThreatLevel::None;
            }
Vegastrike evolved
DEV YOUTUBE CHANNEL
Vegastrike evolved wiki
ezee
Intrepid Venturer
Intrepid Venturer
Posts: 703
Joined: Tue Feb 11, 2014 12:47 am
Location: FRANCE
Contact:

Re: AI Tactics

Post by ezee »

:!: I have started a console project that implement the FSM provided by Mat Buckland from ai-junkie.com .

That is pretty cool , i modified it to simulate the life of AI agents in a base .
The agents follow an agenda , and they can moove to different places in the station .
I will implement things like :
enum loc_inBase
{
dock,
hall,
bar,
shipdealer,
weapondealer,
trader,
police,
jail,
kitchen,
restaurant,
chamber,
adminroom,
commandroom,
turret
};
When the program starts , the agent wakeup in his chamber , with a " Enter_Ship " state . It could be " Enter_bathroom " or whatever , but i won't do a remake of the sims . :lol:

The states are classes and singleton , with 3 main methods :
enter()
execute()
exit()
The AI agent has a function that can change the actual states :
//this method changes the current state to the new state. It first
//calls the Exit() method of the current state, then assigns the
//new state to m_pCurrentState and finally calls the Entry()
//method of the new state.

void ChangeState( State<NPC>* new_state);
For example , i use the enter() fonction in the " Enter_Ship " state to check if the
agent is already in the dock room :
void Enter_Ship::Enter(NPC* npc)
{
//pseudo position of the docking room
pos.x=10;
pos.y=10;
//if the NPC is not already located at the SHIP, he must
//change location to the SHIP
if (npc->Location() != dock)
{
printf( "\n Walking to the dock");
//do something like walk or run etc ...
}
}
Then , the execute() fonction of that "Enter_ship " state check when the action is possible :
void Enter_Ship::Execute(NPC* npc)
{
if(npc->Location()!=dock)
{
int dist=pos.x-npc->pos.x;
npc->pos.x++;
if(dist==0){
printf( "\n Arrived to the dock !");
npc->ChangeLocation(dock);//now arrived
}
else printf( ".");
}
else printf( "\n Entering the ship ...");

}
It's just a beginning , but that is pleasant to imagine say , 100 agents , doing their stuff
in a station . ( not active in the same time , 2/3 are sleeping , see below )
I want to implement something like this :

_The base must have enough rooms ( chambers ) for the staff
_The base is maintained by the staff ( they are 3 by assignment to do the 3*8 hours of
work . If a man is killed , the base will ask the homeplanet to send a new worker .
( there will be a delay before the 3rd guy arrives , so the 2 others will get fatigue , and
productivity will be less good ). If the 3 are killed , and they were communication's engineer , the base will be without comm officers until the reinforcement arrives .
Same for the fighter pilots etc ...
That will be a part of the gameplay that i imagine .

Stations with life !
:wink:

Code: Select all

 if (!track.HasWeapons())
            {
                // So what are you going to threaten me with? Exhaustion gas?
                return ThreatLevel::None;
            }
Vegastrike evolved
DEV YOUTUBE CHANNEL
Vegastrike evolved wiki
Post Reply