MCS 394 Lab 1 (Spring 2000)
Lab 1
MCS 394: Topics in Computer Science
Karl Knight, Spring 2000
Due: Monday, February 28, at the beginning of class
Because of some errors that were noted in my version of the
application, I fixed it so that, if not perfect, it is at least
better. The most important bug in the program I gave you before is
that it didn't appropriately handle the end of a game, which I
repaired. I also dealt with the fact that the human could play even
if it was the computer's turn.
Following are the two versions I am making available to you, with
explanations:
For your convenience, I leave a link to the buggy version here as
well. Not that you should use it
When running the applets, note how I have the applet spill some
information in the TextArea at the bottom (called the outputPanel in
the applet).
When you want to start programming, you should recursively copy
the first directory above to where you want to work. In order to get
you going, I give below a short description of the various files you
will be working with:
- The applet itself:
- The Panels, which are the parts of the applet
- The various Listeners:
- The classes corresponding to the final design of the checkers
learning program illustrated in Figure 1.1 on page 12 of our textbook:
- The Computer player thread:
- And some special-purpose classes:
Let me now explain these various classes in slightly greater detail:
- TicTacToe.java is a
relatively simple class. It is of course the only Applet which sets up
the game. In particular, it sets up its three subpanels (described in
the next grouping of classes), and directly or indirectly instantiates
all of the applications objects, simultaneously setting up
communication links between them.
- These Panels are, from top to bottom, the immediate, visible
subpanels of the TicTacToe applet itself. You should not have to do
much with these.
- These are the ActionListeners and ItemListeners associated
with the Buttons (the board cells and the "Start Game" button) and the
Checkboxes ("Learning On" and Player mode Checkboxes). You should not
have to do much with these, either.
- This is the heart of the application, and are what you should
send most of your time on. I suggest that you check out the instance
variables in these classes as well as there public methods.
There is one major change (actually a simplification) from how I
described these files in class on Monday. Namely, the Evaluator class
I described has now been coalesced with Critic.java, which keeps track of the
feature and weight vectors. In particular, this is where the V
function is calculated.
- There are two instances of this thread in the application, one
corresponding to player X, and the other with player O. Since a
player will only move if both (1) it is enabled and (2) it is the
player's turn, I have used the technology described on pages 625-629
of Concrete Abstractions in the file ComputerPlayerThread.java
in order to have the players wait appropriately.
- Finally, Move.java is a
simple data structure giving the row and column of a move; Board.java is a 2-dimensional array of
strings that keeps track of the current board; and JCRowColLayout.java is a
Layout manager that Mike Hvidsten found which is like a grid, but is
more robust and allows for differently-sized components.