350 likes | 511 Views
Weapon Selection. CIS 488/588 Bruce R. Maxim UM-Dearborn. Weapon Properties. Definitely affect weapon behavior Melee or range Projectile speed Rate of fire Damage Spread angle Damage rate
E N D
Weapon Selection CIS 488/588 Bruce R. Maxim UM-Dearborn
Weapon Properties • Definitely affect weapon behavior • Melee or range • Projectile speed • Rate of fire • Damage • Spread angle • Damage rate • In a game world the designer’s creativity and the game’s entertainment value can be more important than physical constraints
Weapon Applicability • Relative positions of combatants to one another • Evolving nature of a particular battle • Status of player and enemies • Environmental layout • Obstacles affecting trajectory or splash damage • Cluttering objects affecting weapon efficiency • Balance in exploiting enemy vulnerabilities • Player skill at handling a weapon
Training Zone Attributes • Representative terrain • Lots of ammo and weaponry available • Can allow bot to choose weapons arbitrarily or train them extensively with selected weapons one at a time • Provide diverse combat scenarios
Mr. Versatility • Capable of using all game weapons • Has weapon specific shooting skills • (not found yet)
Weapon Evaluation • Relevant game features can be modeled using symbols or numeric values • Player features may also be modeled • These features can be used as inputs to an evaluation function that returns a numeric value representing weapon fitness • The function can contain any simple or exotic algorithm for doing selection (including RBS or trained NN)
Weapon Selection • The AI control algorithm works though a O(n) process of applying the fitness function to each available weapon and selects the one with the best fitness score • The fitness function suffers from the same information loss weaknesses and credit assignment problems as does the static evaluation in the mini-max algorithm
Role of Deduction • Human can make use of deductive reasoning to break a decision down into easily solved sub-problems • This requires the ability to extract key features of a situation and induce the weapon properties that are necessary • This process can be modeled by the the production rules in a RBS • Building production rules takes time
Role of Experience • Humans can make use of memory to avoid repeating costly trial and error experiments • This requires extensive combat history if these banked decisions are to be worthwhile • Simulation can be used to help agents acquire this kind of history • People can share this history with each other and look for trends that may be relevant to new or unknown situations
Hybrid Approaches • Deduction requires heavy reasoning on simple knowledge • Experience used no reasoning but requires lots of knowledge based on history • A combined strategy might seek to extend knowledge gathered by experience by using logic to extend it further • There is a tradeoff between time needed to acquire data and the accuracy of the estimates
Weapon Selection Criteria • Decisiveness • One a weapon is selected by the AI it should not be swapped unless there will be an easily recognized improvement in AI shooting effectiveness • Justifiability • Players observing the weapon used by the AI should be able to explain the choice of the weapon for use in the current situation
Case Study • Weapon choices could be ranges • Long distance (prefer precise weapons) • Medium distance (prefer splash damage) • Close distance (high spread fast projectiles) • Fight flow of control • Powerful weapons when NPC is desperate • Precise weapons when NPC is under control • Weapon change time limited to 5 seconds during combat
Joyce • Contains weapons selection component in its architecture • Scans possible weapons and calls a fitness evaluation function to aid in selection • Evaluation is done using RBS • Best weapon returned via interface • (not found yet)
Context • Weapon model may be the most important aspect of context, but does not need to be very detailed (e.g. could a symbol) • 3D animated models are relied on to translate symbol manipulation in weapon changes and firing behavior
Environment • Only local terrain information is required to predict player and projectile movement • Weapon selection has impact that often extends beyond a single “turn” • Weapon selection may also require information on tactical space for movement around enemy • Might be sufficient to return distance to obstacles near enemy
Player State Information • Heads up display (HUD) provides human player info on his health, weapon, and armor • AI has access to same info in HUD • Enemy NPC state is harder for animat to determine without “cheating” via direct queries • Many times indirect evidence (sounds and projectile impact) can be monitored by NPC’s like human players would do
Representing Weapon Properties • Declarative • Can represent them as a set of rules • Separates data and code • Implicit • Weapon properties induced by observing their effects of the environment • Query • Provide dedicated interface to return precise weapon properties at run-time
Actions • Selecting a weapon could be done using a single procedure call • Selection can be done by cycling through the list of weapons using a series of scripting commands • There may be some delay between selection and the time the correct animation frame sequence is activated
Specification • Symbols will be defined for each of the ten weapons • AI can find out about weapon availability from new inventory interface • Weapons properties will need to be induced during game play • A high-level query will return information about space constriction near target
Interfaces - 1 • Weapon bool Select(const Symbol& weapon); • Inventory (self) void WeaponsAvailable (vector<Symbol>& weapons); • Health (self) int Heath( );
Interfaces -2 • Constriction (enemy) float GetSpatialRestriction( ); • Damage (to enemy) – event callback void OnDamage(const Event_Damage& e);
Code Skeleton void Think( ) { // determine available weapons vector<Symbol>& weapons; personal->WeaponsAvaliable(weapons); // extract situation properties float f = vision->SpatialRestriuction( ); int h = personal->Health( ); // make weapon decision weapons->Select(weapons[i]); }
Sir Obvious • Checks inventory to find weapons and corresponding ammo available • Health changes and terrain constraints are also noted • Prints finding on debug console • (not found yet)
Scripting Languages - 1 • Not AI, but commonly used in games • Loosely typed or dynamically typed • Syntax easier to use than programming language • Compact and powerful statements • Allow for rapid prototyping • Scripts translated to byte code when loaded • Interpreter executes each statement as it is encountered in turn
Scripting Languages - 2 • The scripting environment can be embedded in the application • Alternatively the programming language could be integrated with the scripting language as a means of extending it • A high-level interface can be used to pass all needed data to a script before it runs • It is also possible to allow the scripting language to use input/output interfaces to interact with the world as it executes
Python Weapon Evaluation def EvaluateWeapon(type, ammo): if ammo > 0: if type == “railgun”: return 2 return 1 return 0 • External function calls are easy to handle • If function parameters and return values are required you will need to provide overloaded functions in the interface • You will need to define generic functions to set and query global variables of each type
Voting System Overview • Deductive reasoning • Decisions deduced from initial facts • Declarative property specification • AI knows about firing rates and expected damage • Voting system used to ranks weapon properties • Properties will receive potentially many votes from many features • Votes used to determine weapon fitness
Weapon Properties • The relevant weapon properties are obtained from WWW for Quake2 • Rate of fire • Damage per shot • Damage per second • Speed of Projectile • Precision • Properties will be store in a data file to allow for easy editing and modification
Voting System • Features will be used to decide which weapon property is required most and vote for it • Votes are scaled by their importance (less than 1 and greater than 1) f(w) = P1(w)*V1 + … + Pn(w)*Vn w = weapon Pi(w) = ith weapon property weight Vn = total votes for property
Collecting Feature Votes • Expert needed to make judgments regarding feature importance in particular situations • Experts will assign weights to votes and fitness function will compute the dot product of the number of votes and their weights
Timing Restrictions • Prevent changing weapons if last change occurred a few seconds prior • No weapon switching while firing at enemies possessing ammunition (wait for cover or until enemy stops firing)
Picky • Contains script that implements a voting system used to select the best weapon • Can query world interfaces directly to gather information • Selected weapon is returned via higher-level interface • (seems to have a Python problem)
Evaluation - 1 • Experimentation phase requires lots of tweaking or votes and weapon property weights • When play is observed to be bad features are isolated to see what the problem is • Offending feature is adjusted until votes become reasonable • When votes seem balanced, the property weights are adjust to correct the fitness value
Evaluation - 2 • This system is easy to extend and easy to adjust • System does well at selecting weapons and mirrors human behavior with all its flaws • Adjusting the voting system by trial and error by hand does is not very satisfying • Supervised learning might be good alternative