Author Topic: Calling all coders - please help me test Infected AI v2!  (Read 31454 times)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Calling all coders - please help me test Infected AI v2!
« on: December 22, 2010, 08:35:19 AM »
Infected AI v2
Beta Version 2.3



Beta closed.  :>
New templates online soon..


Version 2.3 notes

  • Fixed a bug that occasionally caused the AI to colonise 2 asteroids then stop completely until attacked.
  • Various minor code tweaks (I don't remember what) to improve efficiency and overall effectiveness

Version 2.2 notes:

  • The AI now automatically detects flowers that grow on its trees, and plants them on Dyson Trees.  No mines just yet, sorry!
  • The AI will now continue to send seedlings to reinforce an attack it is winning.
  • The AI is now a lot smarter about choosing the size of the initial force of seedlings it sends to colonise an asteroid inhabited by greys.
  • Fixed a bug (hopefully) with AI seedlings all flying back to the gather point as soon as they had successfully captured an asteroid.
  • Orphans surrounded by lots of enemies will now try to launch an attack - at the latest - when they reach their spawn cap.
  • When a gather point that has a very large number of seeds launches an attack, it will now split them between all available neighbouring enemy asteroids, drastically improving the virulence of large AI swarms.
  • Removed some unnecessary parts of code that were not doing anything except slowing the engine down.




The Infected AI should then take control of empires 2, 3, 4, 5, 6, etc.
It will not control Player 0 or Player 1.
The AI should perform well in any situation provided you closely follow the implementation instructions.  If your level gives the AI problems, please let me know!!
You need to make sure that the AI has at least 1 asteroid to control.  If he isn't the owner of at least 1 asteroid with either 10+ seeds or 1+ tree, he won't do anything.
« Last Edit: January 05, 2011, 03:05:34 PM by annikk.exe »

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #1 on: December 22, 2010, 08:36:41 AM »
Notes for putting this in your level

1.  This COMPLETELY REPLACES the first version of Infected AI.  It's definitely not recommended to use them both in the same level.

2.  This AI will control as many factions as you want it to.  You don't need to paste multiple copies of the code or anything like that - the ability to control multiple empires and have them fight the player and each other is a key feature of the new version.  All you need to do to have multiple AIv2 factions in your level, is to create asteroids for players 2, 3, 4, 5, etc (whichever ones you want), and give their asteroids some seeds and/or dyson trees.  If an asteroid belongs to one of these empires and has at least 10 seeds or 1 dyson tree on it, the AI will start controlling it.  See the discussion near the bottom of the first page of this thread for more details.

3.  The AI should notice if under attack from a player mine.  (untested)  However, mines for all other factions are currently ignored.  AIv2 does not currently handle its own flowers or mines in any way.

4.  Currently the AI engine constantly renames all of the asteroids on the map to whatever the metric number of that asteroid is.  The metric number is what is used to determine the path seedlings should take to get where they are needed.  Being able to see at a glance what metric a particular asteroid has is a huge help with troubleshooting the AI engine, so I decided to leave this in for the beta version.



Bugs:

- Partitions with only fully-built friendly neighbours but no enemy neighbours or blank neighbours, keep all their asteroids on metric 500, rather than grouping their seeds up or shuffling them around somehow.  This is somewhat of an issue on maps with moving asteroids.

- EFFICIENCY: Regarding the code for sending the seeds to the next lowest metric.  Currently, the check to see if this is a player asteroid is nested deep inside the For loops.  This is inefficient; a better way would be to carry out the check right at the start of the "Send Seeds To Next Lowest Metric" code, and simply not bother running any of the code if checkedroid.owner == 1 or 0.

- EFFICIENCY: As above, but for the "launch attack" code.  It might be easiest to simply include a giant If Statement that rules out any actions being carried out if checkedroid is a player asteroid.  This is conceptually the easiest way to understand it as well, and would remove some detail from the complicated For loops inside the actions section.

- EFFICIENCY: Found some erroneous code that doesn't need to be there.  It talks about "gatherpointsallowed" and carries out some checks to set a variable of the same name.  However, the variable is never used, so this just represents precious clock cycles going to waste.

- Treeless asteroids belonging to player 0 are eroneously considered "friendly" asteroids even when there are actually greys present at the asteroid.  The naive AI sends his 10 colonising seeds there, and they get slaughtered.  :P

- Adjacent single-asteroid partitions belonging to different empires both become gather points, and can reach a situation where one reaches the spawncap, but does not attack because the other orphan asteroid has almost as many seedlings.  I need a special trap for this situation to get the orphans to attack when they reach their spawn cap.

- After capturing an asteroid, its gather metric is reset to 500.  I have seen some cases where this causes seedlings on the newly captured planet to instantly fly back to the gather point (which has metric 200).  A better solution would be to set newly captured asteroids to a metric of 200.  This would cause them to become gather points, meaning the seed army would stick around.  If they aren't valid as gather points they will be changed anyway on the next cycle. By removing the OnAsteroidTaken, set metric to 500 code, now when asteroids are taken they start with a metric of 0.  Nearby seeds will flood in to reinforce.  0 will be re-evaluated shortly thereafter and reset.

- In very action-packed games, the AI will wander about responding to attacks of 50 seedlings with a swarm of 2000.  This is excessive - the AI should make better use of these.



Wish List

- Ability to detect seedlings in flight
- When sending seeds to a neighbour, ability to tell if another (enemy) asteroid is in the way, whose seeds might snipe the travellers on the flyby.
- Ability to detect flowers, and plant them to make super seedlings and/or mines.
- Detect enemy AI mines as well as player mines
- It would be nice if the AI could recognise when he is already attacking, and send the reinforcements as they arrive at the gather point.
« Last Edit: December 30, 2010, 07:22:35 AM by annikk.exe »

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #2 on: December 22, 2010, 11:41:20 PM »
Anyone tried it?
I tried on my Infected Empire map, and also on a new gravity map that I'm making.  It avails itself quite well in either scenario, save for the bug (at the time of writing there is only one) listed above.

AWS

  • Achiever
  • Arboreal Being
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 275
Re: Calling all coders - please help me test Infected AI v2!
« Reply #3 on: December 23, 2010, 05:46:47 AM »
annikk, im really excited about this...i will try it asap and in my newest, unreleased map..(which currently has your AI.v1 code, tweaked for 2 enemy factions)

..i dread to think whats going to happen..
 ??? ;D

anticipating a swift death AWS

EDIT - will this control just 1 enemy's AI? do i need to do what i did before and change the values for a 2nd, 3rd, etc enemy?
« Last Edit: December 23, 2010, 05:56:29 AM by AWS »

AWS

  • Achiever
  • Arboreal Being
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 275
Re: Calling all coders - please help me test Infected AI v2!
« Reply #4 on: December 23, 2010, 05:51:50 AM »
ok, one thing...
do i need to completely remove all previous AI coding, and paste this in afresh??
or add it in addition to whats there already?

im assuming it will require pasting over ALL the old code...

aws

EDIT - its working with 1 AI right now... ;D

EDIT 2 - well, its now decided to crash on me! but i cant be sure it has anything to do with your code.
one error message im getting is the line in your code right at the start-

GetAsteroid(0): ChangeOwner(2)

- saying when loading the game 'attempt to index a nil value'

firstly, i dont know what that specifically refers to, or how to change it.
second, it may have nothing to do with your code as i have also added the rallypoint v.2 code at the same time.
intially it loaded fine, got to my second welcome text explaining how to use the rallypoints, and then it froze. 3 times at the same point.
but now it wont load at all..so, im a little lost with this one.

however, ill keep tweaking and see if i can rescue it before i lose the whole thing :(
lol.
« Last Edit: December 23, 2010, 07:26:16 AM by AWS »

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #5 on: December 23, 2010, 07:53:52 AM »
Quote
GetAsteroid(0): ChangeOwner(2)

Uh, that line isn't in my code...  Are you sure that's not leftover from something else?
And maybe the reason it is causing a crash is because of the erroneous space after the colon.  :>



For the avoidance of doubt, ALL the AIv1 code should be stripped out.


Also,

Quote
EDIT - will this control just 1 enemy's AI? do i need to do what i did before and change the values for a 2nd, 3rd, etc enemy?

Nope, it will control as many factions as you like.  You don't need to do anything special to the code at all.  Just make a level which has some asteroids belong to AI empires (like 2, 3, 4, 5, etc) and give some trees and/or seeds.  The AI will take control of it.  :>
« Last Edit: December 23, 2010, 07:57:54 AM by annikk.exe »

AWS

  • Achiever
  • Arboreal Being
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 275
Re: Calling all coders - please help me test Infected AI v2!
« Reply #6 on: December 23, 2010, 07:59:39 AM »
ok annikk. thanks.
for clarity - this is what it currently looks like (i havent tested this exact state yet as i wanted to post here before i forgot my question!)


GetAsteroid(0):ChangeOwner(2)

purgetimer = GetGameTime()  

   
   while GameRunning() do
   
      
      -- *** INFECTED AI V2 ***
      -- BETA VERSION 0.1


- the red text was there before, from previous code, and the black is your new AI copied into it just now.
do i need both red and black bits. or JUST from the while GameRunning loop...?

again , for clarity -
- before, i had 2 sets of your AI v1 code, one for enemy 2 and for enemy 3. ( i went through each line of your code to change the particular '2' values to '3' !! )
With this new v2 code, you're saying i can make do with just one code set for both/ all enemy AI's i want?
 ;D
« Last Edit: December 23, 2010, 08:03:20 AM by AWS »

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #7 on: December 23, 2010, 08:00:40 AM »
You don't need either of them.

Quote
or JUST from the while GameRunning loop...?

this.



PM me your code if you want, and I'll help you clear out the remnants of AIv1 :>

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #8 on: December 23, 2010, 08:04:52 AM »
Quote
however, ill keep tweaking and see if i can rescue it before i lose the whole thing :(

Go download Notepad++ !  It has basically unlimited undo levels.  It saves me all the freaking time.  If I totally mess something up, I can CTRL-Z my way back through hours and hours of work, looking at what I all changed.... and then just as easily CTRL-Y to fast forward through those changes.

Plus you can skin it, and it has tabs, and it colours all the different lua-specific things so that you can see typos and such.  It keeps nice tramlines for all your tabs and you can even minimize individual sections of code.

It's also totally free to download and takes seconds to install.  :>

AWS

  • Achiever
  • Arboreal Being
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 275
Re: Calling all coders - please help me test Infected AI v2!
« Reply #9 on: December 23, 2010, 08:11:11 AM »
oooh... nice program!! it looks just like dreamweaver / css now.

ok. ive added your v2 code and it works.
i have kept the old v1 for the other enemy and theres no issue as yet running both in the same script.
by what you say i can erase completely the 'copy' of the code so ill try that now and see what happens.

it seems to me now that it is a problem with the rallypoint V2 coding and not your fresh AI v2! :) which is good.. for you anyway!

will keep you posted.
thx as always.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #10 on: December 23, 2010, 08:18:40 AM »
You really should remove Infected AI v1.

The reason why I think this is that AIv2 is going to try to control AIv1's asteroids.  So whichever one of them thinks it's a good idea that the asteroid sends some seeds somewhere, will make the call - and the other AI will be unable to prevent it.
Apart from anything else, AIv1 has a HUGE processing overhead and it will probably slow down the computers of a lot of people that try to play it if you run 2 AI's at once.. :P


AIv1 was never really intended to be used by anyone else to be honest.  I'm surprised and intrigued that you managed to implement it into another level despite its shortcomings.  :>  Did you manage to figure out how it does what it does?  The code isn't exactly pretty.. :P

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #11 on: December 23, 2010, 08:26:10 AM »
Quote
again , for clarity -
- before, i had 2 sets of your AI v1 code, one for enemy 2 and for enemy 3. ( i went through each line of your code to change the particular '2' values to '3' !! )
With this new v2 code, you're saying i can make do with just one code set for both/ all enemy AI's i want?


Yes - this is correct.  :>  Honestly!
I'm trying to think how I can make this any more clear...  you just... you know when you create asteroids, like this:


a = AddAsteroidWithAttribs(x,y,e,s,s)
a.owner = 1


Well, just make AI asteroids like this:


a = AddAsteroidWithAttribs(x,y,e,s,s)
a.owner = 2
s = a:AddDysonTree()
a:AddSeedlings(50)

a = AddAsteroidWithAttribs(x,y,e,s,s)
a.owner = 3
s = a:AddDysonTree()
a:AddSeedlings(50)

a = AddAsteroidWithAttribs(x,y,e,s,s)
a.owner = 4
s = a:AddDysonTree()
a:AddSeedlings(50)




Now, as long as you have copied and pasted my AI code (ONCE only!) like I specified in the original post, the AI will now control factions 2, 3 and 4 for you.
Each of those factions will attempt to colonise the galaxy, capture each others planets, and so on.

You don't need to do anything else.  Just make roids, trees and seeds for the factions you want.  :>


Hopefully this is good and clear now.  ^_^

AWS

  • Achiever
  • Arboreal Being
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 275
Re: Calling all coders - please help me test Infected AI v2!
« Reply #12 on: December 23, 2010, 08:32:56 AM »
You really should remove Infected AI v1.
AIv1 was never really intended to be used by anyone else to be honest.  I'm surprised and intrigued that you managed to implement it into another level despite its shortcomings.  :>  Did you manage to figure out how it does what it does?  The code isn't exactly pretty.. :P
hehe.... lol.
well, all i can really tell you is that i wanted to have the AI for 2 enemies. so i did the logical thing and copied it!
i then went through and where i thought it was referring to the enemy 2, i changed it to 3.
how much effect it had i really couldnt say.
in addition, and ive only now, after all this time just realised it, i had the Global's for enemy3 active as well.
- so i dont really know what the code did what in game, but it worked. and i did notice the game step up a notch :)

anyway, i have now removed the erroneous copied code and have just the new v2 in place.
needless to say, its all totally beyond me. but i trust in the process so im expecting good things.
also, i havent played my level for a few months now. ive been so busy with various home things that i just havent been able to get into it. not to mentionm having no regular internet access for a long time either.

so, where i am now is that i have 1 copy of your new v2 code and it works. which is good.
next is to try and get Pilchard's rallypoint v2 code to work as well. i like his new grey slider bar. but i dont like its positioning on-screen. but first i need it to work.

EDIT - lol. sorry for reiterating my concern. i couldnt figure out how one code can control multiple factions at once! but i see your explanation now and its a little clearer. sorry, it takes some time for me to get my head round all this mathematical stuff. it always has, it probably always will..
:D

AWS

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #13 on: December 23, 2010, 08:45:06 AM »
I can imagine that having 2 copies of Infected AIv1 would mean that the two different empires would read each other's metrics.
This is quite interesting because it means, for example, if one AI attacks the other, then they BOTH think they are the one that is under attack.  :P  So they would both spam reinforcements from their entire empire and it would become an all-consuming war, when a much more viable strategy might be to continue peacefully colonising the galaxy, and swarming up...

It's interesting thinking about it, but to be honest the complexity of AIv1 is so great that it's hard to figure out exactly what the results would be.  If you hadn't already told me that it worked, I would have expected it to crash.. :P


Quote
EDIT - lol. sorry for reiterating my concern. i couldnt figure out how one code can control multiple factions at once! but i see your explanation now and its a little clearer. sorry, it takes some time for me to get my head round all this mathematical stuff. it always has, it probably always will..

It's ok.  :>
The dev blog I wrote/spammed recently about the development of AIv2 probably goes some way to explaining it.

The simplest explanation I can think of is that when an asteroid is selected for checking, it only exchanges metric information with neighbouring asteroids that are owned by the same empire.  Those are also the only asteroids it considers as "friendly".  If a neighbouring asteroid is owned by an empire other than checkedroid.owner then it must clearly be an enemy.

The key is that it's possible to check who owns checkedroid, and also who owns a given neighbouring asteroid.  Because if this, it's possible to figure out if the neighbours are friends or not.

This approach works whether you are checking an empire 3 asteroid, or an empire 5 asteroid, or whatever.  :>

AWS

  • Achiever
  • Arboreal Being
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 275
Re: Calling all coders - please help me test Infected AI v2!
« Reply #14 on: December 23, 2010, 08:57:04 AM »
I can imagine that having 2 copies of Infected AIv1 would mean that the two different empires would read each other's metrics.
This is quite interesting because it means, for example, if one AI attacks the other, then they BOTH think they are the one that is under attack.  :P  So they would both spam reinforcements from their entire empire and it would become an all-consuming war, when a much more viable strategy might be to continue peacefully colonising the galaxy, and swarming up...

It's interesting thinking about it, but to be honest the complexity of AIv1 is so great that it's hard to figure out exactly what the results would be.  If you hadn't already told me that it worked, I would have expected it to crash.. :P

 - this is a most intriguing scenario. perhaps there will be a way to consider both potentialities of spamming each other head-on for gratuitous warring, but only above a certain seed count, and/or then grouping elsewhere nearby to act as counter attacking forces or even pincer movements?! then it really would be hard  :P ;D


annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #15 on: December 23, 2010, 09:41:00 AM »
Quote
- this is a most intriguing scenario. perhaps there will be a way to consider both potentialities of spamming each other head-on for gratuitous warring, but only above a certain seed count, and/or then grouping elsewhere nearby to act as counter attacking forces or even pincer movements?! then it really would be hard  :P ;D


You could make something like that, but it would be best to design the code with that intention in mind.  Otherwise you would get all sorts of other side-effects that might not be desireable.

That said, my code isn't copyrighted or anything like that - I post it here for all to use as they wish - so if you really want to try it then go ahead.  :>


The AI in v2 attacks for one of two reasons:

1)  It has at least 300 seeds at the gather point.
2)  It has more seeds(at the gather point than all of the gather point's neighbours put together.

It's only able to "see" seedlings that are on an asteroid, though.  Seedlings travelling between asteroids are invisible to the AI.

I might be able to address that at some point, I think it's possible to select seedlings in an area, maybe its possible to query their number too.  But for now, the above is how it works.
« Last Edit: December 23, 2010, 09:07:41 PM by annikk.exe »

AWS

  • Achiever
  • Arboreal Being
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 275
Re: Calling all coders - please help me test Infected AI v2!
« Reply #16 on: December 24, 2010, 04:29:41 AM »
well -
first reports are that im a little confused why the AI isnt doing anything. (yes, many roids start off with much more than 10seedlings and/or 1dyson tree)

on nearly all enemy roids that i can see, with at least 20-50 seedlings on them, theyre not doing any planting or colonizing. in fact, looking at them for longer periods, theyre not doing anything at all.
im not sure if its to do with my setup, but im pretty sure they should be doing a lot more tree planting, or deciding to move on elsewhere...
this applies to both enemy AI's...

hmm??

EDIT - ive now had the game running without doing anything for over an hour and none of the seedlings are doing anything. no building or moving. nowt!
i wonder why??
:(
« Last Edit: December 24, 2010, 05:34:34 AM by AWS »

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #17 on: December 24, 2010, 07:08:34 AM »
Did you try pressing tilde to bring up the console, and see if there is an error message there?

If the seeds didn't do anything after 20 seconds, it's not working.. :P

PM me your code and I'll have a look.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #18 on: December 25, 2010, 10:34:31 PM »
I had a look.
The reason it's not working is that you did not put the AI init code at the end of your Function LevelSetup().  In your code, it appears after function LevelSetup() has already ended... in no man's land, between functions...

Code: [Select]
function OnAsteroidSelected(id)              --select an asteroid to rally at

   if GetEmpire(1):OwnsAsteroidID(id) then
  
      selectedid = id
      
   end  
  
end



-- *** INFECTED AI V2 INIT ***
   -- BETA VERSION 0.1
   -- Author: ANNIKK.EXE [at] GMAIL [dot] COM
  
  
   Globals.AI.GraceTimer=(99999)
  
   -- Number of times the engine is run per While loop:
   numberofiterations = 1
   -- Set to 0 for very large maps. (50 asteroids+)
   -- Set to 2-4 for small maps for quicker AI response.
  
   metric = {}
  
   for i = 0,200 do
      metric = 500
   end
  

-- *** END INFECTED AI INIT ***


function LevelLogic()

It's not inside function Level Setup!


To fix, you need to put the code somewhere like this:


Code: [Select]
--Rallypoint variables
   pointexists = false
   pointid = 0
   selectedid = 0
  
  
--Added DrawBox(textureID, borderradius, left, top, right, bottom, r, g, b, a)
   --Rallying button customisation
   buttonleft = 950
   buttontop = 660
  
   barleft = 1010
   bartop = 660

   sliderpos = barleft

  
  
   -- *** INFECTED AI V2 INIT ***
   -- BETA VERSION 0.1
   -- Author: ANNIKK.EXE [at] GMAIL [dot] COM
  
  
   Globals.AI.GraceTimer=(99999)
  
   -- Number of times the engine is run per While loop:
   numberofiterations = 1
   -- Set to 0 for very large maps. (50 asteroids+)
   -- Set to 2-4 for small maps for quicker AI response.
  
   metric = {}
  
   for i = 0,200 do
      metric = 500
   end
  

-- *** END INFECTED AI INIT ***
  
  
  
end

function ScreenDraw()
  
   DrawBox(0, 0, buttonleft, buttontop, buttonleft+50, buttontop+50, 0, 0, 0, 0.5) -- draws switch for quickrally
   DrawBox(0, 0, barleft, bartop, barleft+250, bartop+50, 0, 0, 0, 0.5)   -- draws slider BG


Hope this helps! :>
« Last Edit: December 25, 2010, 11:49:59 PM by annikk.exe »

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #19 on: December 25, 2010, 10:36:56 PM »
I updated the instructions in the initial post to make it clearer that the init code must occur inside Function LevelSetup().

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #20 on: December 25, 2010, 10:44:33 PM »
There's an additional problem with your Function LevelLogic.


Code: [Select]
function LevelLogic()


-- ** Greeting ** --


   Timer = GetGameTime() + 16


   while GetGameTime() < Timer do

      coroutine.yield()
   end

You should not do it this way imho.  This method will cause the AI code to not be run for the first 16 seconds...



Code: [Select]
-- ** Colourwave/ pulsing effect ** --
  
   Timer = GetGameTime() + 1


   while GetGameTime() < Timer do

      coroutine.yield()
   end

There is an additional 1 second pause here.

Then, finally, we reach our GameRunning() do:

Code: [Select]
  while GameRunning() do

   --rtime = GetGameTime()    -- setting the variable 'time' to whatever the game time is
   --rtime = rtime / 60     -- taking that 'time' variable and dividing it by n.  divide slows down. multiply speeds up.
   --gtime = GetGameTime()
   --gtime = gtime / 225
   btime = GetGameTime()
   btime = btime / 320

   --gcolour = math.sin(gtime)    -- setting the variable 'rcolour' to wave up and down. like this the range is now -1 to 1. 1 being the peak of the wave and -1 being the trough. with the horizontal axis as 'time', in this case the 'time' variable.

   --gcolour = gcolour * gcolour     -- square rcolour, if it is negative this will make it positive
   --gcolour = math.sqrt(gcolour)    -- now take the square root of it

      --gcolour = gcolour * 2       -- setting the range of 'rcolour' from 0 to 255. in this case the 'r' referring to 'red', multiplied by n. do the same with 'g' and 'b'
  
   --gcolour = math.sin(gtime)    -- speed of variance
   --gcolour = gcolour * 30

   bcolour = math.sin(btime)
   bcolour = bcolour * bcolour
   bcolour = math.sqrt(bcolour)

      bcolour = bcolour * 5


   bcolour = math.sin(btime)
   bcolour = bcolour * 16


   --rcolour = math.sin(rtime)    -- setting the variable 'rcolour' to wave up and down. like this the range is now -1 to 1. 1 being the peak of the wave and -1 being the trough. with the horizontal axis as 'time', in this case the 'time' variable.

   --rcolour = rcolour * rcolour     -- square rcolour, if it is negative this will make it positive
   --rcolour = math.sqrt(rcolour)    -- now take the square root of it

      --rcolour = rcolour * 18        -- setting the range of 'rcolour' from 0 to 255. in this case the 'r' referring to 'red', multiplied by n. do the same with 'g' and 'b'
  
   --rcolour = math.sin(rtime)    -- speed of variance
   --rcolour = rcolour * 45

   SetBackdropColour(0,2,bcolour)    -- makes the background change between colours. 0 is black/min. 255 is white/max


-- ** Victory Trigger ** -- for 2 enemies
        

      if GetEmpire(2):GetNumOwnedAsteroids() == 0 and GetEmpire(3):GetNumOwnedAsteroids() == 0 then

      Timer = GetGameTime() + 5   -- enables a pause between conquering the roid and the end game message.


      while GetGameTime() < Timer do

      coroutine.yield()
      end

Also, look at the part at the bottom.
The AI will stop running for 5 seconds if this code gets activated.  Mind you, I guess it only happens when you've won/lost so not really a biggie.  Still, I would suggest avoiding the use of additional nested While loops within your While GameRunning()... :>



Finally, I came to this bit - and this is definitely causing the AI to not work.

      
Code: [Select]
     Pause()
      MessageBox("You have controlled The Entire Region. This is most excellent news!                                                                                            Be pleased that you have conquered another bunch of pesky inter-galactic hooligans.")
      WaitDialog()
      Unpause()
      Quit(true)
      end
      
      

      if GetEmpire(1):GetNumOwnedAsteroids() == 0 then
      Pause()
      MessageBox("Calamity!!! Total DEFEAT!!! You must try harder...                                                                                            ...The Central Region is a hostile place indeed...")
      WaitDialog()
      Unpause()
      Quit(false)
      end

   coroutine.yield()
   end


Oh dear.  That seems to be the end of the While GameRunning() loop.

So all code below this will NEVER be run.
Including the entire AI engine.

Below this, the AI engine is given its own Whiel GameRunning() loop but that will never be activated because the first While GameRunning() will never finish.

If I were you, I would use a single While loop for the whole code.  There is no reason to have multiple ones.
« Last Edit: December 26, 2010, 09:41:04 AM by annikk.exe »

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #21 on: December 25, 2010, 11:22:16 PM »
I've attached some example files to the initial post to show you how to implement the AI into a level.  Hopefully that should make it clearer.  :>

AWS

  • Achiever
  • Arboreal Being
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 275
Re: Calling all coders - please help me test Infected AI v2!
« Reply #22 on: December 26, 2010, 11:16:49 AM »
oh dear.
seems i messed that up a little. thanks for the use of your eyes!

ill implement these things asap...


annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #23 on: December 26, 2010, 08:00:50 PM »
Ok, let us know how you get on.  :>

AWS

  • Achiever
  • Arboreal Being
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 275
Re: Calling all coders - please help me test Infected AI v2!
« Reply #24 on: December 27, 2010, 06:09:07 AM »
does your code rename all the roids with numbers? it seems like it...

otherwise, ive managed to get the AI to work without crashing, freezing or reporting multiple errors. good news!

will report on AI's quality after this test run...

aws

EDIT -
1- lots of flowers not being planted - (i know youve earmarked this as a bug though, so... )
2- all roids are maxed at 50 but seemingly no gathering of larger forces, just lots of maxed roids.
3- when i conquer a roid, then remove my seedlings from it, the enemy doesnt try and recapture it. happens on all roids ive tried this with, so far...
4- following on from no.3, when im attacking, they dont send any aid for themselves, they leave their friends to perish :(
« Last Edit: December 27, 2010, 06:52:57 AM by AWS »

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #25 on: December 27, 2010, 07:38:59 AM »
Quote
does your code rename all the roids with numbers? it seems like it...

It does, yes.  This is for debugging purposes so I suggest to leave it in, for now.

The numbers indicate the metric of that asteroid.

If you attack an AI asteroid, its metric (and therefore its name) should change to 0.  If this isn't happening, the AI is not working properly and nearby asteroids will likely not send any aid.
When an asteroid has less trees than maximum, it's set to 100.
And when they decide to use an asteroid as a "gathering up point", prior to attacking, it is set to 200.

Are you seeing this behaviour from the AI?  Specifically, are asteroids changing to 0 when attacked?  It sounds like something might be going wrong because the AI ought to respond vigourously if attacked, and ought to constantly be shuffling its seeds around everywhere the rest of the time.  Can you PM me your code again and I'll take a look? :>

AWS

  • Achiever
  • Arboreal Being
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 275
Re: Calling all coders - please help me test Infected AI v2!
« Reply #26 on: December 27, 2010, 08:17:29 AM »
sent.
you'll have to play for about 15mins or so till you get to see more than one enemy at once.
:)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #27 on: December 27, 2010, 08:41:19 AM »
Just reading through it:

1.  Your function ScreenDraw is inside your function LevelSetup, as is your function OnMouseLeftDownScreen(x,y), function OnMouseLeftUpScreen(x,y), and function OnAsteroidSelected(id).  These should not be nested inside Function Level Setup.  They are seperate functions entirely and should appear below function LevelSetup's end.

2.  You still didn't put everything inside a single "While" loop.


I've made a few adjustments.  Have a look at the code I'm sending you.  See if that works any better :>


Edit... wait.... there _is_ something wrong...  I'm getting a problem indexing metric properly.
« Last Edit: December 27, 2010, 08:59:32 AM by annikk.exe »

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #28 on: December 27, 2010, 09:04:16 AM »
Right, found it.

For some reason the square brackets were removed from "metric" in the initialisation code.

Code: [Select]
for i = 0,200 do
metric = 500
end


But it should actually be:

Code: [Select]
for i = 0,200 do
metric[i] = 500
end


I think what is happening is that the forum converted it into italics...  :P
You should send it in a code box next time.  ;)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #29 on: December 27, 2010, 09:16:05 AM »
That level looks excellent by the way.  And the AI takes to it really well.  I think we're in for a treat.. :>

AWS

  • Achiever
  • Arboreal Being
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 275
Re: Calling all coders - please help me test Infected AI v2!
« Reply #30 on: December 27, 2010, 09:21:31 AM »
ok, well,
the only reason why there is, i think, now 2 While loops going on is that- with just the one before my Greeting, and no End for that loop, it would repeat endlessly ingame, both intro messages, requiring Ctrl-Alt-Del again.
so i just used a 2nd loop after 'End'ing the greeting loop, and went from there.
if you've made it work with one loop i'd love to know how you didnt get the same repeating greeting problem i did?

as far as the rally code goes, i merely copied and pasted it into my code from where he has it in his example file, ie, before the end of levelsetup.
you're saying this this 1st part of the rallypoint code should be in between LevelSetup and LevelLogic, in its own little land somewhere?!if so, why?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #31 on: December 27, 2010, 09:46:50 AM »
ok, well,
the only reason why there is, i think, now 2 While loops going on is that- with just the one before my Greeting, and no End for that loop, it would repeat endlessly ingame, both intro messages, requiring Ctrl-Alt-Del again.
so i just used a 2nd loop after 'End'ing the greeting loop, and went from there.

You always need a "coroutine.yield() end" for each While loop.  The level won't load otherwise.
You really should only use While GameRunning() once.  The logic there is that the game is ALWAYS running, so the loop will be neverending.  Therefore, any code that appears after the coroutine.yield() end will never be run.


Quote
if you've made it work with one loop i'd love to know how you didnt get the same repeating greeting problem i did?

Yes, that is a problem isn't it.
We can say, "timer = 6", and then we can say if GetGameTime > timer then we can bring the messagebox up.
But the next frame, it's still more than timer... so another messagebox appears... then another, and another...

We need a "latch" to stop it.

The easiest way to build a latch is to use a "latch = false" variable.

Then you can do this:

Code: [Select]
latch = false
timer = 6

While GameRunning() do
-- first, lets do the greeting.
if GetGameTime() > timer and latch == false then
MessageBox("Welcome!")
latch = true
end

-- rest of the code goes here...

coroutine.yield()
end



Quote
as far as the rally code goes, i merely copied and pasted it into my code from where he has it in his example file, ie, before the end of levelsetup.
you're saying this this 1st part of the rallypoint code should be in between LevelSetup and LevelLogic, in its own little land somewhere?!if so, why?

Not all of it, but most of it.
Most of the code is actually seperate functions - as in, they are seperate from Function LevelSetup() and Function LevelLogic().
If you ever see "function", it means that it has to go in no man's land.  By convention, drawing stuff seems to go between LevelSetup and LevelLogic, wheras OnAsteroidTaken and any other asteroid-related ones go below LevelLogic.  I am not sure if it has to be this way or not, but it seems like a good standard so that everyone always knows where to find each section.  :>

I said some, but not all.  Some of the code goes inside Function LevelSetup() and some goes inside Function LevelLogic().
I actually ran into a problem on line 750 of the code I sent to you.  It's part of the Rally Point code.  It caused the While loop to stop (error message was revealed by pressing Tilde (`) to bring up the console).  I commented out the For loop in question and ran it again, and the AI aggressively expands and the two factions even fight over the large asteroid owned by the Greys :>
Maybe you could ask Pilchard to have a look at it for you.  In the mean time I'll PM you a copy of the code that I'm running right now so you can check it out.  :>
« Last Edit: December 27, 2010, 08:54:28 PM by annikk.exe »

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Calling all coders - please help me test Infected AI v2!
« Reply #32 on: December 27, 2010, 07:07:22 PM »
Ah. That for loop is the only one in the RP code and kind of...makes it work. How does it break it, exactly?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #33 on: December 27, 2010, 08:51:06 PM »
It's detecting "numroids" as being incorrect, or something.  I forget the exact error message, but basically after a few seconds of game time, it crashes and brings up that error in the console.

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Calling all coders - please help me test Infected AI v2!
« Reply #34 on: December 27, 2010, 09:15:13 PM »
Does the level have moving or created/destroyed asteroids? That might do it.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #35 on: December 27, 2010, 10:00:43 PM »
I didn't see any.  The trouble is coming with this line:


Code: [Select]
for roidtocheck=0,numroids-42 do
Is that definitely the right way to declare the number of asteroids?
I would have thought "numroids" would be declared in the LevelSetup, and then simply referred to later.
In fact, "numroids" appears nowhere else in the code, so the reason it's crashing would seem to be because it's trying to treat a variable (numroids) as a number value, when it hasn't been declared and is therefore equal to nil.

AWS

  • Achiever
  • Arboreal Being
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 275
Re: Calling all coders - please help me test Infected AI v2!
« Reply #36 on: December 28, 2010, 01:04:08 AM »
Does the level have moving or created/destroyed asteroids? That might do it.
no, all static roids. nothing fancy like movers in this one.

- also, im pleased they fight over the main 'grey' roid...that was part of my plan for the map...good :D

aws

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Calling all coders - please help me test Infected AI v2!
« Reply #37 on: December 28, 2010, 02:44:43 AM »
AH! That shouldn't be numroids-42, but numroids-1 Try that.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #38 on: December 28, 2010, 03:03:22 AM »
You still need to specify a value for "numroids" to begin with.  Otherwise its value will be "nil" (which is different from "0") and the game won't be able to carry out mathematics on it becuase it's "not a number", and so will stop working.

I think that AWS needs to put something like "numroids = 42" in his function LevelSetup.  The "-1" bit I presume is because you're starting a "for" loop on 0, but most coders will actually number their asteroids from 0.... so I'd suggest that the "-1" is actually unnecessary.

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Calling all coders - please help me test Infected AI v2!
« Reply #39 on: December 28, 2010, 03:37:15 AM »
numroids isn't (read:shouldn't) be nil, I set it to 4 in the demo map. I might change it to use the IDs of the asteroids and put in your for loop too. *scripts*

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #40 on: December 28, 2010, 04:08:19 AM »
Well that is missing from the code AWS sent me.  In the level he sent, numroids is never declared.
I'm guessing this is at least part of the problem...

