Programming Projects

Main Programming Project

Problem Description

A group of 3 Atheists and 3 TV Evangelists are on their way to a conference discussing the relation between faith and morality. To reach the conference they have to cross a river which is too wide to swim across. Happily there is a boat available, and they can use this to all cross the river. However:

What you have to do

The story above can be used to construct a state-space. Identify the initial state, goal state, and the operations. Then write a program in Java to perform:

What you have to hand in

A copy of your program (which should contain comments explaining what each line of code does), and a copy of a couple of pages of ``traces'' of the program running.

The program should carry out breadth-first search, iterative deepening search, and greedy search based on a heuristic that you make up.

A trace should involve printing either the set of new states added to the agenda each time the program runs the top-level loop, or printing the entire agenda each time the new states have been added.

Hints

The first thing you have to do is to decide how to represent the states within your program. A suitable representation is some form of structure representing what is on each bank of the river. Something like:
left bank:
        number of evangelists
        number of atheists
        number of boats

right bank:
        number of evangelists
        number of atheists
        number of boats
You then have to represent the operations. These are functions which take a state and generate a new one, representing the movement of a boat across the river. Depending on how you write these functions, you may need to check that the operations don't lead to illegal states.

With these components, you should be able to implement the algorithm for breadth-first search given in the lectures. For the agenda you will need to use a stack or a vector (you might be able to get away with an array, but it will need to be a BIG array) which holds a set of states and which allows you to add new states at the start of the array.

If you find that your program is creating a huge array, one problem is likely to be that it keeps generating new copies of the same state. You might want to try removing duplicate states from the agenda.

Once you have the code for breadth-first search, it should be easy to revise the program to do iterative-deepening search, and greedy search.

Make-up Programming Project

Write a program to train a single 3 input TLU.

When the program starts, it should generate a set of random weights for the connections between the 3 inputs and the "threshold input". These weights are output.

The program then prompts the user for a training example; four values that are either 1 or 0. These are the input values and the output value.

The program updates the weights using the error-correction procedure with c taken to be 0.1, prints the new weights and threshold, and then prompts the user for a new training example.

What you have to hand in

As for the main project, you should hand in a copy of your program (which should contain comments explaining what each line of code does), and a copy of a couple of pages of ``traces'' of the program running.

At least one trace should show the program running on the following set of training data:

1 0 0 1
0 1 1 1
0 0 1 0
1 1 0 1
1 0 0 0
1 0 1 0

The last of these values is the output.