Game Playing, CLOS - PowerPoint PPT Presentation

1 / 38
About This Presentation
Title:

Game Playing, CLOS

Description:

Will Rogers. Lecture 6-2. CS250: Intro to AI/Lisp. Knowledge Base ... Video sequence of interesting places. Actions. Drill to depth d. Move forward, backward ... – PowerPoint PPT presentation

Number of Views:33
Avg rating:3.0/5.0
Slides: 39
Provided by: kurtdfenst
Category:
Tags: clos | game | playing | rogers | video

less

Transcript and Presenter's Notes

Title: Game Playing, CLOS


1
Game Playing, CLOS Logical Reasoning I
  • Lecture 6-2
  • November 4th, 1999
  • CS250/350

2
Announcements
  • Midterms Back on Tuesday, maybe Thursday
  • Assignment 3
  • Projects

3
Playing games
  • Why study game playing?
  • Techniques for efficiency
  • Work smarter, not harder

4
Chess versus Go
5
3 Big Ideas from Games
  • Minimax (von Neumann Morgenstern)
  • ?-? Search -- Stop when things cant get any
    better
  • Even ?-? cant solve most games

6
Dont know CLOS? Its your loss
7
Do generic functions have the same quality as
name-brand functions, but at lower prices?
  • To put it another way

8
Object-oriented programming
class cString private char badIndex
protected cString repaceOneChar(char
findChar, char
replaceChar, ...) public cString()
cString(const unsigned size,
const unsignedsizeIncrement)
9
Message in an object
main () cString s1 "Now is the time for
all" s1.mapChars("0123456789",
")!_at_(", 10, 15)
10
Message-passing is passé
  • Objects have behaviors
  • Methods implement behavior
  • Ask objects to behave by calling an objects
    method
  • s1.mapChars()
  • Behaviors can be specialized for objects
  • Generic functions are bundles of methods
  • Methods are specialized for classes

11
Example from Logic
There are three generic functions that
operate on knowledge bases, and that must be
defined as methods for each type of knowledge
base TELL, RETRACT, and ASK-EACH. Here we
show the implementation for literal-kb
elsewhere you'll see implementations for
propositional, Horn, and FOL KBs. (defmethod
tell ((kb literal-kb) sentence) "Add the
sentence to the knowledge base." (pushnew
sentence (literal-kb-sentences kb) test
'equal)) (defmethod retract ((kb literal-kb)
sentence) "Remove the sentence from the
knowledge base." (deletef sentence
(literal-kb-sentences kb) test
'equal)) (defmethod ask-each ((kb literal-kb)
query fn) "For each proof of query, call fn on
the substitution that the proof ends up
with." (declare (special no-bindings)) (for
each s in (literal-kb-sentences kb) do
(when (equal s query) (funcall fn
no-bindings))))
12
Calling all methods
  • How does Lisp decide which method of a generic
    function to call?
  • Most specific method defined
  • Specialize on
  • Classes defined with defclass
  • Types
  • Individual objects

13
The Big Win for generic functions
  • Multiple dispatch Specialize on multiple
    arguments
  • C, Java are single dispatch

14
Back to Knowledge
  • A little logic goes a long way

15
Keep your eye on the prize
  • Why did we study heuristic search?
  • How else can we incorporate knowledge

16
Designing an Interplanetary Explorer
  • Goals for the explorer
  • Actions we can take
  • Situations that might arise

Can we anticipate everything?
17
Telling Your Computer about the World
  • What you know
  • How to go from what you know to what you dont
    know
  • Will Rogers

18
Knowledge Base
  • Knowledge baseDatabase KnowledgeData
  • KB stores what the computer knows about the world
  • Knowledge representation language
  • How we encode knowledge about the world
  • Each bit of knowledge is a sentence

19
OuRover
  • Goals
  • Gather core samples
  • Gather rocks
  • Video sequence of interesting places
  • Actions
  • Drill to depth d
  • Move forward, backward
  • Rotate r degrees
  • Transmit audio/video

20
Getting through to your computer
  • KB Interaction
  • Tell Add new sentences to the KB
  • Ask Query whats known (or what follows from
    what is known)

21
Tell-Ask.lisp I
Main Functions on KBs Tell, Retract,
Ask-Each, Ask, Ask-Patterns First we
define a very simple kind of knowledge base,
literal-kb, that just stores a list of literal
sentences. (defstructure literal-kb "A
knowledge base that just stores a set of literal
sentences." (sentences '()))
22
Tell-Ask.lisp II
There are three generic functions that
operate on knowledge bases, and that must be
defined as methods for each type of knowledge
base TELL, RETRACT, and ASK-EACH. Here we
show the implementation for literal-kb
elsewhere you'll see implementations for
propositional, Horn, and FOL KBs. (defmethod
tell ((kb literal-kb) sentence) "Add the
sentence to the knowledge base." (pushnew
sentence (literal-kb-sentences kb) test
'equal)) (defmethod retract ((kb literal-kb)
sentence) "Remove the sentence from the
knowledge base." (deletef sentence
(literal-kb-sentences kb) test
'equal)) (defmethod ask-each ((kb literal-kb)
query fn) "For each proof of query, call fn on
the substitution that the proof ends up
with." (declare (special no-bindings)) (for
each s in (literal-kb-sentences kb) do
(when (equal s query) (funcall fn
no-bindings))))
23
Tell-Ask.lisp III
There are three other ASK functions, defined
below, that are defined in terms of ASK-EACH.
These are defined once and for all here
(not for each kind of KB)." (defun ask (kb
query) "Ask if query sentence is true return t
or nil." (ask-each kb (logic query)
'(lambda (s) (declare (ignore s)) (RETURN-FROM
ASK t)))) Omitted pattern-matching ASKs
24
Knowledge-Based Agents
  • Agents perceive the world around them
  • Perceptions are recorded in the KB
  • Actions are chosen based on the KB
  • Results of actions are recorded

25
Levels of Agents
  • Knowledge level
  • What an agent knows
  • Planetary core samples must be taken at least
    100mm below the surface
  • Logical level
  • Knowledge is encoded at this level
  • MinDepth(CoreSample,100)
  • Implementation level
  • Inside the machine

26
Building Knowledge Agents
  • Lean on the inference mechanism
  • Tell agent what it needs to know
  • Declarative
  • Declare the state of the world, and let er rip
  • Adding learning
  • Reacting to percepts

27
Separate Domain-Specific from the General
28
Wumpus World
29
Specifying the Wumpus World
  • Percepts?
  • Actions?
  • Goals?

30
Describing the Wumpus World
  • Is the world
  • Deterministic
  • Fully accessible
  • Static
  • Discrete

31
One Environment is Easy
  • If we know the environment well, can engineer it
  • Range of environments?

32
Exploring the world
Perception Stench, Breeze, Glitter, Bump, Scream
Perceive None, None, None, None, None
33
Move Forward to 2,1
34
Perception after One Move
Stench None Breeze Yes Glitter None Bump None
Scream None
35
What Does the World Look Like?
36
Knowledge Representation
  • Not just computer readable
  • computer reasonable as well
  • Syntax - Rules for building expressions
  • Semantics - Relationship between facts in the
    world and sentences
  • Examples?

37
Entailment
  • What follows from what
  • Entailment is relationship among sentences
  • KB entails a
  • Follows is a relationship among facts in the
    world
  • Inference procedures that generate only entailed
    sentences is sound

38
Logical Committment
Write a Comment
User Comments (0)
About PowerShow.com