Power Of The Ring 3 : Campaigns Of Middle Earth ![]() Contains BFME1 Campaigns : Based on Power Of The Ring |
Welcome Guest ( Log In / Register ) |
![]() |
Quick Lists Top RatedTutorials Living World Map G� Ultimate beginner'� Arrow scaling bug� Raising Heroes max� Proper Fire Arrow� Creating an asset.� Simple Structure B� Making a simple Ma� Quick and easy sno� Making patrols nea� Mods The Dwarf Holds The Peloponnesian� RJ - RotWK The Elven Alliance� Helm's Deep Last H� The Elven Alliance Special Extended E� Kings of the West� RC Mod The Wars of Arda Downloads BFME1 1.06 Widescr� Enhanced W3D Impor� Fudge's Map Pack LotR/BfME HD Logos Osgiliath Shellmap Crystals Of Ancien� 2v1 Wold The forests of Dru� Converted BFME2 an� ROTWK animations f� |
||||||||||||||||||||||||||||||||||||||
![]() |
Register and log in to move these advertisements down In-depth AI Coding
C. Introduction to the SkimishAI of BfMe2. Before i start going into detail how to adjust the Skirmish AI to suit your needs, let me take this chance to ramble a bit about the way the SkirmishAI for BfMe2 (henceforth called SkirmishAI_2) actually works (or rather how i think it works), largely by comparing it to the SkirmishAI for BfMe1 (henceforth called SkirmishAI_1). This is going to be rather unpractical stuff and only useful if you are going to explore the limits of this hard-coded bitch like i have. From this point on i will also start to tag my findings with notes like 'mostly verified' or 'mostly speculative' to indicate the degree to which i have reached a conclusion regarding the unexplained workings of the settings (including the occasional definite no-go crash; falsification of a theory has also proven helpful). So, if you are looking for the hands-on how-to stuff, just skip to the next page ... The SkirmishAI of BfMe1: SkirmishAI_1. Some of you may already have some experience scripting the SkirmishAI for BfMe1, either to account for new units and powers, to repair scripts EA left broken for no good reason, for single player maps or (most ambitiosly) for adding a complete new faction. Well, then you already have a good idea how it works. For those who haven't i will now go into a little more detail to illuminate the next sections better. The WB-scripts are basically a very primitive programming language. I am a bit reminded of early versions of pascal, only even more primitive. It has only global variables and constants amd no open functions to speak of (unless you create your own and are really careful not to reference them in the wrong place). Each PLAYER (be it a human player, an enemy faction or one of the neutral PLAYERS) basically gets assigned a pack full of scripts. All scripts designated as 'active' and 'non-subroutine' are run from top to bottom every frame (1/5th of a second) or every X seconds (variable setting), one at a time, checking their conditions and then do (or don't do) a set of value assignments or a call of a subroutine or whatever. To top it all, it has a serious problem with getting and keeping an overview. organizing the scripts into appropriately named folders is mandatory. Naming the scripts and variables is even more important. So, when starting to write or adjust scripts, it is easy to lose sight of the overall picture, unless one already has read and understood practically all of them, a daunting organizational feat. But if that is done succesfully, the modder has the marvelous opportunity to practically control ALL of the AI! Wonderful indeed! The SkirmishAI of BfMe2: SkirmishAI_2. Compared to SkirmishAI_1, SkirmishAI_2 is simpler, less flexible, faster to adjust, more bossy, less transparent and more prone to drastic malfunctions that are hard to fix because of the other traits i just listed. The settings are annotated in an oversimplified manner, if at all, but obviously sufficient for the EA geeks who i assume know exactly what those settings do. I could only experiment and see what happend. The results of those experiments will be covered in as much detail as useful in the next few pages. But here i will outline my assumptions on what EA's programmers where thinking when designing SkirmishAI_2. First, the new AI was supposed to by more flexible when adding new stuff. The whole group of Hero/Unit/SpellbookBehavior-scripts has been streamlined and can now be referenced in code, directly inside the relevant object that is supposed to use this stuff. Sadly, only the most basic behaviors have been converted from script to code. EA should have done a more comprehensive job. Still, the modules that are there work well. I listed most of them on page 3 (AISpecialPowerUpdate). One side effect was to make the objectlists-library obsolete, which also impacts the next point. Second, target acquisition was to be simplified. That was largely succesful. Gone are the AttackPriority lists. Lo and behold, the general AttackChains have arrived! They are not much better though. And there is only a limited number of them available which is sad. But the number should be sufficient for most mods' unit variety. I surmise they are also serving a second purpose when assigning priorities for team building, but i can't be 100% sure. (see below for the general SkirmishAI settings) Third, economy and teambuilding was to be streamlined and 'approximated' by code. The result is a desaster. Here if nowhere else it is very easy to make the AI either go on a rampage, doing one thing and one thing only, or freeze entirely when attempting something it can't do to the exclusion of everything else. Experimentation has also shown that EA tried to implement a random faction strategy, but largely failed to explain how it works (or even to use it the way they thought it should be used!). This leads to the modder making an adjustment that seems to work great, but then finding out it only works great 20% of the time and is just crap 80% of the time. So mostly the now stressed modder will try to adjust values so that SkirmishAI_2 will do one thing good, 100% of the time, or invest an insane amount time with juggling numbers and testing them ingame to balance it all. And all of that without even be able to read anything going on the the program! With SkirmishAI_1's scripts you could always see what was going on ingame by starting it using '-scriptdebug2', an awesomely useful (and needed) tool! One thing this option does show, even for BfMe2: teambuilding. In the most basic sense, it only shows the type of team the AI attempts to build, not what routines it runs once it has been created. SkirmishAI_2 can now build 3 or 4 different teams (of contents that can only be estimated), that have a fixed set of very, very simple assignments, much like the teams of BfMe1, only much worse. This is where the FarmRushingBot rears it's ugly head! Fourth, basebuilding was to be more understandable. Gone are the assignments of scouting teams or teams of buildplots to raise this or that structure according to actual needs. Strategic building my ass! All is geared to build barracks and strike fast at the enemy (read: farms), ignoring all other concerns. Together with the new TeamBuilder, this makes for a fast-paced but very boring game. The only beautiful thing is the new base templates. You can basically devise several different bases, complete with where you want what and when, even multiple optional sets (if you have the time to construct them) or even specific ones for specifc maps and starting positions (very needed for fortress maps). What you can't do is make the AI choose a setup or even a single building according to what it actually needs to counter the current enemy. That makes me really sad. ResourceStructure building as well as the building of walls (or rather wallhubs) by porters is handled twofold. First, The hardcoded AI creates porter teams, which then rush out to build what is needed (from the base templates). Second, depending on priorities (to be set in the base setup for building inside the base or to be assigned somewhere else for farms and hubs) it rushes out and builds. If you make a single mistake either the porters go and spend all their money on farms (standard EA setting) or all their money on building the base. Hard to balance. The walls actually DO work pretty well, apart from the fact that building the wallhubs nicely (much less strategically sensible) is really tricky. But EA simply ignored placing the hub templates on all maps. They did it on one or two but then just stopped because it was so tedious to test and everyone was rushing farms anyway. No point in building a defense, right? One missed opportunity. At the very least, one thing they didn't take out (much less refine). Spell acquisition works the same way it worked before, using scripts, randomly (and according to difficulty level) choosing a purchase path. At least here a modder can still insert scripts that count enemy units according to type (if one has the endurance to update the object lists) or insert any other condition to choose spells according to need. Spell execution is handled just like unit specialpowers though. Further thoughts on SkirmishAI_2. So, how should one approach setting up a good AI for BfMe2? It all has to do with setting the right priorities and do LOTS of experiments (see the rest of the tutorial). But there are a few alternatives if one is really adventureous. Take a look at the general settings in the file 'data/default/skirmishai.ini', specifically the following section, annotated by yours truly. ---- Mostly Verified ----
If yes, AI doesn't use base templates for building, effectively having porter teams only build farms and wallhubs, and maybe another fortress
If yes, AI doesn't send out porter teams to build farms at map-farm-template locations.
If yes, AI doesn't auto-produce units. NOTE: This is different from the script-toggle for unit build. SkirmishAI_2 produces units if it can pay for them. It doesn't need to have a desire (priority) for a team containing the produced unit. In fact, if you disable everything but this, the fortress will still spit out heroes that stand around and do nothing.BUT: Need can influence the build-order.
If yes, AI doesn't purchase upgrades for structures (PLAYER or OBJECT based doesn't matter)
If yes, AI doesn't purchase upgrades for troops.
If yes, AI doesn't use AISpecialPowerUpdate for triggering a SpecialPower.
If yes, AI doesn't build ATTACK teams, DEFENSE teams, EXPLORE teams, or OPPORTUNITY teams.
If yes, AI doesn't send out porter teams to build wallhubs at map-wallhub-template locations.
Well, these toggles alone give a glimpse of what is still possible with SkirmishAI_2. One of the main concerns i had in the past was the bossy nature of the AI. It took me ages to find the right settings so that the initial porters didn't run cross country building farms, but to make them build the base first. All of the things the AI now does are listed above. They all run on priorities whose calculation routines elude me and everybody. They can only be estimated and tested, because all you can set is a range and sometimes a rate of change (per unspecified period of time). Some of the parts work quite well, but some are just broken. Adding TeamBuilding scripts breaks on the AI like waves on a rock. To repair it, switch off UnitBuilding and TeamBuilding, Adapt working Teams from SkirmishAI_1, include the scripts they use (of which some will probably not work, unless you disable TacticalAI) Don't forget to add some hunters for TheOneRing. One type of Team can already be constituted. You can make teams from wall-stretches, outposts, the spellbook etc, and they can employ the same scripts from SkirmishAI_1 that where used to assess threat, check for money, initiate repairs, buy upgrades, etc. The Real Hero will just toogle ALL SETTINGS to YES! Start building the AI from scratch (copy-paste from SkirmishAI_1 then adjust) but will need to find unique ways of getting the AI to build wallhubs and other stuff with porters (using the AI-objects on the maps as tactical markers). New scripts using the new porter are already included in WB2. Before going on a venture like this, please try and make a faction AI for BfMe1 first, to make you understand how it could work. Go, grab the latest beta of The Elven Alliance and create an ElvenSkirmishAI! They need one badly! That's it for now. All the rest of the pages will pick out choice pieces and help you tackle the most stupid AI that i have ever worked with. ------------------------------------------------------------------------------------------------------------------------------------------------------------------- CommentsDisplay order: Newest first | Page: 1, 2 Prolong - Thursday July 29, 2010 - 9:21 Very nice guide, even though it never got finished there is still a ton of great information here. Elrond99 - Sunday February 15, 2009 - 7:52 Thanks for updating the Tutorial Sulherokhh (Team Chamber Member) - Saturday February 14, 2009 - 21:19 After 'D. The Faction Base and Fortress', i guess. jakonic - Saturday February 14, 2009 - 12:05 when will be finished Spell Purchase Scripts???please answer Sulherokhh (Team Chamber Member) - Thursday November 29, 2007 - 17:26 I sure will... Rob38 (Team Chamber Member) - Thursday November 29, 2007 - 11:00 This is by far one of my favorite tutorials on T3A! Please continue to add more :) Sulherokhh (Team Chamber Member) - Wednesday October 3, 2007 - 23:07 I am glad you can put it to use, Rob! Your feedback means a lot to me. :D Rob38 (Team Chamber Member) - Wednesday October 3, 2007 - 22:27 Amazing! I also found a way to recognize if a player is controlled by the AI, but this looks to be a much easier method to use. Thank you for all your wonderful knowledge as there is some really cool stuff in here. Sulherokhh (Team Chamber Member) - Wednesday October 3, 2007 - 19:18 I'll split it up. Let's see what would be a good way. - Edit: Done. I hope you like it. Crashdoc - Wednesday October 3, 2007 - 16:48 Nice findings and interesting ways to use them. Thanks for sharing the knowledge! |
![]() |
|||||||||||||||||||||||||||||||||||||
![]() "One site to rule them all, one site to find them, © All Rights Reserved Eric Edwards ©2013. |