Solution for Assignment 1 - Artificial Intelligence | COSC 6368, Assignments of Computer Science

Material Type: Assignment; Class: Artificial Intelligence; Subject: (Computer Science); University: University of Houston; Term: Spring 2009;

Typology: Assignments

Pre 2010

Uploaded on 08/18/2009

koofers-user-15a
koofers-user-15a 🇺🇸

10 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Solution for Assignment 1 – COSC 6368 – Artificial Intelligence Spring 2009
Problem 1:
A state in this problem can be defined as (X, Y)
X: water present in the 4 liter jug {0, 1, 2, 3, 4};
Y: water present in the 3 liter jug {0, 1, 2, 3};
Initial state and goal states:
INITIAL: (0, 0)
GOAL: (2, 0); (2, 1); (2, 2); (2, 3)
The possible operations:
1. The jug can be filled with water from the tap.
2. The jug can be drained.
3. Water can be poured from one to another jug.
Operator rules:
OPR1: If X < 4, fill X: (X, Y) (4, Y)
This operator is applied to fill the 4 liter jug completely with water. This applies only
when the 4 liter jug is not completely filled.
OPR2: If Y < 3, fill Y: (X, Y) (X, 3)
This operator is applied to fill the 3 liter jug completely with water. This applies only
when the 3 liter jug is not full with water.
OPR3: If X > 0, empty X: (X, Y) (0, Y)
This operator is applied to drain water from the 4 liter jug completely. This applies only
when the 4 liter jug has some water in it.
OPR4: If Y > 0, empty Y: (X, Y) (X, 0)
This operator is applied to drain water from the 3 liter jug completely. This applies only
when the 3 liter jug has some water in it.
OPR5: If (X+Y) >= 4 and Y > 0
This operator is applied to fill the 4 liter jug from the 3 liter jug
(X, Y) (4, Y – (4 – X))
pf3
pf4
pf5

Partial preview of the text

Download Solution for Assignment 1 - Artificial Intelligence | COSC 6368 and more Assignments Computer Science in PDF only on Docsity!

Solution for Assignment 1 – COSC 6368 – Artificial Intelligence Spring 2009 Problem 1: A state in this problem can be defined as (X, Y) X: water present in the 4 liter jug {0, 1, 2, 3, 4}; Y: water present in the 3 liter jug {0, 1, 2, 3}; Initial state and goal states: INITIAL: (0, 0) GOAL: (2, 0); (2, 1); (2, 2); (2, 3) The possible operations:

  1. The jug can be filled with water from the tap.
  2. The jug can be drained.
  3. Water can be poured from one to another jug. Operator rules:  OPR1: If X < 4, fill X: (X, Y)  (4, Y) This operator is applied to fill the 4 liter jug completely with water. This applies only when the 4 liter jug is not completely filled.  OPR2: If Y < 3, fill Y: (X, Y)  (X, 3) This operator is applied to fill the 3 liter jug completely with water. This applies only when the 3 liter jug is not full with water.  OPR3: If X > 0, empty X: (X, Y)  (0, Y) This operator is applied to drain water from the 4 liter jug completely. This applies only when the 4 liter jug has some water in it.  OPR4: If Y > 0, empty Y: (X, Y)  (X, 0) This operator is applied to drain water from the 3 liter jug completely. This applies only when the 3 liter jug has some water in it.  OPR5: If (X+Y) >= 4 and Y > 0 This operator is applied to fill the 4 liter jug from the 3 liter jug (X, Y)  (4, Y – (4 – X))

This applies only when the amount of water in both the jugs is greater than or equal to 4 liters.  OPR6: If (X+Y) >= 3 and X > 0 This operator is applied to fill the 3 liter jug from the 4 liter jug (X, Y)  (X – (3 – Y), 3)) This applies only when the amount of water in both the jugs is greater than or equal to 3 liters.  OPR7: If (X+Y) <= 4 and Y > 0 This operator is applied to empty water from the 3 liter jug into the 4 liter jug (X, Y)  (X+Y), 0) This operator can be applied only when the amount of water in both the jugs is less than or equal to 4 liters and the amount of water in the 3 liter jug is greater than zero  OPR8: If (X+Y) <= 3 and X > 0 This operator is applied to drain water from the 4 liter jug into the 3 liter jug. This operator can be applied only when the amount of water in both the jugs is less than or equal to 3 liters and the amount of water in the 4 liter jug is greater than zero. (X, Y)  (0, X + Y) Example for path to the GOAL: (0,0)  (0, 3)  (3, 0)  (3, 3)  (4, 2)  (0, 2) (2, 0) (0, 0)  (4, 0)  (1, 3)  (1, 0)  (0, 1)  (4, 1)  (2, 3) Problem 2: Answer:

  1. A* (f = g + h) a. Reached goal state: G b. Expanded states in order: S, A, C, D, D Derivations: Expanded State OPEN Status CLOSE Status OPEN ( S ) CLOSE () S OPEN ( A(8) , B(15)) CLOSE (S) A OPEN ( C(7) , D(11), B(15)) CLOSE (S, A) C OPEN ( D(10) , B(15), S (16), D(11)) CLOSE (S, A, C) D OPEN (G1(15), B(15), S(16), D(11), CLOSE (S, A, C, D)

Give reasons for your answer! b. Backtracking only memorizes states that are on the currently explored path. What are the advantages of this approach? What are the disadvantages of this approach? Be specific! Answer: a. Yes! Because: there are finite numbers of states and the algorithm check duplicate in currently exploring. b. Advantages :

  1. It requires low memory and;
  2. Faster: because it doesn’t waste time for already visited states. Disadvantages: Backtracking has to perform redundant work (it expands the already visited states multiple times); if the algorithm encounters a state that has lead to a dead-end again using a different path it is the unsuccessful search. Problem 5: Propose a state-evaluation function for the King Rook vs. King Endgame. Explain your state evaluation function! Answer: We have a black KING (bKING) and black ROCK (bROCK) fight again a white KING (wKING). Distance between bKING and wKING: DIS(bKING, wKING) Distance between bROCK and wKING: DIS(wKING, bROCK) Distance between bROCK and bKING: DIS(bROCK, bKING) The evaluation function can be given as: F = DIS(bKING, wKING) + DIS(wKING, bROCK) + DIS(bROCK, bKING) Problem 6: a) What assumption does the minimax search strategy make about the moves that the opposing player selects? b) In real world games, such as checkers, it is usually not feasible to generate the entire search space. What approach is typically chosen by game playing programs to cope with this problem? c) What is the main difference between minmax search and alpha-beta search? d) Why does search in game playing programs always proceed forward from the current position rather than backward from the goal? Answer: a. The assumption is both player plays optimally to the end of game.

At each step it assumes that player B is trying to maximize the chances of B winning while on the next turn player A is trying to minimize the chances of B winning.(i.e. to maximize A’s own chances of winning). b. The approaches to cope with the problem that we can not generate the entire search space are: Cut off Search (Pruning) Limit the depth of the search tree as we do not have time to explore all the nodes and we assume that the test succeeds for all the nodes at or below depth d. Evaluation Function Return an estimate of the expected utility of the game and it should be the one which accurately reflects the chances of winning the game. c. Main difference between minimax and alpha-beta search is: Using pruning (Cut off search tree) alpha-beta can compute the correct minimax decision. d. Because if we proceed backward from the goal we can not reach to the current state.