Solution of Quiz 2 - KFUPM Open Courseware - King Fahd ...
Solution of Quiz 2 - KFUPM Open Courseware - King Fahd ...
Solution of Quiz 2 - KFUPM Open Courseware - King Fahd ...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
_____________________________________________________________________<br />
<strong>King</strong> <strong>Fahd</strong> University <strong>of</strong> Petroleum and Minerals<br />
College <strong>of</strong> Computer Science and Engineering<br />
Information and Computer Science Department<br />
ICS 381: <strong>Quiz</strong> #2-Section 02<br />
Name:<br />
ID Number:<br />
Max. Grade (20 Points)<br />
________________________________________________________________________<br />
Question 1: Let h be an admissible heuristic function. A best-first search algorithm<br />
called Pathmax uses this function as follows. When it adds a new node N’ to the<br />
search tree as a child <strong>of</strong> a node N, instead <strong>of</strong> computing f(N’) = g(N’) + h(N’),<br />
Pathmax computes f(N’) = g(N’) + max{h(N’), h(N) - c(N,N’)}, where c(N,N’) is the<br />
cost <strong>of</strong> the arc from N to N’.<br />
‣ Explain what Pathmax is trying to do. (2 Points)<br />
Answer:<br />
1. Pathmax is trying to build a consistent heuristics out a non-consistent one. Clearly, if<br />
h(N) - c(N, N’) > h(N’) at some node N’, then h(N) - c(N,N’) is a tighter (but still<br />
optimistic) estimate <strong>of</strong> the cost to go from N’ to the goal than h(N’).<br />
Question 2: The A * search algorithm has a major drawback in that it usually runs<br />
out <strong>of</strong> memory before a solution is found. The algorithm called SMA * , or simplified<br />
memory-bounded A * search, is an improvement on A * that tries to solve this. How?<br />
Is it an optimal algorithm? (5 Points)<br />
Idea<br />
Expand the best leaf (just like A* ) until memory is full<br />
When memory is full, drop the worst leaf node (the one with the highest f-value)<br />
to accommodate new node.<br />
• If all leaf nodes have the same f-value, SMA* deletes the oldest worst leaf and<br />
expanding the newest best leaf.<br />
Then, SMA* backs up the value <strong>of</strong> the forgotten node to its parent.<br />
• In this way, the ancestor <strong>of</strong> a forgotten sub-tree knows the quality <strong>of</strong> the<br />
best path in that sub-tree.<br />
• With this info, SMA* regenerate the sub-tree only when all other paths<br />
have been shown to look worst than the path it has forgotten.<br />
______________________________________________________________________________________<br />
Dr. Tarek Helmy ICS 381: <strong>Quiz</strong> #2-Section 02
Question 3: In the “Four-Queens puzzle,” we try to place four queens on a 4x4 chess<br />
board so that none can capture any other. (That is, only one queen can be on any<br />
row, column, or diagonal <strong>of</strong> the array.) Suppose we try to solve this puzzle using the<br />
following problem space: The start node is labeled by an empty 4x4 array; the<br />
successor function creates new 4x4 arrays containing one additional legal placement<br />
<strong>of</strong> a queen anywhere in the array; the goal predicate is satisfied if and only if there<br />
are four queens in the array (legally positioned).<br />
1. Give the 4- Queens Problem Formulation as an CSP (4 Points)<br />
2. Solve the 4-Queens CSP by applying the Backtracking Search using:<br />
Forward Checking and Constrains Propagation features (6 Points)<br />
1<br />
2 3 4<br />
X1<br />
{1,2,3,4}<br />
X2<br />
{1,2,3,4}<br />
1<br />
2<br />
3<br />
4<br />
X3<br />
{1,2,3,4}<br />
X4<br />
{1,2,3,4}<br />
______________________________________________________________________________________<br />
Dr. Tarek Helmy ICS 381: <strong>Quiz</strong> #2-Section 02
Question 5: Game-Playing<br />
If you are programming a game playing algorithm that uses the Minimax procedure and<br />
alpha-beta pruning. So after your computer has done all this pruning, it is fair enough that<br />
now it is your turn and you will do some <strong>of</strong> the alpha-beta pruning yourself. The tree<br />
below indicates the complete Minimax tree for a particular problem (first move by MIN,<br />
then MAX, and then MIN again). The number at each leaf p indicates the value <strong>of</strong> the<br />
static evaluation function e(p) if it were computed at that leaf.<br />
a) Now your job is to check the boxes under those leaves that do not need to be created<br />
and evaluated thanks to the alpha-beta pruning.<br />
b) Which next move (the left or right one) should MIN make, and why?<br />
The left move, because it guarantees MIN a maximum score <strong>of</strong> -2 after 3 moves,<br />
whereas the right move may lead to a worse result.<br />
______________________________________________________________________________________<br />
Dr. Tarek Helmy ICS 381: <strong>Quiz</strong> #2-Section 02