AWS

  • Achiever
  • Arboreal Being
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 275
Re: Calling all coders - please help me test Infected AI v2!
« Reply #41 on: December 29, 2010, 01:12:59 AM »
hm... i was wondering if it should be an = sign rather than a - sign followed by the number of roids.
but still, where is the declared numroid code? im pretty sure i copied everything from pilchards code verbatum


annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #42 on: December 29, 2010, 04:00:53 AM »
I would have thought that it should appear in function LevelSetup(), alongside the other rally point code.

Just declare the variable like this:

Code: [Select]
numroids = 42
Then in that for loop, you don't need "numroids - 1" or "numroids - 42".  You don't need to subtract anything from it, I think...


Alternatively you could strip out all the rally point code and just add the new version.

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Calling all coders - please help me test Infected AI v2!
« Reply #43 on: December 29, 2010, 04:12:16 AM »
Unfortunately, you did in the old version - it worked on the number of 'roids, not IDs. The new version just needs to be copied over, with nothing done to it.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #44 on: December 29, 2010, 04:28:43 AM »
Sweet :>

By the way, maybe you should make more mention in your initial post of the fact that the code contains a bunch of functions which don't belong in either LevelSetup or LevelLogic, but rather in the area that lies between them.  The code AWS sent me seems to suggest that's something he was tripping up over.  All of the functions (eg function OnMouseLeftUpScreen(x,y)) were in his LevelSetup.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #45 on: December 30, 2010, 09:34:01 AM »
Just spent an hour trying to fix 1 stupid bug.  The problem looked obvious, I couldn't understand why my fix wasn't working.

