Computer Gammon

by David Hitchens

 

Issue 27

May/Jun 87

Next Article >>

<< Prev Article

 

 

A 1 or 2 player version of the famous board game

BEGINNING THE GAME: The program requires a minimum 24K RAM with 1 or 2 joysticks, has single and two player options and is compatible with both 400/800 and XL/XE machines. XE owners, however, may like to boost the colour saturation control on their TV for best effect.

After typing and saving the listing turn up the TV sound and RUN the program to initialise it. When the title screen appears enter each player's name (followed by the RETURN key), up to nine letters will be accepted. If you wish to play the computer enter ATARI for one of the sides or, for a demo of the program, you can even have the computer play itself by entering its name for both sides!

The blue player uses a joystick plugged into port 1, the green player uses one in port 2. If you only have one joystick and wish to run the two player version change the 'PLR' in line 400 to '0'- both players then use the same joystick plugged into port 1.

Once the board has been displayed press the trigger to begin.

OBJECTIVE: The objective is to remove all your tiles from the board before your opponent and, additionally, to attempt to manoeuvre his pieces to your advantage.

Tiles are moved around the board according to the throw of the dice, obeying certain rules. Blue moves clockwise in ascending fashion; green moves anti-clockwise and descends the pegs. Once all your tiles occupy the appropriately coloured pegs in the last six positions you may begin to move off the board.

RULES: A player cannot move his tile onto a peg which holds more than one of his opponent's pieces, nor can more than five tiles occupy any one peg. A solitary tile is vulnerable to attack and will be displaced onto the bar if hit by an opposing tile. In such a case a player must move his tile(s) back onto the board before any other move can be made - if unable to do so because of existing tile placements he forfeits his turn. No piece may be moved off the board by a player unless all his remaining tiles occupy the colour-coded pegs. Finally, providing moves are possible which do not infringe these rules, both dice must be used each turn - they can, however, be used in either order.

PLAYING THE DICE: The computer decides who will commence the game and throws the dice automatically at each turn. A player then has the option of moving two tiles by the value shown on each die (he could also move the same tile twice) or of moving one tile by the sum of the dice. For example, suppose a 3 and a 5 are thrown at the start of the game. You could move a tile from peg 13 to peg 10 (if you are green) and another from peg 24 to peg 19. You could, alternatively, opt to move a single tile from, say, peg 11 to peg 3 or the same tile from peg 24 to peg 16.

If you receive a double, each die is played twice. For example, a double 5 enables you to move 4 tiles 5 places each or 2 tiles by 10 places. You must, however, treat the dice as pairs - in other words you cannot play the 5 followed by the 10 followed by another 5.

Before returning control to you the computer will check for possible moves. If you cannot move according to the above rules you will be informed of this and play will be pass to your opponent.

MOVING THE CURSOR AND TILES: At the start of a game bring the cursor onto the screen by moving the appropriate joystick to the left. Then move the joystick in the required direction (except diagonally) to select the peg from which you wish to move a tile. Press the trigger to register your selection. If valid the marker below the board will move right asking for a destination for the tile. This you register in the same manner. If the move would be an invalid one both your peg selections are cancelled and you must make new entries. If you decide against a move after inputting a source value simply enter an invalid destination and start again. Your move will then take place with the used die, or dice, reducing in luminosity to highlight remaining choices.

If you are 'on the bar' the computer automatically registers this as the start point and you are only required to enter a destination. For example, with a 3 and a 5 thrown the blue player could enter the board (if valid) via pegs 3 or 5. The green player's corresponding pegs would be 22 or 20. To move off the board (numerically equal to '25' for blue and '0' for green) select the tile then position the cursor until the arrow symbol appears in the 'destination' box. Press the trigger to initiate the move.

During a game, providing you have control of the cursor, you may restart via the title screen by pressing the 'Start' key. Pressing 'Select' or 'Option' returns you to BASIC.

STRATEGY: This is an important feature of the game. You must decide if and when to deposit your opponent onto the bar remembering that he will re-enter via your inner quadrant in most cases. Figure out which are the safe moves to make, when to gamble and how to block your opponent's advances. As you manoeuvre your pieces around the board attempt to deposit your opponent on the bar when safe to do so but reduce his opportunities to re-enter with strategically placed tiles. At the close of the game points are scored according to the number and position of all remaining tiles, greater points being given for those furthest from the opponent's inner quadrant.

WINNER: The winner's performance is evaluated in three ways in order to offer different 'goals' when playing against the computer. Tile advantage is simply the number of your opponent's pieces remaining on the board at the end of a game. Total moves is self-evident - the lower the value the more effective has been your strategy. The score is based on the number and position of remaining tiles; high scores result from keeping your opponent away from his inner quadrant. As is usual with games involving dice, luck does play its part but certainly not to the exclusion of a good strategic approach.

GAME DESIGN

It was decided at the outset to use a character-mapped screen for the board and Antic 4 was chosen since this gives 5 colours at a resolution equivalent to BASIC's mode 7.5. It does, of course, require some effort in redesigning the character set. The number characters were additionally altered for greater prominence but they reside on Gr.0 lines above and below the board itself. DLI's were incorporated to permit multiple use of Players and colour registers. The dice illusion is achieved by overprinting two players with appropriate substrings from DICE$. The cursor is pulsed via a simple VBI but, because it is the same player as used for one of the dice, its position and priority must be adjusted in one of the DLI's. An expanded display results from the use of Players to extend the horizontal boundaries of the board and the inclusion of Graphics 1 and 2 lines below the board which gives prominence to the displayed information.

THE JOYSTICK ROUTINE was then added, positioning this some way in to the BASIC listing in order to give a built-in delay to cursor movement. Any routine positioned near the start of a listing will operate more quickly than if located at the end - hence the positioning of 'frequently used subroutines' in lines 10 to 100 in this game.

TILE MOVEMENT AND GAME CONTROL came next using a simple array to keep track of players' tiles and the program was extensively play-tested before adding m/code subroutines to smooth out movement of the tiles. In order to compact the program a series of variables was incorporated to make one master routine in the main loop operate for both players. Since the green player operates in a numerically descending manner this involved an inversion of blue-player logic.

THE COMMON INTRO/EXIT SCREEN uses a mixed-mode display list with title displayed in Antic 5. Careful choice of foreground colours whilst pulsing the background in a VBI results in good legibility of the standard character set.

COMPUTER LOGIC (for the single player version) was kept fairly simple in order to restrict 'thinking time' but it nevertheless plays fairly intelligently and it isn't a simple matter of achieving high scores. Routines were placed near the start of the program for optimum processing speed, their addition significantly reduced cursor speed as described earlier.

AtariLister - requires Java


top