
| GUI Principles | ||
|
The game AtomiX was written originally as part of the coursework for the GUI course at Reading University. To address this the game aims to have a simple, yet intuitive user interface. The user interface uses the standard controls of most modern Windows inspired applications - and is made up with buttons, check boxes, radio options and combo boxes. The buttons are for confirming a selection - either to Start a Game, Play a New Game or About. The check boxes are for enabling or disabling features of the game, such as Smart AI on the computers intelligence model or Show Places to toggle whether the squares the player can move to are highlighted or not. The radio options are used to switch between game modes - either two player or four player. And, the combo boxes are used to select a player type - either human or computer. To aid the user, all controls used in the game cause the mouse pointer to change to a ponting hand, The layout of the controls aims to be as simple as possible, by placing the combo boxes for the player types underneath the radio buttons used for deciding on the number of players, should make it obvious what the combo boxes are for. The actual combo boxes for the different players visibility state is toggled depending on the number of players. In two player mode, only two combo boxes are displayed - one for each player. If four player mode is then selected, an extra two combo boxes are made visible. When switching back to two player mode, these two combo boxes are then hidden. In the game its left, the game grid is made up from a series of layered images - the background layer is the playing grid - which is made out of an image for the background and a grid which is overlaid onto this image showing where all the squares in the game are. Ontop of this is the highlight layer - which is the optional layer, and is used to highlight the different squares in the game where the players can make their moves. Then there is the top layer which contains the actual atoms. These are each individually depicted by a series of images - different images for the number of atoms displayed (1, 2 or 3) and in different colours for the four different players. Whilst the game is being played, there is the added status line at the base of the game area (underneath the players scores), informing the player as to whose go it is and when the game is concluded. All of the check boxes, combo boxes and radio options keep their selected settings throughout the use of the game and do not reset so players can easily use the same settings for subsequent games. The game as default, returns to the main front screen 5 seconds after the game ends. By dividing the game into these two distinct areas - the front screen where options are selected and the actual game screen helps to stop the game from feeling cluttered with these two distinctive areas and makes it clear as to what each part is for. | ||
| AI Models... | ||
|
The computer AI is modeled in two ways, there is the first dumb mode where the computer simply assigns a points score to each square where the player is allowed to move to and simply moves to the square with the highest score. Although there is some randomness added into this system to prevent the other players from being able to predict where the computer will move - often an alternative square is randomly slected instead. The basic method to the algorithm is:
Although the above pseudocode does not include how and where the randomness is added in - as this would give away how this part of the game operates and perhaps spoil the fun. The second intelligence mode is Smart AI. This uses the dumb mode as described above, but each points addition (such as the + 100 for each piece on the square) is multiplied by a weighting factor which is an assessment of how important the square is to the player. This is calculated by prediciting the result of moving to that square, and the number of squares that the player gains from moving to that square. This means that any moves which have a cascading effect around the board are given a high weighting, moves to single squares where there currently are no atoms gain a middleish weighting and moves to squares where there currently are atoms no additional weighing unless it does cause this cascade effect around the board. | ||
| Classes and Methods used... | ||
|
This game uses four different classes. These are: game which is the main class behind the game and includes all the code for the GUI, AI and trhe game board logic. Timer which is a timer thread used to create the clock. InterestedParty an interface between the game and timer (as explained below...) And, Point which is used to store the coordinates of the squares on the board. The main game class contains all the methods for the game itself. This class is an expansion of the Applet base class. This uses a custom layout manager to create the forms and its own internal handlers for the mouse events - such as movement and clicking. The next class, Timer goes together with InterestedParty, which is a basic interface class for cross-manipulation between a thread and the applet which spawned the thread. This InterestedParty class was developed at Ision Internet by Chris Saltmarsh and Sam Hill as part of the Um Automation. Basically, this provides a hook between the thread for the timer and the applet, allowing the thread to invoke methods in the applet itself and to interface with objects contained within the applet (such as the label used to display the time. The timer itself is a thread which sleeps for a second, invokes the method and then returns to sleep for another second and so on... Finally the point class is a simple class for an point object which can store x, y and z coordinates as a sinlge object so you can use point.x, point.y and point.z. This object can also be directly stored in Vectors and HashTables making it very easy and flexable to use and store x,y,z coordinates. Although the z coordinate is not used in this game. | ||
| Back... | ||