artificial intelligence
play

Artificial Intelligence Games need opponents that are challenging, - PDF document

10/4/2012 Introduction to Artificial Intelligence (AI) Many applications for AI Computer vision, natural language processing, speech recognition, search But games are some of the more interesting apps Artificial Intelligence


  1. 10/4/2012 Introduction to Artificial Intelligence (AI) � Many applications for AI � Computer vision, natural language processing, speech recognition, search … � But games are some of the more interesting apps Artificial Intelligence � Games need opponents that are challenging, or allies that are helpful � In general, any unit that is credited with acting on own � But human-level intelligence still too hard � But under narrow circumstances can do pretty well (ex: chess and Deep Blue ) � Fortunately, for many games, circumstances often constrained (by game rules) � Artificial Intelligence (around in CS for some time) Where to Learn AI at WPI? AI for CS different than AI for Games � IMGD 3000 � Must be smart, but purposely flawed � Introduction to idea � Loose in fun, challenging way � “Whirlwind” view of techniques � No unintended weaknesses � Basic pathfinding (A*) � No “golden path”, readily exploitable weakness to defeat � Finite State Machines � IMGD 4000 � Must not look “dumb” � Details on basic game AI commonly used in many games � Must perform in real time � Decision trees � Even turn-based games have humans waiting � Hierarchical state machines � Advanced game AI used in more sophisticated games � Often, configurable by designers � Advanced pathfinding � Not hard coded by programmer � Behavior trees � � “Amount” and type of AI for game can vary IMGD 4100 (in 2014) “AI for Interactive Media and Games” � Fuzzy logic � RTS needs global strategy, FPS needs modeling of individual � Goal-driven agent behavior units at “footstep” level � CS 4341 “Artificial Intelligence” � RTS most demanding: 3 full-time AI programmers � Machine learning � Puzzle, street fighting: 1 part-time AI programmer � Planning � Natural language understanding Outline Common Game AI Techniques (1 of 4) � Whirlwind tour of common techniques � Introduction (done) � For each, provide idea and example (where appropriate) � Common AI Techniques (next) � Movement � Flockin g � Promising AI Techniques � Move groups of creatures in natural manner � Each creature follows three simple rules � Pathfinding (A*) � Separation – steer to avoid crowding flock mates � Alignment – steer to average flock heading � Finite State Machines � Cohesion – steer to average position � Example – use for background creatures such as birds or fish. � Summary Modification can use for swarming enemy http://processing.org/learn � Formations ing/topics/flocking.html � Like flocking, but units keep position relative to others � Example – military formation (archers in the back) 1

  2. 10/4/2012 Common Game AI Techniques (3 of 4) Common Game AI Techniques (2 of 4) � Behavior organization � Movement (continued) � Emergent behavior � A* pathfinding � Create simple rules result in complex interactions � Cheapest path through environment http://www.youtube.com � Example: game of life, flocking /watch?v=XcuBvj0pw-E � Directed search exploit knowledge about destination to � Command hierarchy intelligently guide search � Deal with AI decisions at different levels � Fastest, widely used � Modeled after military hierarchy (i.e. General does strategy, Foot � Can provide information (i.e. virtual breadcrumbs) so can Soldier does fighting/tactics) follow without recompute � Example: Real-time or turn based strategy games - overall strategy, � Details later! squad tactics, individual fighters � Obstacle avoidance � Manager task assignment � A* good for static terrain, but dynamic such as other players, � When individual units act individually, can perform poorly choke points, etc., cause problems � Instead, have manager make tasks, prioritize, assign to units � Example – same path for 4 units, so get “clogged” in narrow � Example: baseball – 1 st priority to field ball, 2 nd cover first base, 3 rd to opening. Instead, predict collisions so furthest back slow backup fielder, 4 th cover second base. All players try to get ball, then down, avoid narrow bridge, etc. disaster! Manager determines best person for each. If hit towards 1 st and 2 nd , first baseman fields ball, pitcher covers first base, second basemen covers first Outline Common Game AI Techniques (4 of 4) � Influence map � Introduction (done) � 2d representation of “power” in game � Break into cells, where units in each cell are summed � Common AI Techniques (done) up � Units have influence on neighbor cells (typically, � Promising AI Techniques (next) decrease with range) � Insight into location and influence of forces � Pathfinding (A*) � Example – can be used to plan attacks to see where enemy is weak or to fortify defenses. SimCity used � Finite State Machines to show pollution coverage, etc. � Level of Detail AI � Summary � In graphics, polygonal detail less if object far away � Same idea in AI – computation less if won’t be seen � Example – vary update frequency of NPC based on position from player Promising AI Techniques (2 of 3) Promising AI Techniques (1 of 3) � Filtered randomness � Bayesian network � Want randomness to provide unpredictability to AI � A probabilistic graphical model with variables and probable � But even random can look odd sometimes (e.g. if 4 heads in influences a row, player will think something wrong. And, if flip coin � Example - calculate probability of patient having specific disease 100 times, there likely will be streak of 8) given symptoms � Example – AI can infer if player has warplanes, etc. based on what � E.g. spawn at same point 5 times in a row, then bad it sees in production so far � Compare random result to past history and avoid � Can be good to give “human-like” intelligence without cheating or � Fuzzy logic being too dumb � Decision tree learning � Traditional set, object belongs or not � Series of inputs (usually game state) mapped to output (usually � In fuzzy, can have relative membership (e.g. hungry, not thing want to predict) hungry. Or “in-kitchen” or “in-hall” but what if on edge?) � Example – health and ammo � predict bot survival � Cannot be resolved by coin-flip � Modify probabilities based on past behavior � Example – Black and White could stroke (reward) or slap (punish) � Can be used in games – e.g. assess relative threat creature. Creature learned what was good and bad. 2

  3. 10/4/2012 Promising AI Techniques (3 of 3) Outline � Genetic algorithms � Search and optimize based on evolutionary principles � Introduction (done) � Good when “right” answer not well-understood � e.g. may not know best combination of AI settings. Use genetic � Common AI Techniques (done) algorithsm to try out � Often expensive, so do offline � Promising AI Techniques (done) � N-Gram statistical prediction � Predict next value in sequence (e.g.- 1818180181 … next will � Pathfinding (A*) (next) probably be 8) � Search backward � values (usually only 2 or 3) � Finite State Machines � Example � Street fighting (punch, kick, low punch…) � Summary � Player does low kick and then low punch. What is next? � Uppercut 10 times (50%), low punch (7 times, 35%), sideswipe (3 times, 15%) � Can predict uppercut or, proportionally pick next (e.g. roll dice) Pathfinding Representing the Space � System needs to understand � Often seems obvious and the level natural in real life � But not full information, only � E.g. Get from point A to B relevant information (e.g. is it � go around lake passable, not water vs. lava vs. � For computer controlled tar…) � Common representations player, may be difficult � 2d Grid � E.g. Going from A to B goes � Each cell passable or impassible through enemy base! � Neighbors automatic via indices � Want to pick “best” path (e.g. 8 neighbors) � Need to do it in real-time � Waypoint graph � Connect passable points � Q: why can’t just figure it � Neighbors flexible (but needs to out ahead of time (i.e. be stored) � Good for arbitrary terrain (e.g. before game starts)? 3d) Finding a Path Consider Simple - Random Trace � Path – a list of cells, points � Agent moves towards goal or nodes that agent must traverse to get to from start � If goal reached, then done to goal � If obstacle � Some paths are better than others � Trace around obstacle clockwise or � measure of quality � Algorithms that guarantee counterclockwise (pick randomly) until free path path called complete towards goal � Some algorithms guarantee � Repeat procedure until goal reached optimal path (best quality) � Others find no path (under � (Humans often do this in mazes) some situations) 3

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend