Comp 210 Lab 10: Missionaries and Cannibals


Link to Homework 9

This lab will be spent working on and discussing possible solutions to the Missionaries and Cannibals problem. You will be working in groups of two, so pick a partner right away.

  1. General discussion of the problem (5 minutes)
  2. Try Exercise 32.2.1
    1. Work in groups of 2 (10 minutes)
    2. Discuss different solutions (15 minutes)
  3. Try Exercise 32.2.2 -- no hard coded values!
    1. Work in groups of 2 (15 minutes)
    2. Discuss different solutions (15 minutes)
  4. Try Exercise 32.2.3
    1. Work in groups of 2 on the first part of the exercise only. (15 minutes)
    2. Discuss different solutions (15 minutes)
  5. Try Exercise 32.2.4 -- if there's time
    1. Work in groups of 2 on the first part of the exercise only.
    2. Discuss different solutions

General hints:

     ; build-list : natnum (natnum -> alpha) -> list-of-alpha
     ; (build-list n f) = (list (f 0) ... (f (sub1 n)))


                    MMMCCCb--
                    /     \
                   /       \
                  /         \
                 v           v
            MMMC--CCb     MMCC--MCb
             /     \        /   \
            /       \      /     \
           /         \    /       \
          v           v  v         v
       MMMCCCb--    MMMCCb--C    MMMCCCb--

There are two main ways of searching a set of states like this: depth-first and breadth-first. In depth-first search, we explore one move from the initial state, then one move from that, and so on until we get stuck. Then we back up and try another move and so on. Note that in depth-first search, we need some way to remember what states we have already visited, or else we may end up repeating states forever and never find a solution. In breadth-first search, we try all possible moves from the initial state, then all moves from them, and so on. With breadth-first search, we are certain to find a solution, if one exists, even without remembering the previously visited states. By the way, in the case of the Missionaries and Cannibals, there exits a solution in eleven moves, and this is the shortest that is possible.