Crossword Puzzle Solver Michael Keefe. Solver structure.

Slides:



Advertisements
Similar presentations
Recursion.
Advertisements

Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Backward Checking Search BT, BM, BJ, CBJ. An example problem Colour each of the 5 nodes, such that if they are adjacent, they take different colours 12.
Maintaining Arc Consistency We have a constraint graph G of variables X 1,...X n, and constraint relations {X i  X j}, and each Xi has a value set V (X.
1 Constraint Satisfaction Problems A Quick Overview (based on AIMA book slides)
1 Constraint Satisfaction Problems. 2 Intro Example: 8-Queens Generate-and-test: 8 8 combinations.
1 Finite Constraint Domains. 2 u Constraint satisfaction problems (CSP) u A backtracking solver u Node and arc consistency u Bounds consistency u Generalized.
The Singleton Pattern II Recursive Linked Structures.
Artificial Intelligence Constraint satisfaction problems Fall 2008 professor: Luigi Ceccaroni.
Chapter 3 DATA: TYPES, CLASSES, AND OBJECTS. Chapter 3 Data Abstraction Abstract data types allow you to work with data without concern for how the data.
Stacks CS-240 Dick Steflik. Stacks Last In, First Out operation - LIFO As items are added they are chronologically ordered, items are removed in reverse.
CS Oct 2006 Chap 6. Functions General form; type Name ( parameters ) { … return value ; }
CS1110: Computer Science I Chapter 5 Arrays. One-dimensional Arrays int [] data = new int [4]; data[0] = 1; data[1] = 3; data[2] = 5; data[3] = 7; Arrays.
Building Java Programs Binary Search Trees reading: 17.3 – 17.4.
1 Week 4 Questions / Concerns Comments about Lab1 What’s due: Lab1 check off this week (see schedule) Homework #3 due Wednesday (Define grammar for your.
Artificial Intelligence CS482, CS682, MW 1 – 2:15, SEM 201, MS 227 Prerequisites: 302, 365 Instructor: Sushil Louis,
CSC 205 Programming II Lecture 18 The Eight Queens Problem.
ليست هاي پيوندي Linked Lists ساختمان داده ها و الگوريتم ها.
Sudoku Jordi Cortadella Department of Computer Science.
Artificial Intelligence CS482, CS682, MW 1 – 2:15, SEM 201, MS 227 Prerequisites: 302, 365 Instructor: Sushil Louis,
CS 100Lecture 131 Announcements Exam stats P3 due on Thursday.
1 The Stack Class Final Review Fall 2005 CS 101 Aaron Bloomfield.
Object-Oriented Programming Simple Stack Implementation.
Chapter 5 Constraint Satisfaction Problems
Exercise 2 Introduction to C# CIS Create a class called Employee that contains the following private instance variables: Social Securitystring.
More loops while and do-while. Recall the for loop in general for (initialization; boolean_expression; update) { }
Maintaining Arc Consistency (MAC) MAC is the same as Back-tracking, but with calls to AC-3 interleaved... function Backtracking-Search(csp) returns.
An Introduction to Artificial Intelligence Lecture 5: Constraint Satisfaction Problems Ramin Halavati In which we see how treating.
private void Application_Launching(object sender, LaunchingEventArgs e) { } private void Application_Activated(object.
A: A: double “4” A: “34” 4.
Introduction to Collections. Collections Collections provide a way of organizing related data in a model Different types of collections have different.
Contest Algorithms January 2016 Pseudo-code for backtracking search, and three examples (all subsets, permutations, and 8- queens). 4. Backtracking 1Contest.
Chapter 5 : Methods Part 2. Returning a Value from a Method  Data can be passed into a method by way of the parameter variables. Data may also be returned.
1 Reference Variables Chapter 8 Page Reference Variables Safer version of C/C++ pointer. "Refers to" a variable. Like a pointer. Effectively.
Class Method Read class Student { private: string id; string firstName, lastName; float gpa; public: // Will the method change any data members? // Yes!
CS 171: Intro to AI Discussion Week 2 Jan 15 th 2016.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
Symbolic Execution in Software Engineering By Xusheng Xiao Xi Ge Dayoung Lee Towards Partial fulfillment for Course 707.
Midterm 2 Review Notes on the CS 5 midterm Take-home exam due by 5:00 pm Sunday evening (11/14) Hand in your solutions under the door of my office, Olin.
CSE 143 read: 12.5 Lecture 18: recursive backtracking.
EQUATION IN TWO VARIABLES:
Doubly Linked List Review - We are writing this code
Data Structures and Algorithms
Algorithm Design and Analysis (ADA)
Recursion.
CS B551: Elements of Artificial Intelligence
Stacks Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
© המרכז להוראת המדעים האוניברסיטה העברית בירושלים
null, true, and false are also reserved.
البرمجة بلغة الفيجول بيسك ستوديو
Cs212: Data Structures Computer Science Department Lab 7: Stacks.
String Methods: length substring
searching Concept: Linear search Binary search
Chapter 9 One-Dimensional Arrays
Unit 3 - The while Loop - Extending the Vic class - Examples
Chapter 3: Finite Constraint Domains
UML Class Example Sales - name: string - monthlyProfit : double[] public class Sales{ private String name; private double[] monthlyProfit; public.
Java Lesson 36 Mr. Kalmes.
Running example The 4-houses puzzle:
Constraint Satisfaction Problems
Michael Ernst CSE 140 University of Washington
Constraints and Search
Binary Search Trees Chapter 9 2/24/2019 B.Ramamurthy.
slides created by Alyssa Harding
C++ Pointers and Strings
Constraint Satisfaction Problems. A Quick Overview
Algorithms: Design and Analysis
Object-Oriented Programming and class Design
Building Java Programs
C++ Pointers and Strings
Presentation transcript:

Crossword Puzzle Solver Michael Keefe

Solver structure

UI structure

Let Q be a copy of puzzle constraints Let arc be a binary constraint Let xi,xj,xk be Variables with domains initialized to all words that fit void AC3(Puzzle p) { While Q not empty Remove an arc (xi xj) from Q; If arc-reduce(xi, xj) then If the domain of xi is empty return failure; else Add to Q all arcs (xk xi), with k different than i and j, that are in the CS-Problem; return success; } ARC Reduction and backtracking

Arc reduce private static bool arcReduce(Puzzle p, Variable xi, Variable xj) bool change = false; var c = getConstraint(p, xi, xj); string word = string.Empty; // if the constraint was inverted var swapped = c.CellA.Variable != xi; var y = swapped ? c.CellA.Index - 1 : c.CellB.Index - 1; var x = swapped ? c.CellB.Index - 1 : c.CellA.Index - 1; //For each value u in the domain of xi for (int i = xi.Domain.Count - 1; i >= 0; i--) { bool exists = false; word = xi.Domain[i]; exists = xj.Domain.Any(w => w[y] == word[x]); if (!exists) //If there is no such v, remove u from the domain of xi & set Change to true; xi.Domain.RemoveAt(i); change = true; } return change; }