Author Topic: Infected AI overhaul  (Read 5166 times)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Infected AI overhaul
« 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.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Infected AI overhaul
« Reply #1 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:

  • There are asteroids nearby waiting to be colonised and we haven't seen any sign of an enemy empire yet.
  • We are colonising nearby asteroids, and we have spotted an enemy empire, who is also peacefully colonising asteroids.
  • We are trying to colonise nearby asteroids but an enemy empire is trying to do a rush tactic against us.
  • We've colonised all the asteroids visible to the current metric network, and cannot see any asteroids belonging to another empire.  They must be in a different part of the galaxy so we'd better wait until a comet comes past - or we float into range - of either an uncolonised asteroid or an asteroid owned by another empire, or another metric network that has gather points.
  • We've colonised all the asteroids visible to us, we can see asteroids belonging to an enemy empire.

These are all covered in Layer 5.




Asteroid states:

  • The asteroid is barren with no seedlings on it.  Layer 5.
  • .
  • The asteroid is barren and we have less than 10 seedlings on it, the enemy empire has less seedlings on it than we do.
  • The asteroid is barren and we have less than 10 seedlings on it, the enemy empire has more seedlings on it than we do.
  • .
  • The asteroid is barren and we have at least 10 seedlings on it, other empires have less seedlings on it than us.
  • The asteroid is barren and we have at least 10 seedlings on it, other empires have more seedlings on it than us.
  • .
  • We own the asteroid.  The asteroid is not under attack.  We have less trees than the asteroid's treecap.  We have less than 10 seedlings on it.
  • We own the asteroid.  The asteroid is not under attack.  We have less trees than the asteroid's treecap.  We have at least 10 seedlings on it.
  • .
  • We own the asteroid.  The asteroid is not under attack.  We have the same number of trees as the treecap.  We have enough seedlings to spare to send to other asteroids.  We have friendly or barren asteroids in range.
  • We own the asteroid.  The asteroid is not under attack.  We have the same number of trees as the treecap.  We have enough seedlings to spare to send to other asteroids.  We don't have any friendly or barren asteroids in range - this asteroid must be an orphan.
  • .
  • We own the asteroid.  The asteroid is not under attack.  We have the same number of trees as the treecap.  We need a bigger force guarding the asteroid.
  • .
  • We own the asteroid.  The asteroid is under attack from seedlings only.  The asteroid is an orphan so no help will be coming.
  • We own the asteroid.  The asteroid is under attack from seedlings only.  The asteroid is not an orphan so help will be coming.
  • .
  • We own the asteroid.  The asteroid is under attack from a mine.  The asteroid has zero friendly neighbours, so no help will be coming.  A barren asteroid is in range.
  • We own the asteroid.  The asteroid is under attack from a mine.  The asteroid has zero friendly neighbours, so no help will be coming.  No barren asteroids are in range.
  • .
  • We own the asteroid.  The asteroid is under attack from a mine.  The asteroid has at least one friendly neighbour, so help will be coming.
  • .
  • We own the asteroid.  Its torch metric is 1, and the neighbour with metric 0 is under attack from a mine or a number of seedlings significantly larger than what we have available to send.
  • .
  • We own the asteroid.  Its torch metric is 1, and the neighbour with metric 0 is under attack from a mine or a number of seedlings significantly larger than what we have available to send plus whatever we already have at the neighbour.
  • .
  • We own the asteroid.  We are the gather point, but we are no longer a suitable gather point and should relinquish the role so a new election can be held.
  • We own the asteroid.  We are the gather point, and the requirements are still being met for us to continue as such.  We haven't launched any attacks recently, and don't have enough seedlings to attack yet.
  • We own the asteroid.  We are the gather point, and the requirements are still being met for us to continue as such.  We haven't launched any attacks recently, but we now have enough seedlings to attack.
  • We own the asteroid.  We are the gather point, and the requirements are still being met for us to continue as such.  We have recently launched an attack.
  • .
  • We own the asteroid and one of the trees has grown a flower.
  • We own the asteroid and have a flower in orbit.
  • We own the asteroid and have a mine that has recently grown on a tree.
  • We own the asteroid and have a mine in orbit.
  • .
  • An enemy empire owns the asteroid.  We have no seedlings on the asteroid.
  • An enemy empire owns the asteroid.  We have seedlings on the asteroid, but not enough to capture it.  We have recently launched an attack on the asteroid.
  • An enemy empire owns the asteroid.  We have seedlings on the asteroid, but not enough to capture it.  We haven't launched any attacks on it recently.


I can't think of any more states an asteroid could be in.
Can you?  Tell me!
« Last Edit: July 21, 2010, 07:33:13 PM by annikk.exe »

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Infected AI overhaul
« Reply #2 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.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Infected AI overhaul
« Reply #3 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.

Rudolf

  • Administrator
  • Old Oak
  • *****
  • Thank You
  • -Given: 5
  • -Receive: 13
  • Posts: 669
  • Eufloria: Yes
Re: Infected AI overhaul
« Reply #4 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.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Infected AI overhaul
« Reply #5 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.

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: Infected AI overhaul
« Reply #6 on: July 21, 2010, 11:37:46 PM »
the newest version has GetNumAsteroids()!

Terrial

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 66
Re: Infected AI overhaul
« Reply #7 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.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Infected AI overhaul
« Reply #8 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!

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Infected AI overhaul
« Reply #9 on: August 09, 2010, 07:25:41 AM »
Mental note.  Make a new metric array - CautionMetric.