I only just worked it out.

I was looking at the wrong freaking file.

>.<

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #46 on: December 30, 2010, 12:50:45 PM »
Well, after another mammoth coding session, that's v0.2 done.

This new version brings new features, behavioural changes, and efficiency improvements.
See the original post in this topic for full details.  :>

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #47 on: December 31, 2010, 02:14:20 AM »
Here's a list of new things that will be in the next version, 2.3.


  • If invaded, the AI will leave some seedlings from the main swarm to finish off any attackers once the main part of the attack is over, rather than charging off again as soon as the attackers are reduced to below about 20.
  • In v2.2 the AI would occasionally sit on 2 adjacent fully-built asteroids, both with metric 500, and do nothing for several minutes - for no apparent reason.  This is fixed.
« Last Edit: December 31, 2010, 02:26:42 AM by annikk.exe »

AWS

  • Achiever
  • Arboreal Being
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 275
Re: Calling all coders - please help me test Infected AI v2!
« Reply #48 on: December 31, 2010, 05:07:39 AM »
test no.2 -

im 4 roids in to my 42 roid map, barely even begun, and i attack with 150seedlings to an empty but fully dyson-tree built roid. within 5 seconds im swarmed by over 1200enemy seedlings.!!!! ??? :o
i cant even break out of my own starting 'safe zone'....

 how does one edit or tweak these kinds of variables?!

 ;)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #49 on: December 31, 2010, 05:16:44 AM »
