
CS440: Introduction to Artificial Intelligence
Fall 2008
Programming Assignment #3: Clue as a Bayesian Net
Due Thursday, Dec. 11th, at noon.
Introduction
In the previous programming assignment, you wrote a resolution theorem prover for the child’s
game of Clue. But of course, Clue is a game; everything is either true or false. In real life, there is
uncertainty. So in this assignment we will use the game of Clue as a domain, but this time the
goal is to infer the probability of an even given a set of evidence. The method of inference should
be variable elimination over a (small) Bayesian net.
The Problem
In the game of Clue, there are three explicit random variables: Person (Mustard, Scarlett, Plum,
Green, White, Peacock), Weapon (Wrench, Candlestick, Rope, Knife, Revolver, Pipe), and Room
(Hall, Lounge, Dining, Kitchen, Ballroom, Conservatory, Billiard, Library, Study). Looking at
crime statistics (well, pretending to) we have also determined that we need three implicit random
variables: Gender (M, F), Cook (T, F) and Military(T, F). The motivation for the additional
variables is as follows: women stereotypically prefer certain types of weapons (e.g. knives), while
men prefer others (e.g. revolvers, pipes and wrenches). Cooks are more likely to be in the kitchen
and to have access to knives. (From her outfit, we infer that Mrs. White is more likely than the
others to be a cook, although academics also tend to like to cook, so Prof. Plum is slightly more
likely to be a cook than the others.) Current and former members of the military are trained to use
guns. (Note that we don’t know if Col. Mustard was in the military or if his moniker is just an
affect, but we will infer that it is more likely.) The Bayesian net that relates these six variables is
given in Figure 1, below. The conditional probability tables are also given below.
Your job is to write a program that takes in evidence and a query variable assignment, and prints
out the probability of the query variable assignment given the evidence. The evidence consists of
assignments for any subset of variables (including the empty set and the full set). The query
variable assignment is the target that you are calculating the probability of. For example, you
might get the following input:
Cook = F
Weapon = Knife
Query = Room = Library
Your program should then print out probability that the murder was committed in the library,
given that the murderer was a cook and the murder weapon was a knife.
Input
Your program should take the name of an input file as its only argument. The file will be an input
file. The last line of the file will contain a query variable. Any preceding lines will contain
evidence variables. An evidence variable line will be of the form “Variable = Value”, as in the
example above. Note that the variable names, equal signs and values are separated by a space,
and that there is only one variable per line. The values for Gender are M and F. The values for