320 likes | 433 Views
CO3301 - Games Development 2 Week 19 Production Systems. Gareth Bellaby. Next week. Acceptance check for Project CVs. Prepare a CV or bring along a previous one. Jobs. Knowledge Representation. There are a variety of knowledge representation methods.
E N D
CO3301 - Games Development 2Week 19Production Systems • Gareth Bellaby
Next week • Acceptance check for Project • CVs. Prepare a CV or bring along a previous one. • Jobs.
Knowledge Representation • There are a variety of knowledge representation methods. • Most AI is based on symbol manipulation, i.e. a set of symbols with a set of procedures for operating on them. • Knowledge is representation and the methods for manipulating it.
Knowledge Representation • A set of facts can be represented in a database. However, a database has very low inferential capabilities. It might be possible to use an inference engine (cf. Data Mining). • Database: static, flat, homogenous, passive. • Knowledge Base: flexible, layered, heterogeneous, active. This is what is used in an expert system.
Procedural Knowledge • Procedural knowledge is operational, i.e. what to do when. • Could be directly coded, but such an approach has low inferential adequacy and low acquisitional adequacy. • Most common method is production rules.
Production Rules • IF a person has a risk of heart attack • AND a person has had a previous heart attack • THEN give digitalis • New knowledge is derived using various reasoning mechanisms.
Rule-based system • 1. If ?x has hair • then ?x is a mammal • 2. If ?x is a mammal • and ?x chews cud • then ?x is an goat • 3. If ?x is a mammal • and ?x long neck • then ?x is an giraffe
Example & Exercises • Gordon has hair and a long neck. • Michael has hair. • Graham is a mammal and chews cud. • Thomas has a long neck.
Inference • Deduction is the process of reasoning from premises to conclusions. • A deductive argument can only bring out what is already implicit in its premises. • However, it can also give rise to questions. Questions are requests about facts for which we currently have no data.
Forward and Backward Chaining • Reasoning carried out by a interpreter. • Two methods: • forward chaining from assertions • backward chaining from hypotheses • Rule-based system is a deduction system.
Forward Chaining • Gordon has hair => Gordon is a mammal • Gordon has a long neck • we already know that Gordon is a mammal • the animal is a mammal and the animal has a long neck => Gordon is giraffe
Backward Chaining • Gertrude has long neck. • Look for the gaps in our knowledge. • Giraffes have a long neck and are mammals. Gertrude may be a giraffe. • Is Gertrude a mammal? • Mammals have hair. We need to find out if Gertrude has hair.
Rule Based Systems • AI Interface Standards Committee, 2005 AIISC Report • http://www.igda.org/ai/report-2005/rbs.html
Age of Empires III • rule startFishing • inactive • group tcComplete • mininterval 15 • { • bool givenFishingBoats = false; • if ( (kbUnitCount(cMyID, cUnitTypeFishingBoat, cUnitStateAlive) > 0) && (gWaterExploreMaintain < 0) && (gFishingPlan < 0) ) • givenFishingBoats = true; // I have fishing boats, but no fishing or water • // scout plans, so they must have been given to me. • if (givenFishingBoats == false) // Skip these early-outs if we were granted free // boats. • { • if ( (kbGetCiv() == cCivDutch) && (kbUnitCount(cMyID, cUnitTypeBank, cUnitStateABQ) < 1) ) • return; // Don't burn wood before we have a bank
Rule Based Systems and FSMs • Obviously some similarity between the two. • If you have a situation in which all of the states can lead to all of the other states then a rule-based system is more useful than an FSM.
Reasoning and inference • It's possible to store knowledge in such a way that the structure allows reasoning to occur. • The structure used to store the knowledge allow the derivation of new facts from those facts which are explicitly stored. • The mechanism for deriving information depends on the structure.
Structure of Production Rules • The order of the production rules is the primary way of structuring production rules. • Sequential logic. • The rules are examined in order. Later rules may therefore be ignored.
Semantic Nets • Semantic = "meaning" • A semantic net is a set of nodes (usually items you want to represent knowledge about) connected by a set of links. The links are labelled and represent relations between the nodes.
Human Studies • Derived from human studies (Collins and Quillian, 1969). • People appear to store information at the most abstract level. They don't remember that canaries fly, robins fly, swallows fly, etc. Instead they remember that birds (in general) fly, and that canaries, robins and swallows are all types of birds.
Human Response Times • Evidence is the difference in response time to questions. Subjects took longer to answer "Can a canary fly?" than "Can a canary sing?". Singing is a specific property of (or closely associated with) canaries, whilst flying is a general property of being a bird.
A Semantic Net Example animal isa fly bird can has wings isa canary sing can
Frames (slot and filler structure) • Formally equivalent to semantic nets. • A collection of semantic net nodes and slots that together describe an object, act or event.
Frames • frame is a list • slot is an attribute • A frame is a list of attributes (slots) and associated values that describe some entity in the world. • Slots can be values, constraints or procedures. • Some Advantages: • fairly detailed • inheritance links give a form of default reasoning
Frames example FRAME: bird a_kind_of: animal moving_method: fly active_at: daylight FRAME: albatross a_kind_of: bird colour: black_and_white size: 115
Rule-based system • One use of production rules is in expert systems. An expert system is a specialized problem solving program designed to work in a single area of human expertise. • Typically use a production system. • Geological analysis, for instance for mining and drilling, e.g. PROSPECTOR. • Medical diagnosis, e.g. MYCIN.
A MYCIN Rule • If • the infection is primary-bacteraemia, and • the site of the culture is a sterile site, and • the suspected portal of entry of the organism is the gastro-intestinal tract, • then there is suggestive evidence (0.7) that the identity of the organism is bactericides
Expert Systems • Expert systems include: • Rule base or Knowledge base: using production rules (the knowledge base). A rule links conditions to outcomes or actions. Stores the rules, cases, relationships, etc. • Working memory. • Inference engine (the interpreter). Runs the production rules, checks to see if rule applies, e.g. decisions about which rule to fire, or places in the firing of rules into ranked order. • An expert system shell is an inference engine with an empty knowledge base, e.g. Leonardo.
Working memory • Current state of the system. • Contents of the working memory are compared to the rules. • If a rule matches the working memory then the rule triggers. • More than one rule could match the contents of working memory.
Knowledge Acquisition • Knowledge is acquired from experts, typically through interviews, observation of problem analysis. • Research still underway into formal methods for knowledge acquisition. • Research still underway in to machine learning, e.g. rule induction or learn by example. • Less useful for games since direct querying of an expert less required. • Difficulties of setting up the expertise for a computer game.
Developing An Expert System • The single most difficult task is interviewing the expert: • differences in language between expert and researcher • differences in intention between expert and researcher • have to convert experience and expertise into facts and rules
Structures • Rules can be set out as a tree. • Expert systems typically use backwards chaining with opportunistic forwards chaining.
References • Any AI book, e.g. Russell & Norvig. • AI Interface Standards Committee, 2005 AIISC Report • http://www.igda.org/ai/report-2005/rbs.html • Rabin , "Promising Game AI Techniques", AI Game Programming Wisdom 2, 2003. • "Practical Logic-Based Planning" , Daniel Wilhelm, AI Game Programming Wisdom 4, 2008. • A Simple Inference Engine for a Rule-Based Architecture, Mike Christian, AI Game Programming Wisdom, 2002. • A Rule-Based Architecture using Dempster-Shafer Theory, François Dominic Laramée, AI Game Programming Wisdom, 2002.