Have you tried reducing the amount of seeds the AI starts with?

AWS

  • Achiever
  • Arboreal Being
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 275
Re: Calling all coders - please help me test Infected AI v2!
« Reply #50 on: December 31, 2010, 06:14:53 AM »
yeah. am in the process of tweaking a few things actually. but that was my main focus.
i think im going to have to alter the way the player starts the map too. its a bit too 'tunnel' like in the early game, esp. with this AI ! :)
- by way of roid placement, player ID's, etc, as well as seed counts, etc (+more roids)
im also increasing the explosion power radius for mines to be a lot more powerful and useful as offensive weaponry against these massive swarms that can occur.
being outnumbered 10/15:1 isn't good  8)
plus, i think mines should be more... mine-like, not just a useful laser-weapon but upon death also, they should have some weighty impact, imo.

aws

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #51 on: December 31, 2010, 06:20:33 AM »
Hmm, it might be possible to write some special code to destroy all enemy seedlings around a planet when a mine dies...

Rudolf

  • Administrator
  • Old Oak
  • *****
  • Thank You
  • -Given: 5
  • -Receive: 13
  • Posts: 669
  • Eufloria: Yes
Re: Calling all coders - please help me test Infected AI v2!
« Reply #52 on: December 31, 2010, 07:45:04 AM »
yeah. am in the process of tweaking a few things actually. but that was my main focus.
i think im going to have to alter the way the player starts the map too. its a bit too 'tunnel' like in the early game, esp. with this AI ! :)
- by way of roid placement, player ID's, etc, as well as seed counts, etc (+more roids)
im also increasing the explosion power radius for mines to be a lot more powerful and useful as offensive weaponry against these massive swarms that can occur.
being outnumbered 10/15:1 isn't good  8)
plus, i think mines should be more... mine-like, not just a useful laser-weapon but upon death also, they should have some weighty impact, imo.

aws

I am toying with the idea of making mine deaths more destructive. Partially due to the super seedlings slightly unbalancing play at the moment. Not that I think it is a huge problem though. 

AWS

  • Achiever
  • Arboreal Being
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 275
Re: Calling all coders - please help me test Infected AI v2!
« Reply #53 on: January 01, 2011, 06:21:30 AM »
yeah. am in the process of tweaking a few things actually.
...
im also increasing the explosion power radius for mines to be a lot more powerful and useful as offensive weaponry against these massive swarms that can occur.
being outnumbered 10/15:1 isn't good  8)
plus, i think mines should be more... mine-like, not just a useful laser-weapon but upon death also, they should have some weighty impact, imo.


I am toying with the idea of making mine deaths more destructive. Partially due to the super seedlings slightly unbalancing play at the moment. Not that I think it is a huge problem though. 

:D
yes, i have been toying with the idea for a while now. at first i thought it wasnt necessary to increase this side of mine-related death but with annikk's AIv2, i feel its about time. there should be greater depth to one's options.
so far, ive got my flowers with 7 'petals' and have been experimenting with a slightly increased detection radius to start blasting away from further away, but with each petal being very slightly weaker. then upon death, blasting into a surprisingly large burst as a final goodbye to the enemy!
i like the theory, but getting it right in game is harder...
...we'll get there though

