|
1. Introduction
|
|
1.1. Foreword
The object studied in this project is Artificial intelligence called
“BecomePrey” for “Warzone 2100” game. I’m its designer and creator and
development took me over 2 and half years of hard work, result of my
determination is one of the best AIs for strategy games of all times. My
artificial intelligence does not use any cheats (or advantages to other players)
and doesn’t use any preferences while selecting which player to attack (e.g.
doesn’t prefer human to enemy AI). Even with those disadvantages, BecomePrey can
easily beat any threat and kill even AI which has such advantages. This project
will try to precisely document Warzone 2100 game and describe whole script of
BecomePrey AI for use as information source and inspiration of future
generations of talented modders and developers. Because of enormous length of
main AI script (over 120 pages A4), this project has attachment in form of a
link
(http://warzone2100.wz.cz/files/BP290PFR_Documentation.exe
)
,
you can view script in MS Office, Notepad or my script development program
called VSC. When I started writing this, BecomePrey was in version 2.90PFRt3,
however at the end it was v2.90 PFR. I tried to modify this documentation
project on a fly, but I might screw up something and description and
attached script may differ in few parts. This game is open-source since 2005 and is
free to download over the internet. |
|
1.2. Used abbreviations and special names: (in order as appears)
AI = Artificial Intelligence; group of scripts which creates a virtual
personality that can make decisions/comments in reply to user input, in gaming
software this personality interacts with you as your opponent in game.
RTS = Real-time strategy game; genre of computer gaming where you may lead an
army in real time battle instead of turn based battling. In this style of
gaming, time and quick thinking becomes a challenging factor of the game.
Modding = Modifying. Modding is a slang term used to express the act of
customizing original content in gaming software.
Mod = this slang term expresses the end result product of Modding. A Mod is
usually created for 1 of 3 reasons; to enhance original game play experience,
fix over looked programming problems left in a game by developer or build a new
game based on another game’s engine (core program).
Bug = an error or logical mistake in game programming or modding.
FPS = First Person Shooter; a game in which you see your surroundings through
the eyes of the virtual character in which you are playing, instead of the usual
view of the player character's whole body.
HUD = Heads-Up Display; usually shows the state of your virtual player
character's vital and equipment stats.
GUI = Graphical User Interface; This style of interface uses graphics to
interact with user visually instead of the “Old School” style of command lines.
Windows O/S is a perfect example of GUI in action. User can click on windows and
symbols to navigate through the computer and run applications. This is an
extremely "user friendly" and speedy method of interfacing with a computer.
Map = this should be self explanatory. This shows you the geographical layout of
the land/battlefield in which you may navigate through your virtual player
character's movement.
Deathmatch = this is a free for all killing field. No rules, no storyline, all
versus all, player with most frags (kills) after pre-defined time wins.
Singleplayer = this game play mode is where human player plays against the
game's (usually pre-scripted) AI. This mode is also often called “Campaign”
which involves a storyline of some sort.
Multiplayer = in this mode, multiple human players play against each other in
player vs. player, team vs. team or in team vs. computer-driven opponent (A.I.).
Skirmish = Skirmish mode is special Singleplayer mode widely used in recent RTS
games. This Mode is where you will enter into specific types of challenging
encounters that will test your skills and assist you in training for
Multi-Player situations. |
|
Abbreviations and special names used in part 4:
(All are directly referring to Warzone 2100 game)
AAS = Advanced Attacking Script
AAP = Anti-Air Protector
ASK4HELP = special feature that allows human player ask his BOT for help by
offering alliance to enemy player.
AVAS = Advanced VTOL Attacking Script
AACS = Artillery Attacking and Counter-Attacking script
BOT = in this case an AI player assigned to help human player
DYWERA = Dynamic Weather Randomizer
Cyborg = a battle droid controlled using Synaptic Link technology; unit that
uses mechanic legs propulsion
LasSat = Laser Satellite Command Center; uplink center that controls orbital
satellite with long-range ultimate laser weapon.
Module = building upgrade; attaching upgrade module to powerGen/resCenter speed
up power income/research. 2 modules attached to factory building allows player
to build tanks/VTOLs with medium and heavy bodies and also speeds up building
process.
NEXUS = intelligent computer virus that caused The Collapse in storyline of
Warzone 2100 campaign
NEXUS Intruder Program = a computer virus designed to take over hardware of
attacked computer system
NEXUS Link Technology = technology capable of taking-over enemy units/structures
by uploading NEXUS Intruder Program into it
powerGen = Power Generator; building that is powering up to 4 oil derricks to
excavate oil resources
resCenter = Research Center; building that researches technologies
Tank = unit that uses wheeled, half-tracked, tracked or hovered propulsion.
TCS = Total Control Script
VTOL = Vertical Take Off and Landing; unit that uses VTOL propulsion
|
|
2. Artificial Intelligence in computer games - general |
| 2.1. What is AI actually? Artificial intelligence in any computer game is represented by a computer-driven
opponent who plays against you as an equal on the battlefield with access to
everything that you have access to, e.g. weapons, terrain, etc.
There are quite a few types of AI:
Hard-coded AI – this type of artificial intelligence was widely used in the
past, especially for deathmatch FPS games. The Computer-driven player has
pre-programmed paths where he can go. One primary script randomly and
continuously selects a path and secondary script leads the Computer-driven
player to fire on other players nearby. This way of handling AI’s behavior may
be quite effective, especially because the developer may simply adjust game
difficulty by giving secondary AI script more precision in firefighting. Pre-scripted AI – this type of artificial intelligence is widely used in
Singleplayer. AI is written specifically for one map. The main design is based
on “triggers”, for example, when a human player enters a certain area, a trigger
is engaged and then an action is activated. Imagine a tank entering a mountain
pass leading to AI’s base, trigger is engaged once enemy tank enters triggering
zone and then the AI either starts to build tanks to counter-attack or it will
send an air strike to the intruding enemies location. Zone-based semi-adaptive AI – this type of AI is used in modern FPS games. Every
player driven by the computer has specified zones/areas in which they own and
patrol, these areas are referred to as "Owned Zones". Zones are strategically
occupied by computer-driven (A.I.) opponents so that they may all collaborate
and hunt the human player down. If a trigger detects human player nearby (in
modern games even loud sounds, fire or footsteps may be triggers), semi-adaptive
modules may engage him on pre-scripted basis or grant AI player/players
permission to temporarily move to and monitor another zone. This type of AI
handling is very effective. Dynamically Adaptive AI – this is the most advanced type of AI used to date.
This AI can adapt to any known situation and solve any problem, making its own
decisions not dependant on any hard-coded basis. This type of AI is suitable for
both FPS and RTS games and is extremely effective. However, development of such
AI is extremely time consuming and in some cases can take years to create.
|
| 2.2. AI versus Script Someone who knows what an AI really is may think this is a ridiculous
comparison. It's because they would know that scripts are like bricks and an AI
is more like a house. Every AI consists of many scripts, the way in which they
are arranged and the seemingly unnecessary extra scripting that leads to the
activation/choosing of the next script is what gives the group of scripts a
feeling of personality. This is the sum of an AI. An architect designs a house
not only to be functional but to have a feeling of personality. So is true and
actually more so in creating an AI. The thing that makes an AI/house more than a
sum of scripts/bricks is the way in which they are bound together. This makes it
pleasing and desirable; it gives it a feel of PERSONALITY/CHARACTER. A good AI
is one that people unwillingly begin to refer to as “he” or “she”. An AI’s
personality is what makes people refer to it as an entity. There is no greater
reward for an AI scripter than when someone says “Hell, I fought your AI 1 on 1
and he’s a devious and sneaky little bastard. Good work, man!” Special scripts
that are not necessary for the AI to work, but adds some kind of uniformed
behavior is what creates this desired effect of realism and life in an AI. For
example imagine RTS AI which can kill you without single unit lost, because “he”
forced damaged units to return to base for repairs. Imagine AI that is attacking
with two independent strikes at once, one kamikaze run to disarm your front
lines and then attack from rear with backup. Only perks like this create good AI
and cause human to feel same like fighting another human.
|
|
3. Warzone 2100 RTS |
| 3.1. Basic information about RTS genre
RTS games are typically simulations of war, in these games you are a general who
can see the battlefield from above, commanding all units, managing bases etc.
Even though RTS genre is not the main topic of this paper, I’ll describe it in
detail so that everyone can understand the full aspects of RTS featured games.
In Real-time strategy game, you usually begin with either an MCV (Mobile
Construction Vehicle) capable of deploying as HQ or a Truck (special vehicle
which can build structures). The first aspect in all RTS is base building,
player has to use MCV or Truck(s) to build main base and bring whole
infrastructure online. Each type of building is designed to perform one task,
for example factory can build units and more Trucks, Research Center can
research advanced technologies to be deployed on battlefield while Resource
Extractors ensure that player won’t have lack of power (money, credits or
whatever). Once main base is built, player has to secure his base by defense
towers, build tanks, aircrafts or soldiers to keep enemy away and make progress
in research to keep up with developing enemy. In multiplayer games, players may
of course create unions and alliances and help each other in all military,
economical and researches. After some massive battles the game ends, winning
conditions may be to kill all enemy forces, to gain control over certain area,
to destroy specific structure and even to research a vital technology sooner
than your enemy. |
| 3.2. Warzone 2100 features Warzone 2100 RTS game was released in 1998 for Play station gaming console and
almost a year later in 1999 they came out with the PC version. Warzone 2100 was
heavily criticized for enormous difficulty in both campaign and skirmish games
and this was the main pitfall stated by the popular PC magazine's of the day,
this naturally lead to the under-rating of this great and "before it's time"
gaming platform. Warzone 2100 was the very first RTS game in a full 3D
environment and that supported free 3D camera movement over the entire
battlefield. It also had many revolutionary ideas and features which are still
being used in the latest "cutting edge" games of our recent day. In respect to
its myriad of contributions to the gaming industry which has become part of the
industries recent standards, it's my opinion that Warzone 2100 was under-rated
and horribly underestimated. Out of fairness, I’ll try to make a short iteration
of all features Warzone 2100 brought to the RTS genre. First of these unique
features is "Base" building, in which is based on "Truck" vehicles capable of
building structures. Secondly Warzone included a feature under the name of
"Commanders"; these special vehicles are able to lead groups of units into
battle and can use a laser designator to provide better aiming capabilities for
the members of that group. In addition they possess the ability to override auto
firing of artillery (which will be covered in the next few sentences) in order
to concentrate fire on one target. Warzone also introduced Auto Sensoring
Artillery, capable of automatic long-range targeting and firing when enemy gets
within artillery range. To add additional variety to your arsenal (as if it were
really needed) Warzone has many types of sensor arrays, some for extending
Artillery field of view; Counter-Battery radars (which can calculate exact trace
of incoming artillery shell and guide all available artillery in range to
counter fire attacking battery). Another great feature is the ability to create
your own units from component parts. A player may select what ever combination
of available propulsion, body and weapon he desires, from that moment on the
vehicle is ready to be produced in mass. In the unmodded game, there are over
2000 possible combinations or in other words… 2000 unit types to be build.
Research efforts used in Warzone 2100 has never been duplicated in it's
magnitude since its creation. The research in the unmodded game covers over 460
topics, including enhancements for base structures and units, research of new
weapons and hyper-advanced technologies. Additionally, players can select one of
3 technology levels for start of Skirmish or Multiplayer games. Another breath
stunning feature in Campaign's is that the base you build is transferred from
mission to mission along with all units, so you don’t have to rebuild it again
and again. If I were to list all of the features available it would take many
pages to do so, so I’ll skim over a few of them and keep it short.
|
| 3.3. Warzone 2100 about game Upon entering the game you land from your transport and establish your base.
Here you conduct research, design and manufacture vehicles, build new structures
and prepare your plans of global conquest. If the game goes badly you'll end up
fighting last ditch battles here to defend your base from enemy attacks. During
the game, you will experience stunning cinematic effects, with fully zoomable,
rotational camera action, realistic smoke, and fire and damage effects and of
course, plenty of gratuitous explosions! Combat is frantic, with extensive
graphical effects and damage to the terrain and buildings giving rise to flying
shrapnel and boulders. Within the game are many different structures and
vehicles. From an initial Command Centre, you then go on to build Resource
Extractors to provide fuel for Power Generators, which in turn supply energy to
Factories, Research Facilities and weapons emplacements to protect your base.
Research will provide you with upgrades to structures and new technologies for
weapons, vehicles, jammers, sensors and propulsion systems for every occasion!
With a simple mix-and-match design system, different vehicle parts can be
assembled to produce hundreds of different vehicle configurations. From light
combat vehicles fitted with machine guns to heavy tanks carrying massive
Howitzers, fast hovercraft for aquatic attacks and VTOLs to provide air support,
a different configuration is always possible for the situation in hand. In later
stages, you will be able to build AI equipped Command Units, which will direct
other units in battle and designate targets for their attacks. Sensor vehicles
will be able to detect enemies before they know you are coming, and jammers will
be able to reduce the enemy's ability to track your units. In the end all of the
3D battle effects show its toll. Strategy is the only word that can be said
about the gameplay of the game. If you want a true strategy game this is the
one.
|
| 3.4. Warzone 2100 modding abilities With all availabilities Warzone 2100 engine provides, there’s no wonder that
Warzone once had the largest modding community in history of RTS games. Almost
everything may be changed by skilled hands, including (but not limited to) 3D
models, maps, sounds, research topics, vehicle parts, damage modifiers for armor
type vs. weapon type, visual effects, map scripts, skirmish AI. Additionally,
Pumpkin Studios who initially designed the game provided unofficial support and
hints to modders until they vanished from the scene.
|
| 3.5. Warzone 2100 life history Warzone 2100 (PC version) was officially released in 1999 by Pumpkin Studios and
distributed by Eidos. Even though initial version of game was nearly perfect,
Pumpkin Studios released 10 additional patches to enhance gameplay experience.
Soon after patch #10, Pumpkin Studios broke and there was no further official
support. However, there was a light at the end of the tunnel, that light was
provided by NEWST. NEWST was a group of Warzone 2100 fans, skilled modders,
graphic designers and scripters who took over support for about 2 following
years. They also released unofficial patch #11. After NEWST broke up, another
group formed mainly from old NEWST members, called Pumpkin-2, however this
modding group was not nearly as successful as NEWST. Pumpkin-2 didn’t last long
and was reformed into a group called RTS.net. Along with those large groups,
there were also smaller and even more productive groups, like German
Warzone2100.de group or my WEF project (Warzone Elite Force).
|
| 3.6. Warzone modding community today
There are a few groups and some individuals modifying Warzone today. RTS.net and
it’s redevelopment project is taking care of future updates for main Warzone
executable and we've been waiting for this many years, but now in 2005, Warzone
has become an open-source program. This makes it in definition "a free game" and
its source code has lost copyright protection. This allows us to legally modify
Warzone Graphical Engine and keep it up to par with modern technologies. Another
active group is Warzone2100.de; they are working on a great mod called Warzone
2120. And at last, Czech WEF group is taking care of its tools made by me and
working on further development of mods and AI. I must not forget individuals
like LavCoyote25 who is working on his stunning Mars campaign maps, Pardons
a.k.a. RTSGod developing his LiveOrDie mod and Troman developing his AIs and
helping with scripting language redevelopment. |
|
4. BecomePrey Artificial Intelligence |
| 4.1. Why all this started? It’s hard to say why, Warzone 2100 was (and still is) such a great game that I
couldn’t resist modding it. Everything started with simple attempts to modify
weapons and some statistics, and then I decided to mod it big time. My first
step was K-I-C-K mod. K-I-C-K takes place after storyline of campaign and adding
hundreds of new technologies into game, ever since it's first official version,
K-I-C-K was the embodiment of fast paced action, great explosions and mainly
challenging fun. After some updates on my K-I-C-K mod, I decided to take
standard Warzone 1.10 AI developed by Alex McLean and modify it’s scripts for
better performance to make K-I-C-K gameplay even more challenging. Everything
went flawlessly and I eventually learned how to use scripting language enough to
create my own AI from scratch. After some initial attempts and further updates
for my K-I-C-K mod, I knew I would have to program some tools to make my modding
life easier. First step was KMS (K-I-C-K Mod Switcher which bares this name even
now when it really isn’t limited to the K-I-C-K mod), this application can
easily switch between mods and AIs and allows developers to publish their work
in form of small modules which are pretty easy to both install and use. Next
application I made was Template Generator, as you already know, Warzone uses
units created from researched parts, and the final designed unit is called a
template. My next stop was the unofficial 1.11 update by the NEWST group. This
update has quite a lot of mistakes and gameplay was not balanced; therefore I
took their version and modified it to provide balanced gameplay, fixed all known
bugs and included new graphics. Later, because I wasn’t really happy to modify
my upcoming AI in Notepad, I made VSC (VLO&SLO Compiler) program which is even
now the most useful thing I ever made. It is specifically designed for writing
an AI including easy access to most commonly used commands. At last I have
merged VSC and Template Generator together and developed much more usable
version of KMS 2.1. Then I moved onto „BecomePrey AI" and that's where I’m at
now. As one great man said: „To make a "General Purpose Skirmish A.I." that
poses a real challenge to players equivalent to playing against good human
players on ANY Map is something of a "Holy Grail". Especially when you cannot
"Spawn Reinforcements" and rely on "Canon Fodder" and "Ant Swarm" waves. Within
those constraints such an A.I. would have to be "Dynamically Adaptive
Tactically". „
|
| 4.2. BecomePrey – basic description BecomePrey AI is the most advanced Warzone and maybe even RTS AI available to
this date. It does not use any form of cheating, in definition, the AI can do
only things which the human player can do. BecomePrey AI is still in development
and its version number right now is 2.90 Pre-Final Release. This is supposed to
be the last version of 2.xx series. About tactic, BecomePrey is a Dynamically
Adaptive AI and can be hardly surprised by any known tactic. I’ll try to
describe the personality of my AI. BecomePrey never flees from battle, attacking
with 1 to 3 attack waves at once; he has also capability to be assigned to help
other human players or AI players in an alliance. His power-management (or how
it treats money) is fine-tuned to highest levels and BecomePrey can quickly
acclimatize on maps with low resources same as on maps with many resources.
BecomePrey can decide to move its base to another place any time and its
attacking capabilities are unpredictable. Attack and base defense are well
balanced and only large number of enemy units can catch BecomePrey off guard.
BecomePrey may “reincarnate” another player in alliance when he is dead and
bring him quickly back on foot. Well there are thousands of small features not
mentioned like aspiration to lose as little Trucks as possible and a feature
that can fortify a base with offensive artillery. Others will be mentioned in
script details later. BecomePrey has also support for customable cheating; there
are 6*2 levels of cheating to satisfy needs of advanced players.
|
|
5. BecomePrey Main Script detailed technical specifications
( Revised for version 2.90 PFR ) |
|
You may see whole script in attachment #1; this part is referring to it! Use it! CAUTION: EXTREMELY LONG DOCUMENTATION AHEAD! Coffee is mandatory!
VARIABLES AND CONSTANTS: This is the place where all variables must be declared. There are three types of
variables, “public” which stores content constantly until is changed, “private”
which delete content immediately after script execution and “constants” which
are “public” variables with pre-assigned data. Variables are case sensitive and
must be specified before using them.
TRIGGERS: This is the place where all triggers must be specified. Triggers are either
timed e.g. (every, 1); (wait, 100) or event-triggered, these are activated for
example when unit is hit by a weapon or when structure is destroyed etc. Timed
triggers are optional, because they may be assigned directly in script.
MAIN SCRIPT:
event initialisedEvent(CALL_GAMEINIT) { GAME INIT SCRIPT - restart all public variables to their default values - put all units on battlefield to one group (these units are all trucks for
sure, so assign them to buildGroup) - designate location of main base; take one of trucks and store its coordinates
as a location for HQ - if there are more than 2 droids, assign 2 of spare droids to join
harvesterGroup (a group which takes care of gathering and protecting oil
derricks) - fix known alliance limitations and disallow player to attack own units by
accident - restart DYWERA (Dynamic Weather Randomizer), this is an extra script that
takes over control of weather conditions in game. - enable critical technologies and fix possible bugs in Cyborg prodiction on T1
technology level - check and store actual “T” technology level -start LIFE }
event AutoBases(inactive) { CHEAT LEVEL C-X EMULATION - Apply only on cheat level x-1 or x-2 - Build oil derricks on resources nearby the base - build essential buildings in the base - on x-2 build defenses around base and defend oil derricks }
event oilHack1(executeScriptTr) { HACK TO OVERRIDE MAP HIDDEN AREA - Reveal coordinates of all oil derricks on map (human can see this on map
preview) - Reveal coordinates of all enemy bases on map (human can see this on map
preview) }
event ForceBuildHQ (every,1) { - FORCE HQ TO BE ALWAYS BUILD AS FIRST STRUCTURE - build HQ at once }
event DEBUG_MODE_ENABLER(buildBaseTr) { ENABLES DEBUG MODE ACCORDING TO AI SETTINGS - Reveal whole map - give human beta tester regular power gifts }
event BOTSettings(buildDerrickTr) { TAKES CARE ABOUT BOTs (computer driven AIs assigned to help you) - check if you’re a BOT - check to which player you belong - register that player as WhosMyLord and create alliance - divide players to color groups, blue=human, green=BOT, red=enemy AI - as this is executed shortly after start, enable in game fog (this causes
BP-characteristic start flashing) }
event weatherSetUp (changeWeatherTargetTr) { MAIN DYWERA (Dynamic Weather Randomizer Script) - generate random numbers and mix weather conditions and daytime } event changeFogColor(upgradeStructuresTr) { ADDITIONAL DYWERA SCRIPT - apply color designated by main DYWERA script
- smoothly fade from one color to another (changes weather) - activate snow/rain when critical mass is reached }
event DBM_MoveBase(fortifyTr) { DYNAMIC BASE MANAGEMENT SCRIPT - move base to another location after some time - force all units to move to new location too - build HQ over there - store coordinates as main base location }
event buildCybFactoryFirst(initOverrideMinorTr) { INITIAL CYBORG FACTORY OVERRIDE - build 2 cyborg factories as a minor startup task }
event buildRepFirst(initOverrideMinorTr) { INITIAL REPAIR CENTER OVERRIDE - build 1 repair center as a minor startup task }
event buildFactoryFirst(initOverrideMostEssentialTr ) { INITIAL FACTORY OVERRIDE - build 3 factories as a major startup task }
event buildResFirst(initOverrideMinorTr ) { INITIAL RESEARCH CENTER OVERRIDE - build 1 research center as a minor startup task }
event buildPowFirst(initOverrideMostEssentialTr ) { INITIAL POWER GENERATOR OVERRIDE - build 2 powerGens as a major startup task }
event harvesterOperate(buildDerrickTr) { ADVANCED HARVESTER SCRIPT - find oil resources not occupied by enemy forces and build oil derrick - if all oil derricks are built, build defensive structures around derricks }
event harvesterBuildersSlider(buildDerrickTr) { HARVESTER GROUP – BUILD GROUP TRANSFERS - maintain 2 trucks in harvesterGroup and reassign truck from buildGroup to
harvesterGroup when necessary - maintain at least 2 trucks in buildGroup and reassign truck from
harvesterGroup to buildGroup when necessary }
event defendOilEnhanced(extraOilDefensesTr) { EXTRA OIL DEFENSES - execute when all resource extractors are built and defended with essential
defenses and player has enough power - build extra defenses around derricks }
event incendry(inactive) { MAIN AACS SCRIPT (Artillery Attacking and Counter-Attacking Script) - Build Counter-Battery radar inside the base - Build sensor on NORTH of the main base (if not out of map)
- Build sensor on EAST of the main base (if not out of map) - Build sensor on SOUTH of the main base (if not out of map)
- Build sensor on WEST of the main base (if not out of map) - Specify best sensor turret technology available }
event incendryStop(inactive) { IDLE TRUCK PREVENTER - assign truck from senseGroup back to buildGroup when idle }
event incendryStart(incendryTr) { START MAIN AACS SCRIPT - determine if any sensor or radar is required - if so, transfer one truck from buildGroup to senseGroup - execute main AACS script - enable idling preventer }
event buildSense(buildSenseTr) { DELIVER SENSORS ACROSS WHOLE MAP - randomly try to detect „nomads land“ - check if nomads land is really neutral - build sensor in the middle of neutral area }
event buildPowerGenerators(buildPowerGeneratorsTr) { BUILD 1 POWERGEN PER 4 DERRICKS NOTE. Every powerGen can supply max. 4 oil derricks - detect number of oil derricks and number of powerGens - prevent building too many powerGens at the start of game, set unlimited for
first 6 minutes and then limit building to one per 1,5 minute - powerGens = oilDericks / 4 ; if less, build more of them }
event buildBaseQueue(buildBaseQueueTr) { CREATE LIST OF AVAILABLE STRUSTURES - iterate list of all structures - copy all structures already available to another list
pickStrQueue[pickStrQueueDepth] }
event buildBase(buildBaseTr) { BUILD STRUCTURES FROM pickStrQueue[pickStrQueueDepth] LIST IN BASE - randomly select a structure that is still under max. limit abd build it }
event structureLimitHack(defendBaseTr) { -TRUCK ANTI-STUCK SCRIPT - ensure that Truck is not stuck in base and his commands are all clear }
event vanishArtifacts(managePowerTr) { EXTRA SCRIPT THAT REMOVES TECHNOLOGY ARTIFACTS FROM SKIRMISH GAME (THEY ARE
USELESS) - iterate through all features, detect artifact crate - remove artifact if found }
event defendBaseQueue(defendBaseQueueTr) { CREATE LIST OF AVAILABLE DEFENSES ACCORDING TO T-LEVELS - check current technology level - iterate all defenses list for given T-level - copy available defenses to pickDefQueue[pickDefQueueDepth] list }
event defendSpotSelect(defendSpotChangeTr) { SELECT RANDOM SPOT ON BASE BORDER - detect place as large as factory building on base border - select spot for further building right there }
event defendBase(defendBaseTr) { BUILD DEFENSE FROM LIST OF ALL AVAILABLE DEFENSES IF ENOUGH POWER - check for available power and execute only if power > 100 - decide wheter respond to AAP and build AA site where requested or build clasic
defenses - either build defense on selected defendSpot or build AA site where requested
and send „ready“ status to AAP }
event defendBaseLP(defendBaseLPTr) { BUILD DEFENSE FROM LIST OF ALL AVAILABLE DEFENSES ALWAYS - refer to event above; doesn’t check for power state; executed less often }
event buildBaseArty( buildBaseArtyTr ) { BUILD ARTILLERY WEAPONS IN BASE - iterate through all artillery structures and build a queue of available models - use Floating Point Randomization with bias 2 to select proper artillery
structure - build artillery on random location in main base }
event upgradeStructures(upgradeStructuresTr ) { UPGRADE STRUCTURES USING MODULES - check if module is required for any factory and upgrade factory if necessary - check if module is required for any powerGen and add module if necessary - check if module is required for any research center and add module if
necessary }
event finishStructs(finishStructsTr) { FINISH STRUCTURES WHERE BUILDING PROCESS WAS INTERUPTED BY DESTRUCTION OF TRUCK - enumerate all factories and send truck to resume building if necessary - enumerate all cyborg factories and send truck to resume building if necessary - enumerate all VTOL factories and send truck to resume building if necessary - enumerate all powerGens and send truck to resume building if necessary - enumerate all research centers and send truck to resume building if necessary - find HQ building and send truck to resume building if necessary }
event newfortify(fortifyTr) { FORTIFY MAIN BASE BY BUILDING LINES OF DEFENSE TOWERS ON NEAREST GATEWAYS
(PASSAGEWAYS) find nearest gateway and assign a truck to build line of defenses }
event droidBuilt(droidBuiltTr) { TASK CARRIED WHEN NEW UNIT IS BUILT - if unit is tank, assign it to tankGroup - if unit is cyborg, assign it to cyborgGroup - if unit is VTOL, check for it’s weapon and divide into 2 groups - if VTOL has anti-structure weapon, assign it to vtolGroup - if VTOL has anti-tank weapon, assign it to vtolUnitGroup - force VTOL to move to landing pad or attack a target for vtolUnitGroup if
present - if unit has NEXUS Link Turret (capable of taking over enemy units), assign
unit to NEXUSGroup - if unit is specified as truck, assign it to buildGroup - select secondary orders (automatic behavior) for every unit: never return for
repairs, attack from longest range possible, fire at will, pursue if enemy tried
to flee }
event reSortUnits(inactive) { UNIT RESORTING SCRIPT; TAKES CARE OF INBOUND UNITS (TAKEN OVER BY NEXUS LINK OR
GIVEN BY A CHEAT SCRIPT ETC.) - put all units on battlefield to one temporary group - iterate temporary group and put units to its proper group one by one
(technically do droidBuilt event but do NOT change unit - orders in any way) }
event randimizeNumbers(rndNumGenTr) { CREATE RANDOM NUMBER SEED FOR RANDOM NUMBER GENERATOR - generate random numbers to mix randomized events in game }
event SelectRndTemplateRun(inactive) { PRODUCE TANKS AND GROUND TRUCKS - check for power level and limit building to 2 factories on low power state - execute for each completely built factory without any task (idle factory) - check if more trucks are required and build one if they are - increase buildBBCheck number by one - if buildBBCheck is more than 6, select best BB (anti-structure) Tank, start
production and reset buildBBCheck counter - if buildBBCheck is less than 6, select a tank model from all templates
(completed unit designs) available to AI - process all available unit templates in Floating Point Randomizer with radius
6 and determine tank to be built - build tank }
event SelectRndTemplate( tankBuildEventTr ) { ACTIVATES SelectRndTemplateRun EVENT - activate SelectRndTemplateRun event }
event SelectRndTemplateCRun(inactive) { PRODUCE CYBORGS AND CYBORG TRUCKS (Combat Engineers) - check for power level and limit building to 1 cyborg factory on low power
state - execute for each completely built cyborg factory without any task (idle
factory) - check if more trucks are required and no tank factory is available, build one
if required - process all available unit templates in Floating Point Randomizer with radius
6 and determine cyborg to be built - build cyborg }
event SelectRndTemplateC(cyborgBuildEventTr ) {
ACTIVATES SelectRndTemplateCRun EVENT - activate SelectRndTemplateCRun event }
event takeover(takeoverTr) { WHEN A UNIT IS TAKEN OVER BY NEXUS, SORT TAKEN-OVER UNIT - sort unit to a group, treat it like newly produced unit - give unit primary and secondary orders }
event takeoverDefend(EtakeoverTr) //even this necessary cheating is minimized! { IF ENEMY HAS NEXUS Link WEAPONS, RESEARCH COUNTER-TECHNOLOGY AS TOP PRIORITY
TASK - research NEXUSDefense technology after 5 NEXUS encounters }
event lassatRecharge(inactive)
{ RECHARGE LasSat AFTER TIME GIVEN - when activated, set LasSat to enabled state }
event Buildlassat(doResearchTr) { BUILD LASER SATELLITE COMMAND CENTER - check for existing LasSat, proceed if none found - build LasSat - dis-charge LasSat if charged - assign timer to lassatRecharge event - remember we have LasSat already (do not attempt to build more) }
event TargetSeek(upgradeStructuresTr) { SELECT TARGET FOR LASER SATELLITE - select enemy player on random basis - select and store random target from all known structure types }
event activatelassat(buildPowerGeneratorsTr) { FIRE LASER SATELLITE - re-validate target - select Laser Satellite Command center building - activate Laser Satellite - restart targeting system - start laser satellite recharging }
event lassatisgone(lassatReBuildtr) { TRIGGER LASER SATELLITE BUILDING WHEN DESTROYED - trigger when structure is destroyed - reset LasSat state and allow AI to rebuild Laser Satellite Command center }
ADVANCED ATTACKING SCRIPT MK-V Following lines will describe one of most complicated script in BecomePrey,
administer more caffeine if necessary
Tank Superior Assault Script event tank_AAS_INIT(tankInitTr) //inactive after init { ATTACK SCRIPT INITIALISATION - check if tankGroup has enough units to attack - AI has enough units - proceed to migration - AI has NOT enough units to attack - regroup units and prevent stucking in base - find a location as large as factory building on the edge of base and order all
units to regroup there (only if unit is not fighting at the time) - set defensive secondary orders for all units }
event tank_AAS_MIGRATION(emulateZeroWaitTr) //ALWAYS ON (WAIT,0 - EMULATION) { MIGRATION SCRIPT - start attack preparations - select enemy player to attack - select a neutral spot between own and enemy base - move all units to regrouping location }
event tank_AAS_SUBINIT1(emulateZeroWaitTr) //ALWAYS ON { SUBINIT #1 - wait for majority of units to regroup - activate positioning }
event tank_AAS_POSITIONING(emulateZeroWaitTr) //ALWAYS ON (WAIT,0 - EMULATION) { POSITIONING SCRIPT - select enemy target of opportunity (structure) that is nearest to regrouping
location - check for unit presence around structure and decide whether attack buildings
or units first - select final target (original structure) or switch to anti-unit attack script - execute attack, remember Target to avoid re-activating attack }
event tank_AAS_SUBINIT2(emulateZeroWaitTr) //ALWAYS ON { SUBINIT #2 - if structure target is eliminated, proceed to anti-unit script - if it is not, make sure all units are attacking - order closest units to attack - force freshly build reinforcements to move to enemy base location as backup }
event tank_AAS_AT1(emulateZeroWaitTr) //ALWAYS ON { ANTI-UNIT ATTACK SCRIPT - this script requires x,y coordinates to be given by another script
(POSITIONING SCRIPT) - enumerate area near coordinates, detect unit presence - decide whether it’s a good time to start with unit attack, return to
POSITIONING if necessary - if it’s time to eliminate units in area, select random unit in close proximity
to given coordinates - execute attack, remember Target to avoid re-activating attack }
event tank_AAS_WITHDRAW(tankMoveTr) //every, 50 { WITHDRAW SCRIPT - execute if following conditions found: majority of forces decimated, enemy
defeated, attack cancelled, a bug freezed attack scripts - stop attack and force all units to return to base for repairs - restart and reactivate all attacking script parts }
Cyborg Superior Assault Script event cyborg_AAS_INIT(cyborgInitTr) //inactive after init { ATTACK SCRIPT INITIALISATION - check if cyborgGroup has enough units to attack - AI has enough units - proceed to migration - AI has NOT enough units to attack - regroup units and prevent stucking in base - find a location as large as factory building on the edge of base and order all
units to regroup there (only if unit is not fighting at the time) - set defensive secondary orders for all units }
event cyborg_AAS_MIGRATION(emulateZeroWaitTr) //ALWAYS ON (WAIT,0 - EMULATION) { MIGRATION SCRIPT - start attack preparations - select enemy player to attack - select a neutral spot between own and enemy base - move all units to regrouping location }
event cyborg_AAS_SUBINIT1(emulateZeroWaitTr) //ALWAYS ON { SUBINIT #1 - wait for majority of units to regroup - activate positioning }
event cyborg_AAS_POSITIONING(emulateZeroWaitTr) //ALWAYS ON (WAIT,0 - EMULATION) { POSITIONING SCRIPT - select enemy target of opportunity (structure) that is nearest to regrouping
location - check for unit presence aroung structure and decide whether attack buildings
or units first - select final target (original structure) or switch to ani-unit attack script - execute attack; remember Target to avoid re-activating attack }
event cyborg_AAS_SUBINIT2(emulateZeroWaitTr) //ALWAYS ON { SUBINIT #2 - if structure target is eliminated, proceed to anti-unit script - if it is not, make sure all units are attacking - order closest units to attack - force freshly build reinforcements to move to enemy base location as backup }
event cyborg_AAS_AT1(emulateZeroWaitTr) //ALWAYS ON { ANTI-UNIT ATTACK SCRIPT - this script requires x,y coordinates to be given by another script
(POSITIONING SCRIPT) - enumerate area near coordinates, detect unit presence - decide whether it’s a good time to start with unit attack, return to
POSITIONING if necessary - if it’s time to eliminate units in area, select random unit in close proximity
to given coordinates - execute attack; remember Target to avoid re-activating attack }
event cyborg_AAS_WITHDRAW(cyborgMoveTr) //every, 50 { WITHDRAW SCRIPT - execute if following conditions found: majority of forces decimated, enemy
defeated, attack cancelled, a bug freezes attack scripts - stop attack and force all units to return to base for repairs - restart and reactivate all attacking script parts }
GROUND ATTACKS END
event doResearch(doResearchTr) { RESEARCH SCRIPT - if player has enough power, do research in all research centers }
event doResearchLP(doResearchLPTr) { RESEARCH SCRIPT LOW POWER - always research stuff in 2 research centers (executed less often) }
event managePower(managePowerTr) { RESEARCH POWER GENERATOR PGRADE AS TOP PRIORITY TASK - if low on power, research vital powerGen technology }
event vtolStructs(scoutMainTr) { VTOL STRUCTURE BUILDING SCRIPT - check for number of VTOL Factories - check for number of VTOL Rearming Pads - dynamically build the two structures up to 2 factories and 10 rearming pads - just in case, check for HQ to be build }
event SelectRndTemplateVRun(inactive) { PRODUCE VTOLS AND VTOL TRUCKS - check for power level and limit building to 1 VTOL factory on low power state - execute for each completely built VTOL factory without any task (idle factory) - check if more trucks are required, build one if required - process all available unit templates in Floating Point Randomizer with radius
2 and determine VTOL to be built - build VTOL }
event SelectRndTemplateV(cyborgBuildEventTr ) { ACTIVATES SelectRndTemplateVRun EVENT - activate SelectRndTemplateVRun event }
VTOL&NEXUS TOTAL CONTROL SCRIPTS Warning: Warzone built-in handling for NEXUS Link overtaking is sometimes buggy,
I had to make TCS to make sure AI has always control over taken-over unit, unit
resorting script is also specifically build to handle NEXUS TCS.
event intruderDetected(vtolDefendTr) { ADD INTRUDER TO TCS TARGET LIST - executed when a unit attack AI’s structure - check for unit designation, if determined as hostile, add unit to TCS ATTACK
LIST }
event newObjectReport(newDroidReportTr) { ADD SPOTTED UNITS TO TCS ATTACK LIST - execute if enemy unit emerge in sensor range - check for unit designation and type - if enemy unit is tank or cyborg, add it to TCS ATTACK LIST }
event sendNEXUS(inactive) { ORDER NEXUS Link UNITS TO ATTACK - recompile TCS ATTACK LIST, check for invalid, friendly or destroyed entries
and sort list - order NEXUSGroup to attack last entry in list - repeat attack orders in regular intervals so units won’t get stuck (WZ Engine
bug prevention) }
event sendNEXUSACTIVATE(NEXUSTeamGoTr) { ACTIVATES sendNEXUSACTIVATE EVENT - activate sendNEXUSACTIVATE event }
event NEXUS_RTB (NEXUSCheckTr) { RETURNS IDLE NEXUS UNITS TO BASE - detect idle units - return to base (technically remove „stuck status“ and make NEXUS units to
accept new orders and show idle status) – bug prevention }
event engageAndOvertakeAtWill(NEXUSStopAndEngage) { DEFEND DURING MISSION - execute if NEXUS Link unit is attacked during attack mission - stop and take over attacker }
event sendVtols(inactive) { VTOLS UNIT ATTACKS - SEND VTOL-UNIT TEAM - recompile TCS ATTACK LIST, check for invalid, friendly or destroyed entries
and sort list - target first unit in TCS ATTACK LIST - detect AA sites near targeted unit - skip attacking unit and attack AA site as first priority - if area is clear, attack enemy unit until destroyed or inside base }
event aimingPrecissionFix(NEXUSTeamGoTr) { COMPENSATE UNIT MOVEMENT - periodically resend VTOLUnitGroup to its target, prevent VTOL NEXUS Units to
get stucked and aim VTOL strike to updated location of moving enemy. }
event sendVtolsACTIVATE(VtolsTeamGoTr) { - activate sendVtols event }
event vanishScreen(inactive) //vtolAttackTr2) { RESTART MAP VISIBILITY (DISABLED FOR DEVELOPMANT PHASE) - restart visibility and give TCS better chance to catch new units }
event targetExpirationCheck(NEXUSTeamGoTr) { DELETE TARGET FROM TCS ATTACK LIST AFTER 4 MINUTES - iterate through TCS ATTACK list and delete outdated entries }
event groundTCS(TankTCSTr ) { BATTLEDROID TOTAL CONTROL SCRIPT (BATTLEDROID SURVIVAL METHOD) - execute if AI’s unit was attacked - check attacker’s designation and type - counter-attack if possible or return to base }
event LiveShield(vtolDefendTr) { DROID GROUPS TCS - PROTECTS BASE AGAINST LONG RANGE ATTACKS - execute if AI’s structure is attacked - if structure is part of main base and some units are idling in base - counter-attack intruder - Well... This is kind of simple compared to script itself ... :D }
ADVANCED VTOL ATTACKING SCRIPT MK-V
a.k.a. VTOL SUPREME ASSAULT SCRIPT
event vtol_AAS_INIT(vtolInitTr) //inactive after init { INITIALIZATION - execute if vtolGroup has enough units to start attack - activate AVAS MK5 and proceed to FIRST ATTACK }
event vtol_AAS_FirstAttack(emulateZeroWaitTr) //ALWAYS ON (WAIT,0 - EMULATION) { FIRST ATTACK - randomly select enemy player to attack - select nearest target of opportunity - check for AA sites around selected target - if script detected only few AA sites, attack AAs first - if area is crawling with hostile AAs, ignore this threat and attack original
target regardless - if TCS vtolUnitGroup is idle, assign it to help in attack - activate subinit1 }
event vtol_AAS_SUBINIT1(emulateZeroWaitTr) //ALWAYS ON { SUBINIT #1 - wait for original target to be destroyed or attack cancelled - activate REPEAT }
event vtol_AAS_RepeatAttack(emulateZeroWaitTr) //ALWAYS ON (WAIT,0 - EMULATION) { REPEAT ATTACKS - select nearest target of opportunity - check for AA sites around selected target - if script detected only few AA sites, attack AAs first - if area is crawling with hostile AAs, ignore this threat and attack original
target regardless - if TCS vtolUnitGroup is idle, assign it to help in attack - activate subinit1 }
event vtol_AAS_WITHDRAW(vtolMoveTr) //every, 50 { WITHDRAW - execute if following conditions found: majority of forces decimated, enemy
defeated, attack cancelled, a bug freezed attack scripts - restart AVAS MK5 - order all VTOL units to return to base for repairs }
AVAS MK5 END
event vtolDefend(vtolDefendTr) { ANTI-AIR PROTECTOR - execute when a unit attack AI’s structure - check unit’s designation - if unit is enemy VTOL, send remote AAP request to defendBase event }
event vtolPrevention(fortifyTr) { PREVENTIVE AAP CALLS - iterate all essential structures - determine location as large as factory structure near building - check for AA sites nearby - send remote AAP request to defendBase event if number of AAs is insufficient }
event difficultyModifier(inactive) //upgradeStructuresTr) -cheat disabled { DIFFICULTY SLIDER CHEAT (DISABLED) - this script is considered AI cheating and is disabled unless stated otherwise
in cheat setup in VLO file }
event truckSurvival(upgradeStructuresTr) { TRUCKS SURVIVAL SCRIPT MK3 - this very complicated script assures that truck won’t go anywhere near enemy
weapon and won’t get destroyed - truck in close proximity to enemy unit/defense is immediately sent to fake
location near base HQ }
event tankRepairs(scoutMainTr) { REPAIR IDLE UNITS - check for members of tankGroup and cyborgGroup idling in base - order damaged unit without order to RTR (Return to repair) }
event skLocateEnemyMethod(tankAttackTr5) { USE 'skLocateEnemy' INTERNAL WZ2100 METHOD FOR ATTACKS IF ALL ELSE FAILED - if there’s no attempt to attack anything for 22 minutes, use old 'skLocateEnemy'
Warzone call - this is required mainly in AI battles when one of AIs is defeated but some
units are stuck out of range and BecomePrey forces can’t find it. }
event unitAssignationCheck(upgradeStructuresTr ) { ASSIGNATION CHECK - activate resorting script if required to gain control over all units again - make sure BecomePrey will live if at least one truck survived enemy attack }
event restoreAttacks (inactive) { RESTORE ATTACK SCRIPTS - after given time elapsed, return all units to base and restore attack function }
event sendHelpNow(sendHelpNowTr) { ASK 4 HELP FEATURE FOR BecomePrey BOT - executed when human player offers alliance to an enemy - execute if human player is my lord (AI is assigned to help this human player) - send all available forces to player’s HQ if present - stop all recent attacks }
event CheatIfYouCan(CheatsTr) { CHEAT SETUP - enable/disable cheat functions according to player settings }
event plannedResort (upgradeStructuresTr) { RESORT UNITS – REMOTE answer remote calls for unit resorting }
REINCARNATION SCRIPT event playerBlesses(blessTr) { PLAYER GIVES LIFE - give spare trucks and few oil derricks to allied player that was just defeated
and restore his life }
event playerDefeated(scoutMainTr ) { DIE - executed when player died - terminate all life functions and wait for reincarnation }
event playerReborn(scoutMainTr ) { REBORN - re-activate all life functions - select new spot for HQ if needed }
event reassignPlayers(reassignTr) { RESTART AI FUNCTIONS IF HUMAN LEFT MULTIPLAYER GAME - restart all NOTE: all scripts freeze when human leave the game, this prevents AI disabling }
DOCUMENTATION END
|
Data sources Information Sources used for creating AI: scriptLang.rtf – official WZ scripting language documentation scriptLang1.3.rtf – WZ scripting language documentation revised in 2004 by
Chojun (included on attached CD) 1.10AI – original Warzone skirmish AI developed by Alex McLean, chief technology
engineer of Pumpkin Studios |
Information Sources used for Warzone history and features: LavCoyote25’s Warzone Document Project - http://members.shaw.ca/kgmetcalfe/ |
| |
|
Česko-anglické gymnázium v Českých Budějovicích
Seminární práce
Artificial intelligence in computer game
Konzultant : Mgr. Pavel Hartman
Obor : Výpočetní technika
Student : Martin Němeček
Ročník : 3.ročník
Školní rok : 2004/2005
23.února 2005 v Českých Budějovicích |