Monday, April 16, 2012

A different kind of AI. Feasible?

First a little about me:



I'm a software developer by trade and if you're into tading in eve-online you may have used the EMMA helper app that I wrote. I mention this just so you know I'm happy with the technical-nus of all this. :wink:



In sup com, I've played quite a few vanilla ranked match, a handful of FA ranked matches, a couple of random team games, a few games over Hamachi with my brothers and lots and lots of skirmishes against AIs. In other words, I've done at least a little of most ways of playing.



Now here's my problem: I like playing against AIs. I rarely have a long enough stretch that I know I can go into a match without having to bail halfway through but against AIs I can just pause or save. Sorian's AI is great, particularly in the early game. It's very good at building lots of things and throwing them at you. The problem comes later in the game. The AI players always seem to lose focus. For example I played a Sorian on Ranoke the other day and by the late game he was just sending battleships across 1 at a time. A couple of times he even sent a strategic missile sub against my ships and subs that were moving towards his island.. It's like the AI gets to T3/4 and then does not really know what to do with itself so just produces random stuff that it instantly sends to attack you without and cosideration to defensive positions, commander location, makeup of enemy forces, etc.



The other problem is that once I get the upper hand against an AI it will NEVER pull somthing out of the bag and get a win. For example, yesterday I played a ranked match against Usi on Theta (it's in the vault if you're interested). I basically had the game sewn up with a far larger land force, more teritory and factories, etc. The trouble was, I shot myself in the foot with poor scouting. I did not realise I could have steam-rollered him at the end and in that period he built 10 or so T2 gunships and sent them against my com. Game over. Now, I'm not complaining about that, in fact, I think it's great. An AI would never do that though.







To sumarise:



1) AI's seem to lose focus in the late stages of the game.

2) AI's have no real strategy, they just use a generic mix of units to try and hide thier lack of strategic depth.







So I'm wondering, is it feasible to create an AI in supcom's scripting system that addresses these issues? If so, is it more a question of maintaining reasonable performance?







I am of course looking through the lua's but this stuff is pretty alien to me so thought I'd get come community thoughts before wasting loads of time on it. :)|||While I don't really share most of your background (I used to be a pretty good ranked player), I also enjoy playing against AI and I suffer from the same problems. Having Sorian AIx with cheat adjustments (at roughly 1.5x res/build speed) partially solves it by giving the AI an unfair advantage (and basically stretching the T1/T2 phase before getting to T3 yourself), but it's not a fix for the problem. The AI 'stops' at T4. It doesn't understand the need to win, at that point.|||There is a partially completed Strategy Manager in the lua that I plan on finishing. This should help fix the issues you are seeing by allowing the AI to change strategy mid-game based on any number of variables.|||Interesting stuff, I will have a play around and see if I can come up with anything. Good to hear you're on the case though Sorian. :wink:|||Quote:|||/BulletMagnet watches spliff very closely for news of this new AI.



random question spliff: how will you be constructing your armies? will you have pre-fabbed platoons, or have some sort of statistical analysis to determine a good composition for an army based on what it's expected to do.|||Well, at risk of taking over this thread (and spoiling the surprise) I will tell you.



There are no pre-fab templates for bases or squads. Everything the AI does is based on "priorities" which are evaluated every 30 seconds. The priorities are based on current intel and a system of "rules" which can be adjusted on a per-map, per-mod, per-ai personality basis.



Essentially without writing any code it will be possible to create very unique AI playing styles by adjusting its "tendency" to do something rather than spelling everything out as rigid proceedures.



I'll be ready to release the first version in 1-2 weeks. I've already written the code for selecting AIs and evaluating their rules, goals and tasks. I only have the intel system left to write. After that most of the work will be developing the UI and new types of goals (I only have a "collect energy" goal written a.t.m.).|||*points motion tracker at spliff|||@Ambo: do you like the direction that this thread is taking?



spliff|||BulletMagnet|||I will upload a WIP version shortly. As far as Lua being hard... well I'm not sure what you are looking at (the core language or supcom code). I assure you the first is as simple as it gets and the second would be complex in any language.



Do a search for Programming in Lua (PIL) to get your head around the core language before freaking out about the supcom code. :wink:|||@Ambo: i self taught myself lua by reading other peoples mods, the actual Moho Engine trickery is a bit harder but nothing that you couldn't quickly pick up.



to put my words in perspective: i don't have any formal qualifications in programming other that self-teaching a lot and doing a 1st-year introductory programming course.