aws

AWS

  • Achiever
  • Arboreal Being
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 275
Re: Calling all coders - please help me test Infected AI v2!
« Reply #54 on: January 01, 2011, 08:58:57 AM »
test 3. i look away from the screen for 2minutes to see annikk's gorgeous kitten pics and then when i click back to the game i see the enemy has taken over all bar 2 of my roids!!!
im being annihilated over and over...

i feel small and pathetic  :'(


Bonobo

  • Achiever
  • Old Oak
  • ****
  • Thank You
  • -Given: 139
  • -Receive: 12
  • Posts: 670
  • Eufloria: Yes
Re: Calling all coders - please help me test Infected AI v2!
« Reply #55 on: January 01, 2011, 09:25:33 AM »
Yeah, Annikk’s AI uses vicious tactical kittenz which reach even out of the game …

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #56 on: January 01, 2011, 11:27:13 AM »
The AI should probably start with about the same about of seedlings (and dyson trees) as the player.. :>

AWS

  • Achiever
  • Arboreal Being
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 275
Re: Calling all coders - please help me test Infected AI v2!
« Reply #57 on: January 01, 2011, 11:28:49 PM »
ah. ok.
at the mo they start with about twice as many...

i had a most excellent game last night. testing things out. discovered some radius/ send dist. issues but only managed to get half way through my map. which took over 1.5hrs. there isnt one minute of let up from the enemy. its utterly relentless!
ive also been writing a dev blog in notepad to go along with this release. it details all my processes for those who care about such things.  ;)
needless to say, epic is a word for the constant feeling of battle-hardening you get with this AI engine.
you've got a masterpiece here annikk.

