Up: CopyCat Table of Contents
Left Left: 3 Educational Value Up Right Right: 5 What's new?

4 Programming

The program CopyCat is relatively small -- under 2000 lines of code; the class files are under 40K. This makes it an attractive program for the net. Its small size is due to the concise language of mathematics. Another reason is that java is also a very concise language.

The program

(For the following to make sense, it is important to be familiar with CopyCat)

CopyCat is made up of many components: PlayArea, BoardBox, Rotator, and Title. PlayArea (PlayArea.java) is the component where all the action occurs. It has a complex interface to handle all the players' manipulations of the solid object. PlayArea reports back to CopyCat (CopyCat.java) whenever the player does something significant.

BoardBox (BoardBox.java) is the part that shows the static original picture that the player must copy (I call it a board)--not much to it.

Rotator (Rotator.java) has the solid object rotating and bouncing in a non-repeating way. There is also a user interface where the player can grab the object and rotate it manually, but as soon as the player lets go, it returns to tumbling.

Title (Title.java) is a trival component that simply puts centred text in a box. It is used for the title and the score.

PlayArea and BoardBox rely on the object Board (Board.java). Board holds all the information of the board and has a few methods that relate to the board -- drawing the board, clearing the board, and counting the correct matches on the board.

PlayArea,Rotator and Board rely on the object Solid (Solid.java). Solid holds all the 3D information relating to the solid object and has a few methods as well.

PlayArea and Board rely on the object GroupGraph (GroupGraph.java). GroupGraph holds all the preferred orientation of the solid, how to get from one oriention to another, and the symmetries of the faces the of solid.

PlayArea, Rotator and Solid use the object Omatrix (Omatrix.java), the orthogonal/orientation matrices. Omatrix holds a matrix and has many matrix methods.


The config files

One of the most flexible parts to CopyCat is that it has very little hardwiring; all of the changeable information is read in with files: which object that is used, which group graph that is used, the screen setup, and the board. This saves oodles of time compiling, and will eventually lead to user interface where the user will run some application that produces these config files. A half measure that is implemented right now is that the board status can be retrieved from the System.out--this is a hidden feature so that non-techies won't get too excited.

the files


home Contents Help!