Euflorium: The Eufloria Community

Eufloria => Eufloria Classic => Eufloria Classic Mods => Topic started by: annikk.exe on July 08, 2010, 06:34:54 PM

Title: Infected AI overhaul
Post by: annikk.exe on July 08, 2010, 06:34:54 PM
Going to start making some notes about this to help me when I start programming.


The key method of organising the engine will be to formalise each different part into a layer-based structure, similar to the OSI model in networking.
The layers below perform services for the layers above.


Here's a first draft.

Layer 6 -> Take action based on metric information and the states of neighbouring asteroids.
Layer 5 -> Final check to ensure nothing prevents this asteroid from taking action, eg if it's under attack, or doesn't have any seedlings on it, or... etc
Layer 4 -> Where no metric is self-evident, scan through the list of traversable neighbouring asteroids to work out a calculated metric.
Layer 3 -> Calculate any self-evident metrics that should be applied to the selected asteroid - this includes being elected to Gather Point and applying for Orphan status.
Layer 2 -> Calculate friendly and attackable paths from the selected asteroid
Layer 1 -> Select a random asteroid from the seedlist.  If an asteroid is not on the seedlist then it is totally invisible to the AI engine.
Title: Re: Infected AI overhaul
Post by: annikk.exe on July 09, 2010, 07:50:11 PM
In order to make the AI foolproof, it will be necessary to evaluate all possible asteroid states, and preferably a fair few different strategic states as well.



Strategic states:


These are all covered in Layer 5.




Asteroid states:



I can't think of any more states an asteroid could be in.
Can you?  Tell me!
Title: Re: Infected AI overhaul
Post by: annikk.exe on July 14, 2010, 06:12:01 PM
Going to overhaul this before I make Big Bang map, I think.  I will want an updated AI engine to use with it.

I'll be flying out to Abu Dhabi at the start of August to deploy a technical solution that I've been working on for the last 18 months, then I'm off work for 3 weeks for the arrival of my new kitten.  :>  (there will be pics)

During those 3 weeks will also be a good opportunity to work on some of this stuff.
Title: Re: Infected AI overhaul
Post by: annikk.exe on July 19, 2010, 11:08:46 PM
Hoping to start the overhaul this week.  The aim is to boil it down to a single function which can be called by level designers to implement the AI in their own levels.
Title: Re: Infected AI overhaul
Post by: Rudolf on July 21, 2010, 07:14:27 PM
Without promising anything; Alex is considering a way to make mods global, so people can apply the game as a whole. This would definitely be a good candidate.
Title: Re: Infected AI overhaul
Post by: annikk.exe on July 21, 2010, 07:50:43 PM
Nice :>  So you could play the original campaign but against Infected AI?  That could make some of the levels insanely difficult!


One of the big barriers to making the Infected AI more self-contained is its reliance on the designer inputting a lot of data directly to the AI engine.  For example, the engine must be told how many asteroids there are, and the X and Y coords of those asteroids.

First and foremost we need to know how many asteroids are in the level.
I'm not aware of any way to call this directly, so lets try something like this:


Code: [Select]
roidnumber = 0

for roidcheck = 0,100 do

  if GetAsteroid(roidcheck).position.x ~= nil then
    -- this roid must exist

  elseif roidnumber == 0
    -- this roid doesn't exist!  the previous roid was the last one.
    roidnumber = roidcheck - 1

  end

end
-- Now we have auto-calculated the roidnumber variable



For the X and Y coords, I can solve this by using GetAsteroid(0).position.x.
Normally the AI engine stores the coordinates in two arrays, CoordX[] and CoordY[].
So all I have to do is something like this:


Code: [Select]
for assigncoords = 0,roidnumber do

  coordx[assigncoords] = GetAsteroid(assigncoords).position.x
  coordy[assigncoords] = GetAsteroid(assigncoords).position.y

end



That will automatically populate the crucial roidnumber, CoordX[] and CoordY[] variables.


This brings us a step closer to a totally independent AI function.
Title: Re: Infected AI overhaul
Post by: Alex on July 21, 2010, 11:37:46 PM
the newest version has GetNumAsteroids()!
Title: Re: Infected AI overhaul
Post by: Terrial on July 22, 2010, 03:55:52 AM
What about more states where the Enemy controlls the roid, like if they have a mine on their roid, or an enhanced tree. Usually if an enemy has a flower on a defense tree, I make a point of sending a mine to that roid to destroy the flower because I HATE enemy mines.  Also if the enemy has a mine on their asteroid, that would require either another mine or a really large attack force.
Title: Re: Infected AI overhaul
Post by: annikk.exe on July 22, 2010, 06:42:25 PM
The AI doesn't need to do too much if it selects an enemy asteroid for checking (in layer 1).  There's not a lot it can do, since it will usually have no seeds or trees there.

If one of the AI's asteroids is selected and finds itself with an attackable path containing an enemy laser mine and/or large group of seedlings, it would mean the AI engine is set to be in a specific strategic state (ie it has made contact with an enemy) resulting in a general awareness that battle may come soon; the AI's entire empire would grow more cautious.  In addition, on layer 5 it would cause that asteroid to not send reinforcements out, and instead build up a decent defensive force before it supplies seedlings to the metric network for distribution.


Thanks for the thought.  :>  It helps me a lot to walk through the logic of these problems!
Title: Re: Infected AI overhaul
Post by: annikk.exe on August 09, 2010, 07:25:41 AM
Mental note.  Make a new metric array - CautionMetric.