Adversarial Search - P2
Adversarial Search - P2
Adversarial Search - P2
Sometimes a problem is not embedded in a long set of action sequences but requires picking the
best option from available choices. A good general-purpose problem solving technique is to list
the constraints of a situation (either negative constraints, like limitations, or positive elements
that you want in the final solution). Then pick the choice that satisfies most of the constraints.
Formally speaking, a constraint satisfaction problem (or CSP) is defined by a set of variables,
X1;X2; : : : ;Xn, and a set of constraints, C1;C2; : : : ;Cm. Each variable Xi has a nonempty domain
Di of possible values. Each constraint Ci involves some subset of t variables and specifies the
allowable combinations of values for that subset. A state of the problem is defined by an
assignment of values to some or all of the variables, {Xi = vi;Xj =vj ; : : :} An assignment that does
not violate any constraints is called a consistent or legal assignment. A complete assignment is
one in which every variable is mentioned, and a solution to a CSP is a complete assignment that
satisfies all the constraints. Some CSPs also require a solution that maximizes an objective
function.
CSP can be given an incremental formulation as a standard search problem as follows:
1. Initial state: the empty assignment fg, in which all variables are unassigned.
2. Successor function: a value can be assigned to any unassigned variable, provided that it
does not conflict with previously assigned variables.
3. Goal test: the current assignment is complete.
4. Path cost: a constant cost for every step
Many troubles in AI can be regarded as problems of constraint satisfaction, where the goal state
pleases a specified set of constraint.
!
Caution Constraint satisfaction problems can be solved by means of any of the search
approaches.
The common form of the constraint satisfaction procedure is as follows: Until a
whole solution is located or until all paths have led to lead ends, do
1. Choose an unexpanded node of the search graph.
2. Apply the constraint inference rules to the chosen node to generate all possible new
constraints.
3. If the set of constraints encloses a contradiction, then report that this path is a dead end.
4. If the set of constraints illustrates a total solution then report success.
5. If neither a constraint nor a complete solution has been located then apply the rules to
produce new partial solutions. Insert these partial solutions into the search graph.
After Step 1 we derive are more conclusion that Y contradiction should generate a Carry. That is
D+2>9
D > 6 (Controduction)
After Step 2, we found that C1 cannot be Zero, Since Y has to a carry to satisfy goal state. From
this step onwards, no need to branch for C1 = 0.
Step – 3
We have assigned digit to every letter in accordance with the constraints and production rules.
Now by backtracking, we find the different digits assigned to different letters and hence reach
the solution state.
Solution State:
Y=2
D=7
S=9
R=8
N=6
E=5
O=0
M=1
C1 = 1
C2 = 0
C3 = 0
C3(0) C2(1) C1(1)
S(9) E(5) N(6) D(7)
+ M(1) O(0) R(8) E(5)
M(1) O(0) N(6) E(5) Y(2)
After the Step 1, w see that the initial guess is not correct. Because all the guesses following that
have been checked, which has lead to the contradiction. Thus we move to second step with the
change in the initial guess.
Step – 2
At Step (2) we have allocated a single digit to every letter in accordance with the constraints and
production rules.
Now by backtracking, we discover the different digits allocated to dissimilar letters and therefore
reach the solution state.
Solution State:
C=9
N=8
G=7
A=5
O=2
E=4
D=1
R=6
S =3
C1 = 0
C2 = 0
C3 = 0
C4 = 0
C4(0) C3 C2(0) C1(0)
C9 R(6) O(2) S(3) S(3)
+ R6 O(2) A(5) D(1) S(3) D(1)
A(5) N(8) G(7) E(4) R(6)
Example: The map coloring problem.
The task of coloring each region red, green or blue in such a way that no
neighboring regions have the same color.
We are given the task of coloring each region red, green, or blue in such a way that the
neighboring regions must not have the same color.
To formulate this as CSP, we define the variable to be the regions: WA, NT, Q, NSW,
V, SA, and
T. The domain of each variable is the set {red, green, blue}. The constraints require
neighboring regions to have distinct colors: for example, the allowable combinations
for WA and NT are the pairs
{(red,green),(red,blue),(green,red),(green,blue),(blue,red),(blue,green)}. (The
constraint can also be represented as the inequality WA ≠ NT). There are many
possible solutions, such as {WA = red, NT = green, Q = red, NSW = green, V = red,
SA = blue, T = red}.Map of Australia showing each of its states and territories
1. Initial state : the empty assignment {},in which all variables are
unassigned.
2. Successor function: a value can be assigned to any unassigned variable,
provided that it does not conflict with previously assigned variables.
3. Goal test: the current assignment is complete.
4. Path cost: a constant cost(E.g.,1) for every step.