You are a robot assigned to place three Knights on a 3 x 3 chess board such that (1) all Knights do not attack each other, (2) only one Knight is placed in each row, and (3) only one Knight is placed in each column. Recall that a knight attacks in an “L” pattern, i.e., a knight moves two spaces rectilinearly and then one space at right angles to the initial movement.
For the benefit of students who do not play chess, the following boards illustrate the allowed cells (marked as O) and prohibited cells (marked as X) after you place a knight (marked as K) at a cell. Once a knight is placed at a cell marked as K, any other knight may be placed only in a cell marked as O, and may not be placed in a cell marked as X. Only symmetry-collapsed positions are shown below. All other constraint positions may be obtained by symmetry reflections and rotations.
row 3
K
X
X
row 3
X
O
X
row 3
O
X
O
row 2
X
O
X
row 2
K
X
X
row 2
X
K
X
row 1
X
X
O
row 1
X
O
X
row 1
O
X
O
col
C1
col
C2
col
C3
col
C1
col
C2
col
C3
col
C1
col
C2
col
C3
You decide to formulate this task as a CSP in which columns are the variables (named C1 through C3) and rows are the domain values (named 1, 2, and 3). After you have solved the CSP, each column (variable) will be assigned a row (value), and all constraints will be satisfied. The columns (variables) are C1-C3:
• C1, col 1 - will be assigned the row number of the knight in column 1
• C2, col 2 - will be assigned the row number of the knight in column 2
• C3, col 3 - will be assigned the row number of the knight in column 3
The rows (domain values) are the digits 1-3:
1, the knight in that column is in row 1
2, the knight in that column is in row 2
3, the knight in that column is in row 3
There are no unitary constraints, and so the initial variable domains include all possible values:
D1 = {1, 2, 3} D2 = {1, 2, 3} D3 = {1, 2, 3}
First of all think all CSP constraints as explicit relations of all allowed pairs of variable values: Implement constraint graph associated with your CSP and then Run arc consistency also comment on your results.
Comments
Leave a comment