P8.py.

Slides:



Advertisements
Similar presentations
CSE473 Winter /30/98 State-Space Search Administrative –Reading: Chapter 4 –PS2 on the Web now Last time –problem solving as {graph search, Lisp.
Advertisements

Finding Optimal Solution of 15 puzzle B NTUCSIE Kai-Yung Chiang.
Informed search algorithms
Informed search algorithms
A* Search. 2 Tree search algorithms Basic idea: Exploration of state space by generating successors of already-explored states (a.k.a.~expanding states).
Problem Solving: Informed Search Algorithms Edmondo Trentin, DIISM.
Greedy best-first search Use the heuristic function to rank the nodes Search strategy –Expand node with lowest h-value Greedily trying to find the least-cost.
Heuristics Some further elaborations of the art of heuristics and examples.
Dynamic Programming Nithya Tarek. Dynamic Programming Dynamic programming solves problems by combining the solutions to sub problems. Paradigms: Divide.
Solving Problem by Searching
Dictionaries Last half of Chapter 5. Dictionary A sequence of key-value pairs – Key is usually a string or integer – Value can be any python object There.
A piston moves a distance of 12cm from top to bottom (starts at top) One complete piston movement takes 0.04 seconds. Piston Problem The equation for the.
Artificial Intelligence
Informed Search Strategies Tutorial. Heuristics for 8-puzzle These heuristics were obtained by relaxing constraints … (Explain !!!) h1: The number of.
CS 460 Spring 2011 Lecture 3 Heuristic Search / Local Search.
CSC344: AI for Games Lecture 4: Informed search
State-Space Representation Read Chapter 3. Searches you use MapQuest –road maps Google –documents CiteSeer –research documents.
Heuristics CSE 473 University of Washington. © Daniel S. Weld Topics Agency Problem Spaces SearchKnowledge Representation Planning PerceptionNLPMulti-agentRobotics.
Problem-solving agents
Strings. Sentences in English are implemented as strings in the C language. Computations involving strings are very common. E.g. – Is string_1 the same.
3.0 State Space Representation of Problems 3.1 Graphs 3.2 Formulating Search Problems 3.3 The 8-Puzzle as an example 3.4 State Space Representation using.
1© Manhattan Press (H.K.) Ltd Resonance tube – Measurement of speed of sound in air.
EXAMPLE 1 Writing Factors Members of the art club are learning to do calligraphy. Their first project is to make posters to display their new lettering.
INTRODUÇÃO AOS SISTEMAS INTELIGENTES Prof. Dr. Celso A.A. Kaestner PPGEE-CP / UTFPR Agosto de 2011.
Informed search algorithms Chapter 4. Outline Best-first search Greedy best-first search A * search Heuristics.
Criticizing solutions to Relaxed Models Yields Powerful Admissible Heuristics Sean Doherty Mingxiang Zhu.
State-Space Representation General Problem Solving via simplification Read Chapter 3.
Informed search algorithms Chapter 4. Best-first search Idea: use an evaluation function f(n) for each node –estimate of "desirability"  Expand most.
For Friday Finish reading chapter 4 Homework: –Lisp handout 4.
For Monday Read chapter 4, section 1 No homework..
Advanced Computer Science Lesson 4: Reviewing Loops and Arrays Reading User Input.
Neural Heuristics For Problem Solving: Using ANNs to Develop Heuristics for the 8-Puzzle by Bambridge E. Peterson.
For Wednesday Read chapter 6, sections 1-3 Homework: –Chapter 4, exercise 1.
For Wednesday Read chapter 5, sections 1-4 Homework: –Chapter 3, exercise 23. Then do the exercise again, but use greedy heuristic search instead of A*
4/11/2005EE562 EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS Lecture 4, 4/11/2005 University of Washington, Department of Electrical Engineering Spring 2005.
Feng Zhiyong Tianjin University Fall  Best-first search  Greedy best-first search  A * search  Heuristics  Local search algorithms  Hill-climbing.
Best-first search Idea: use an evaluation function f(n) for each node –estimate of "desirability"  Expand most desirable unexpanded node Implementation:
 How do you represent a number with no value?  Mathematicians defined the “number” 0 (zero)  How do we represent a string with no value?  Use an empty.
Artificial Intelligence Lecture No. 6 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Python Mini-Course University of Oklahoma Department of Psychology Day 3 – Lesson 11 Using strings and sequences 5/02/09 Python Mini-Course: Day 3 – Lesson.
Heuristic Functions. A Heuristic is a function that, when applied to a state, returns a number that is an estimate of the merit of the state, with respect.
September 4, Application problem 1. A guitar has 6 strings. How many strings are there on 6 guitars? Write a multiplication sentence and solve.
Python – May 16 Recap lab Simple string tokenizing Random numbers Tomorrow: –multidimensional array (list of list) –Exceptions.
Ch. 4 – Informed Search Supplemental slides for CSE 327 Prof. Jeff Heflin.
State space search Represented by a four-tuple [N,A,S,GD], where: N is the problem space A is the set of arcs (or links) between nodes. These correspond.
1 A* search Outline In this topic, we will look at the A* search algorithm: –It solves the single-source shortest path problem –Restricted to physical.
Chapter 3 Solving problems by searching. Search We will consider the problem of designing goal-based agents in observable, deterministic, discrete, known.
Lecture 5 of Computer Science II
Main Points: - Working with strings. - Problem Solving.
P8.py.
Piston Problem A piston moves a distance of 12cm from top to bottom (starts at top) One complete piston movement takes 0.04 seconds. The equation for the.
CMPT 120 Topic:  Case Study.
Heuristic Functions.
Heuristic Search A heuristic is a rule for choosing a branch in a state space search that will most likely lead to a problem solution Heuristics are used.
Project 1 Project_1_The_Eight_Puzzle.doc.
Frozen Graphics Lesson 3.
Another problem to solve…
CS 4100 Artificial Intelligence
Heuristics Local Search
Another problem to solve…
Comparing Strings – How to
Heuristics Local Search
4.8 Pivoting Implementing Gaussian Elimination computationally can lead to problems Happens if the element used to create zeros is small relative to other.
Solving absolute value equations visually
Russell and Norvig: Chapter 3, Sections 3.1 – 3.3
Notes Over 1.7 Solving Inequalities
Notes Over 1.7 Solving Inequalities
Another problem to solve…
More on recursion Last time we went through a workshop on recursive functions. Let’s look at some of the problems together.
Informed Search.
Presentation transcript:

P8.py

8 puzzle in python Look at a simple implementation of the eight puzzle in python p8.py Solve using A* Three heuristics: NIL, OOP, MHD

What must we model? A state Goal test Successor function

What must we model? A state Goal test Successor function Represent a state as a string of nine characters E.g.: “1234*5678” Goal test Successor function

What must we model? A state Goal test Successor function String equality Successor function

What must we model? A state Goal test Successor function def successor8(S): """Returns a list of successors of state S""" # index of the blank blank = S.index('*') succs = [] # UP: if blank not on top row, swap it with tile above it if blank > 2: swap = blank - 3 new = S[0:swap]+'*'+S[swap+1:blank]+S[swap]+S[blank+1:] succs.append(('U', new)) ...

Example python> python p8.py 10 Problems using 10 random steps from goal Using No Heuristic (NIL) from *32415678 to *12345678 72 states, 27 successors, 40 goal tests, 0.002507 sec Solution of length 5 Using Out of Place Heuristic (OOP) from *32415678 to *12345678 32 states, 11 successors, 17 goal tests, 0.001228 sec Using Manhattan Distance Heuristic (MHD) from *32415678 to *12345678 48 states, 16 successors, 24 goal tests, 0.002736 sec