Docsity

Programming Assignment 2 - Introduction to Artificial Intelligence | CMSC 421, Assignments of Computer Science

Toggle sidebar
bg1
CMSC 421 Programming Assignment 2
Due Date: Thursday, October 17, 5PM
For this programming assignment, you will be modifying a backtracking imple-
mentation of Sudoku to solve the Sudoku puzzle more efficiently.
Sudoku
In this game, your goal is to fill a 4x4, 6x6 or 9x9 grid such that each value in a
column, row and block has a different value from other entries in the same row,
column and block. Each cell in the grid can be filled with a digit from 1 to n
(where n is the size of an nxn board).
You can gain some intuition on how to solve this problem by checking:
http://www.websudoku.com
Algorithm
You will solve the Sudoku puzzle as a constraint satisfaction problem (CSP).
You will need to implement Minimum Remaining Values (MRV) heuristic, Least
Constraining Value (LCV) heuristic and Forward Checking. Backtracking has
been already implemented. Your goal is to modify this code to find the solution
as efficiently as possible.
Code Infrastructure
Copy the code from http://www.cs.umd.edu/class/fall2006/cmsc421/projects/pa2.tar
to your directory. Read the documentation in the file thoroughly. A couple of
notes on the code:
1. Backtracking is implemented in the function (backtracking sudoku mcv
lcv fc ac) where:
(a) sudoku - a list representation of a sudoku board (Test cases are in-
cluded).
(b) mcv - if mcv = t, do Minimum Remaining Values (MRV)
(c) lcv - if lcv = t, do Least Constraining Value (LCV)
(d) fc - if fc = t, do Forward Checking
(e) ac - if ac = t, do Arc Consistency
2. You will need to compile the code in order to get results for this assignment
in a timely manner (ie: ”:cl sudoku-csp.lisp”)
3. You should be able to run all the provided test cases in under a minute.
4. You are free to modify the underlying infrastructure in order to improve
run time. Document changes in your write up.
pf3

Partial preview of the text

Download Programming Assignment 2 - Introduction to Artificial Intelligence | CMSC 421 and more Assignments Computer Science in PDF only on Docsity!

CMSC 421 Programming Assignment 2

Due Date: Thursday, October 17, 5PM

For this programming assignment, you will be modifying a backtracking imple- mentation of Sudoku to solve the Sudoku puzzle more efficiently.

Sudoku

In this game, your goal is to fill a 4x4, 6x6 or 9x9 grid such that each value in a column, row and block has a different value from other entries in the same row, column and block. Each cell in the grid can be filled with a digit from 1 to n (where n is the size of an nxn board).

You can gain some intuition on how to solve this problem by checking: http://www.websudoku.com

Algorithm

You will solve the Sudoku puzzle as a constraint satisfaction problem (CSP). You will need to implement Minimum Remaining Values (MRV) heuristic, Least Constraining Value (LCV) heuristic and Forward Checking. Backtracking has been already implemented. Your goal is to modify this code to find the solution as efficiently as possible.

Code Infrastructure

Copy the code from http://www.cs.umd.edu/class/fall2006/cmsc421/projects/pa2.tar to your directory. Read the documentation in the file thoroughly. A couple of notes on the code:

  1. Backtracking is implemented in the function (backtracking sudoku mcv lcv fc ac) where:

(a) sudoku - a list representation of a sudoku board (Test cases are in- cluded). (b) mcv - if mcv = t, do Minimum Remaining Values (MRV) (c) lcv - if lcv = t, do Least Constraining Value (LCV) (d) fc - if fc = t, do Forward Checking (e) ac - if ac = t, do Arc Consistency

  1. You will need to compile the code in order to get results for this assignment in a timely manner (ie: ”:cl sudoku-csp.lisp”)
  2. You should be able to run all the provided test cases in under a minute.
  3. You are free to modify the underlying infrastructure in order to improve run time. Document changes in your write up.

Programming Assignment 2: CMSC 421, Introduction to Artificial Intelligence: Fall 2006 2

Implementation and Discussion

  1. [30 points] Implementation Implement the following functions to solve the CSP:

(a) [10 points] Modify the current implementation to support Forward Checking. (b) [10 points] Implement the Minimum Remaining Values (MRV) heuris- tic. (See Russell and Norvig p. 143) (c) [10 points] Implement the Least Constraining Value (LCV) heuris- tic. (See Russell and Norvig p. 144)

Make sure that your code is well commented and readable. Also, make sure to remove all the debugging statements before submitting.

  1. [70 points] Results and Discussion Run your code on test cases test4, test6, test7, test8 and test9. You may present results from additional test cases if it helps in your discussion. Find the number of times an assignment is made (i.e.: Number of times a value is set on the board during backtracking) and time (i.e.: (time (back- tracking test4 t nil nil nil))). Discuss and compare how these statistics change/improve as you use:

(a) Only Backtracking (b) Backtracking with MRV (c) Backtracking with LCV (d) Backtracking with forward checking (e) Backtracking with MRV and LCV (f) Backtracking with MRV, LCV and forward checking

(Note: The write up will be graded for presentation, as well as correctness. Presentation of your results in tables is highly encouraged. You may also sum- marize your results by providing statistics, such as calculating the average, in addition to presenting full results.)

Extra Credit

  1. [15 points] Implement Arc Consistency. Note: You must submit the code and discussion to get full credit.

Deliverables

The deliverables of this project is a single tar file, your-glue-id.tar, containing the following files.