is it possible for the user, ie me, to alter the AI's determinations? eg, instead of only attacking after they have over 300seeds, i can change that to 200 or 400, etc? or other variables? or is it written that it a closed container of code?
just wondering how much, if any, control an individual can have on your code..


aws

AWS

  • Achiever
  • Arboreal Being
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 275
Re: Calling all coders - please help me test Infected AI v2!
« Reply #58 on: January 02, 2011, 05:27:32 AM »
annikk. your addition to my victory condition code has meant that the 'win' message does not pop up at the end of the level.
can you take a look at tell me why, pls?

Code: [Select]
if GetEmpire(2):GetNumOwnedAsteroids() == 0 and GetEmpire(3):GetNumOwnedAsteroids() == 0 then

if Timer < GetGameTime() + 5 then -- annikk's additions
Timer = GetGameTime() + 5 -- enables a pause between conquering the roid and the end game message.
end

if Timer == GetGameTime() then

Pause()
MessageBox("You have controlled The Entire Region. This is most excellent news!   Be pleased that you have conquered another bunch of pesky inter-galactic hooligans.")
WaitDialog()
Unpause()
Quit(true)
[color=red]end[/color]
end


if GetEmpire(1):GetNumOwnedAsteroids() == 0 then
Pause()
MessageBox("Calamity! Total DEFEAT! ...The Central Region is a hostile place indeed... ")
WaitDialog()
Unpause()
Quit(false)
end

