Docsity

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

Toggle sidebar
bg1
CMSC 421 Programming Assignment 1
Due Date: Part A: In class Tuesday, September 27
Part B: 6PM Friday, September 30
For this problem, you will apply search to solve Su Doku puzzles.
Su Doku
In this puzzle, you start with an initial partially filled in n×ngame board. A simple 4 ×4
example is given below:
12
421
41
23
12
421
41
23
At each step in the game, you can fill in the empty positions with a number from 1 to n. A
solution to the puzzle is a fully filled in game board in which each number from 1 to nappears
exactly once in each row, column and blo ck. The blocks for a 4 ×4 board and a 9 ×9 board are
shown in bold as below:
A solution to the simple 4 ×4 example is given below:
1234
4321
3412
2143
1234
4321
3412
2143
The difficulty of these puzzles varies greatly depending on the initial board. In some cases, a
relatively straight-forward depth first search may work satisfactorily. In other cases, backtracking
will be required.
Your Assignment
Su Doku can be solved in a number of ways – some options include using uninformed search,
heuristic search, local search and constraint satisafaction.
The first part of your assignment, Part A, involves writing pseudo-code for a basic backtracking
search algorithm to solve this constraint satisfaction problem for a 4x4 board. Your solution
pf3

Partial preview of the text

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

CMSC 421 Programming Assignment 1

Due Date: Part A: In class Tuesday, September 27 Part B: 6PM Friday, September 30

For this problem, you will apply search to solve Su Doku puzzles.

Su Doku

In this puzzle, you start with an initial partially filled in n × n game board. A simple 4 × 4 example is given below:

2 1

1 2 4

1 4

3 2

2 1

1 2 4

1 4

3 2

At each step in the game, you can fill in the empty positions with a number from 1 to n. A solution to the puzzle is a fully filled in game board in which each number from 1 to n appears exactly once in each row, column and block. The blocks for a 4 × 4 board and a 9 × 9 board are shown in bold as below:

A solution to the simple 4 × 4 example is given below:

4 3 2 1

1 2 3 4

2 1 4 3

3 4 1 2

4 3 2 1

1 2 3 4

2 1 4 3

3 4 1 2

The difficulty of these puzzles varies greatly depending on the initial board. In some cases, a relatively straight-forward depth first search may work satisfactorily. In other cases, backtracking will be required.

Your Assignment

Su Doku can be solved in a number of ways – some options include using uninformed search, heuristic search, local search and constraint satisafaction.

The first part of your assignment, Part A, involves writing pseudo-code for a basic backtracking search algorithm to solve this constraint satisfaction problem for a 4x4 board. Your solution

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

should be about a page long, and should include details about how you will encode and maintain the current assignment as you search and possibly backtrack. You should do this part of the assignment as soon as possible, before you start coding!

The second part, Part B, of your assignment involves writing a C/C++ program to solve this puzzle. We have provided a simple shell for a program which reads in and writes out a Su Doku game board. Your job is to fill in the innards. You may use whatever search algorithm you like, but beware that naive search algorithms may not be able to solve the harder puzzles.

Code Infrastructure

Code and infrastructure for the course is available from /afs/csic.umd.edu/class/cmsc421/0101/common For this assignment, a simple shell of a C program which reads in and outputs a board is pro- vided. Copy the source code from /afs/csic.umd.edu/class/cmsc421/0101/common/pa1/src and use the provided Makefile with make to compile the program.

Sample input and output files are available in /afs/csic.umd.edu/class/cmsc421/0101/common/pa1/input /afs/csic.umd.edu/class/cmsc421/0101/common/pa1/output. Your code will be tested on other inputs, so it is probably a good idea to try some others. You should check for incorrect input.

Evaluation

  1. [25 points] The psuedo-code for the two different algorithms.
  2. [50 points] Your Su Doku program
  3. [25 points] A 1 page write-up describing your Su Doku code development.

Deliverables

To receive full credit, you must 1) Turn in Part A your psuedo-code writeup in class on Tuesday, September 26. 2) You must turn in your program as explained in below 3) Submit a 1 page writeup with your program, describing the search approach you used, any other approaches you tried, and successes or failures you had along the way. 2) and 3) comprise Part B and are both due at 6PM on Friday, September 30.

Submission Guidelines for Part B

Please remember that your code must work on the class linuxlab system. Please double-check this before turning in your submission.

To submit electronically, execute the following command: /afs/csic.umd.edu/submit/fall2005/cmsc421/bin/submit 1 project1.tar project1.tar is a tar file explained below. project1.tar should be in your current directory.

Note that you will see a message saying that your submission is successful after submitting your tar file. In case of multiple submissions for the same assignment, only the last submission will be saved. The previous ones are overwritten. (Note: use electronic submission only for programming assignments. Homework assignments should be submitted in class or physical copies should be given to the TA or Professor.)