lua is easy! though it's very picky on capitalisation. lol.|||BulletMagnet|||Right.



I've spent quite a while looking through the FA AIs and some of the user AIs available. I've also read through Sorian's old thread for getting started with modding the vanilla AI and worked through a couple of other sites that give some extra info.



I'm pretty happy with LUA. It's not incredibly clear to me yet but with a bit of concentration I can usually work out what everything is doing.



My problem is that it all seems totally disconnected. I can't get an overview in my mind of how the whole thing hangs together at all.





I assume that the main game processing loop is in the core engine and it only calls out to the AI functions now and then. Or am I thinking too old school? Is the AI script actually running the whole time in parallel with the core engine and the engine just asks for updates now and then?





In any case, all I see is a hell of a lot of functions but I can't see a 'start point' for the whole thing. In Vanilla, this seems to have been the 'aibrainPlans.lua' file. However, in FA this file seems to be irrelevant. It simply links to the 'aiarchetype-managerloader.lua' file. Now this one seems a little more promising but I still can find a start point for the whole thing.





If someone could set me on the right course that would be great. I'm sure I could figure the rest out once I get the fundamentals sorted in my head. Thanks.|||Try starting with the AI Support Mod and Advanced AI mods located here Advanced AI



It's an early version of my AI that does absolutely nothing. For that reason it is a good template for where to start (change the UID in mod_info.lua first though).



The short answer however is:



The game calls AIBrain:OnCreate()

AIBrain:OnCreate() calls AIBrain:CreateBrainShared()

AIBrain:OnCreate() 'imports' the plan file

AIBrain:OnCreate() calls importedplan.EvaluatePlan(). This function doesn't do much except respond with a number saying how 'good' it is. The plan with the highest value becomes currentplan.

AIBrain:OnCreate() calls currentplan.EvaluatePlan() and currentplan.ExecutePlan() regularly to decide what to do.



Anything called via ForkThread runs in parallel to the game and other threads.



So basically your starting point would be either AIBrain or archetype-managerloader depending on how low-level you want to get. Either edit it directly (good for testing but bad for other mods) or find the bit where it imports other plans and try and put yours in too.



All in all I think you'll find my mod a better way to go, as it is designed to support new AI just by dropping them in the right folder (/shadow/lua/AI/types) and they show up in the lobby. The only downside is you'll also need the patch I wrote and a few support mods. Everything you need and instructions are available via the link above but you can PM me if you get stuck.|||funny story spliff. i installed said AI and removed Sorian's and Duncane's to do a semi-proper test.



i got it royally handed to me, i've never been rushed so hard by an AI before. so naturally i wanted to see if this was like emergent behaviour or something and found the AI mod empty!



i'm so embarrassed right now.|||What always bugged me about the AIs was their inability to evaluate a map and construct their structures and units with proper respect to terrain height and water.



That was actually what I was working on with my vanilla AI mod before I ... embarrassingly ... abandoned the project in the face of an approaching FA release date and a number of bugs I could not iron out. :oops:



I still think about doing an FA AI mod every now and again, I really want to give it another shot, but I really can't set aside the time to even play let alone write and test an AI mod. :?





---



I would say the simplest late game 'strategy' to implement in the AI's would be to stop offensive unit production & attacks then devote resources to spamming defenses and game-enders with t3 engies.



Essentially following the "turtle to game-ender" strategy.



At the very least thats what the turtle AI's should be doing.|||brent_w|||Would be good to see the AI building its bases without map markers... currently the markers tell the AI what to do, where to go, where to form up etc... the AI should evaluate the map and make these decisions itself... just like the player.



Hate it when you have a good custom map but the AI plays like a gimp because all the markers are not set :(



Yapa|||duncane|||BulletMagnet|||brent_w|||spliff|||bump.



any new news on this?|||My progress has been delayed by a new top-secret mod project which I'm almost ready to release. I thought it would take a few days but I got stuck on something that took me 4 days to work around.



When that is released (probably this weekend) I'll release my AI framework properly. The main reason I don't do it right now is because it requires a shadowing patch to fix the inability to mod the game lobby. I'm putting the patch in an installer so there will be no stress for people to install - at the moment it's a bit tricky finding the correct place to put everything. No doubt you guys can all work it out but as soon as you try testing it online you'll have to go through the pain of walking others through it.



An installer solves this issue and I already have an InnoSetup script I wrote for Advanced Tactics which can do most of what I need.

No comments:

Post a Comment