130 likes | 139 Views
Dive into the intricacies of Homeworld 2's AI system - from Tactical to Strategic AI forms. Learn how the game AI ensures challenging gameplay and adapts to player skill levels. Explore exclusive insights from a Sierra programmer on the decision-making processes behind the AI. Discover the scripting and coding techniques used to create dynamic AI behavior in the game. Benefit from expert tips on optimizing both Tactical and Strategic AI for enhanced gaming experiences.
E N D
Nicholas Mezza CIS 488 Winter 2006 Homeworld 2
Homeworld 2 is a 3D Real Time Strategy Game (RTS) The player controls a fleet of spacecraft and must fight it out with up to 5 other players. Overview
There are two major forms of AI in this game: Tactical / Unit AI determines how each unit reacts to orders or how they react to other units. Strategic AI determines how a computer player builds their fleet and attacks other players. Forms of AI
This is an excerpt from an interview done with Dan Irish, a Sierra programmer. These are the two main goals the creators had when designing the AI The main goal in designing and implementing an AI for Homeworld2 is to ensure that it offers a challenge, while providing the subtleties that make it play as a human would. I remember playing Homeworld when it first came out (I worked at a different company then) and instantly realizing that the AI formations would always act a certain way and the ships would always fly in perfect formation when coming to attack. The second challenge is the introduction of random errors into the AI's routines, so that it has the ability to scale the difficulty depending upon the skill level of the player. Dan Irish on AI
Homeworld 2 uses SCAR (a proprietary scripting language) and Lua scripting for its decision based AI. The game itself is coded in C++. The game AI is a rule-based system using weighting (priorities). How does it work?
function Logic_military_groupvars() cp_minSquadGroupSize = 4 cp_minSquadGroupValue = 150 if (sg_moreEnemies > 0 and s_selfTotalValue < s_enemyTotalValue*2) then cp_minSquadGroupSize = cp_minSquadGroupSize + 2 cp_minSquadGroupValue = cp_minSquadGroupValue + 75 else -- if we are winning, meaning we have quite a bit more military then the enemy then reduce minsize and value --aitrace("playerthreat:"..playercompare) if (s_militaryStrength > 120) then cp_minSquadGroupSize = 3 cp_minSquadGroupValue = 120 end end end Example – Strategic Ruleset
Data = { -- when approaching the target use this method to split the formation and transition in to the attack style howToBreakFormation = StraightAndScatter, -- Maximum distance to get from the target when breaking away. maxBreakDistance = 4000.0, -- break off the attack run when this distance from the target distanceFromTargetToBreak = 2000.0, safeDistanceFromTargetToDoActions = 2800.0, useTargetUp = 0, -- data for picking the position in space to fly to when we break off the attack run -- how to orient the choice of break point, options are Attacker,Target and TargetAttackPoint coordSysToUse = Target, horizontalMin = 0.6, horizontalMax = 0.9, horizontalFlip = 1, verticalMin = 0.2, verticalMax = 0.6, verticalFlip = 1, Example - Tacticalflyby_Interceptor_vs_CapShip_mod
-- done at the end of every strafing run RandomActions = { { Type = PickNewTarget, Weighting = 1, }, { Type = NoAction, Weighting = 2, }, }, BeingAttackedActions = { }, FiringActions = { { Type = FlightManeuver, Weighting = 99, FlightManeuverName = "RollCCW", }, }, } flyby_Interceptor_vs_CapShip_mod
Original Script Differences: -- Maximum distance to get from the target when breaking away. maxBreakDistance = 1600.0, -- break off the attack run when this distance from the target distanceFromTargetToBreak = 800.0, safeDistanceFromTargetToDoActions = 1200.0, useTargetUp = 0, Example - Tactical 2flyby_Interceptor_vs_Capship
-- It has more, less common, actions upon firing FiringActions = { { Type = NoAction, Weighting = 25, }, { Type = FlightManeuver, Weighting = 3, FlightManeuverName = "RollCW", }, { ... flyby_Interceptor_vs_Capship
Tactical AI is scalable and works well even with a large number of units. Tactical AI results in fluid, realistic battles. While Strategic AI is relatively simple, it does not require much CPU time. Strengths
Strategic AI essentially just throws waves of units at you. There are rules (modified by game difficulty) as to how many ships should build up before this happens. Strategic AI requires a large number of defined rules for specific things to build or research. No learning Tactical AI cannot switch between multiple tactics per unit type. i.e. It's limited to a single ruleset and can only randomly choose predefined reactions. Weaknesses