is the 'end' i tried to highlight in red, unnecessary? i cant see why its there. the win conidition has it but the loss does not. and the loss message certainly does show upon defeat. however, upon taking it out and testing it, the level wont load so ive left it in.
otherwise its something to do with your timer addition methinks...

AWS

  • Achiever
  • Arboreal Being
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 275
Re: Calling all coders - please help me test Infected AI v2!
« Reply #59 on: January 02, 2011, 05:29:33 AM »
oh, and hows beta 0.2 coming along? is it ready to use yet?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #60 on: January 02, 2011, 06:11:25 AM »
I've reorganised the tabs to make this a bit clearer.


Code: [Select]
if GetEmpire(2):GetNumOwnedAsteroids() == 0 and GetEmpire(3):GetNumOwnedAsteroids() == 0 then

if newtimer == nil then
newtimer = GetGameTime() + 5
end

if newtimer <= GetGameTime() then
Pause()
MessageBox("You have controlled The Entire Region. This is most excellent news! Be pleased that you have conquered another bunch of pesky inter-galactic hooligans.")
WaitDialog()
Unpause()
Quit(true)
end
end


if GetEmpire(1):GetNumOwnedAsteroids() == 0 then
Pause()
MessageBox("Calamity! Total  DEFEAT! ...The Central Region is a hostile place indeed... ")
WaitDialog()
Unpause()
Quit(false)
end

The end is necessary.  Give me a minute to look over this and I'll see if I can figure out what's wrong.  :>


UPDATE:  Try that.  :>
« Last Edit: January 02, 2011, 06:17:05 AM by annikk.exe »

AWS

  • Achiever
  • Arboreal Being
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 275
Re: Calling all coders - please help me test Infected AI v2!
« Reply #61 on: January 03, 2011, 03:18:45 AM »
thx.

let us know when the latest version is done wont you?! ;D

what are the additions being added?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #62 on: January 03, 2011, 04:33:22 AM »
Just random bug fixes to stop the AI getting flummoxed by unusual situations.  I can't remember if I added any new features, per se.


I'll go update the main post now.  By the way, I've discovered (thanks to Cousin Joel) that it's possible to just organise my different modules into functions.
Here they all are:


You can click the "+" next to each function and it will expand out, so you can see the code inside.  :>


Then inside LevelSetup(), I use the following command:

AIInit()

and that initialises the AI engine.
Then, in function LevelLogic(), I use this command:

InfectedAIEngine()

And then the engine just works just like it does normally.  :>


Pretty handy for keeping things organised..

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Calling all coders - please help me test Infected AI v2!
« Reply #63 on: January 03, 2011, 04:43:17 AM »
That's the new engine posted.

AWS

  • Achiever
  • Arboreal Being
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 275
Re: Calling all coders - please help me test Infected AI v2!
« Reply #64 on: January 03, 2011, 07:44:21 AM »
{mister burns voice}
excellent...