Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this assignment, you need to implement three functions to complete a Sudoku project, which is a logic-based puzzle game for number placement. The Classic

For this assignment, you need to implement three functions to complete a Sudoku project, which is a logic-based puzzle game for number placement. The Classic Sudoku is a number placing puzzle based on a 9x9 grid with several given numbers. The object is to place the numbers 1 to 9 in the empty squares so that each row, each column and each 3x3 box contains the same number only once.

According to the constraint satisfaction problem (CSP), the definitions of these three functions are as follows:

3) void CSP::arcConsistency(const State state); - Attention: for this function, you need to modify a data member variables[9][9] in the CSP class.

This function has a stronger constraint than the udpateDomain() function. Again, you need to update the domains of the variables[9][9] data member, according to the current state. As talked in the class, you can follow the pseducode to update the domains of the unassigned variables based on the tail and head principle of an arrow.

Two important variables:

Variable variables[9][9];

State cur_state;

Both of the two variables are the data members of the CSP class. But only the first variable (variables[9][9]) needs to be updated inside your implemented functions. For the second variable (cur_state), you do not need to update its value but just read it. Actually you do not need to read this variable directly, as it is given to you as the input parameter of your function - const State state. So you just need to read the information from state variable. They are the same.

(1) variable[9][9] - each variable represents a cell of the sudoku table. For example, variable[0][5] is the cell in the first row and the 6th column. The structure Variable" definition is in the header file CSP.h. It has two data members: domain and assignment. domain is a vector representing the possible values can be assigned for this variable. So it has at most nigh numbers. assignment is an integer, which presents the current assignment for this cell. The value can be any integer between 1 and 9. If it is 0, it means the current variable has not been assigned yet. In your implemented functions, you should update the domains of these unassigned variables.

(2) cur_state - its structure is also defined in the CSP.h file. It only has one data member values[9][9] which has a similar meaning as the assignment data member of the above variables[9][9]. For example, values[2][3] represents the assignment of the cell in the third row and the fourth column of the sudoku table. It can be any integer between 1 and 9. Again, if it is 0, it means the cell has not been assigned yet.

(Hint: if you want to check whether a cell (ith row, jth column) has been assigned yet, you can use any of the three ways: cur_state.value[i-1][j-1] == 0, or variables[i-1][j-1].assignment == 0, or the function input parameter state.value[i -1][j-1] == 0)

#include

#include "CSP.h"

/************************************** Below are the three functions you need to implement ***************************************/

/*Check whether current state satisfy the constraints*/ bool CSP::goalCheck(const State state) {

return false; }

/*Update Domain for the forward checking*/ void CSP::updateDomain(const State state) { }

/*Arc consistency use*/ void CSP::arcConsistency(const State state) {

}

/************************************************ End of Assignment ***********************************************/

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

Students also viewed these Databases questions

Question

Question Can a Keogh plan fund be reached by the owners creditors?

Answered: 1 week ago

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago