Click Here To Go To The Your Computer Archive



Written By Martin Roberts


Cover Art
Click Here To Enlarge Loading Screen

Loading Screen
Click Here To Enlarge Opening Screen

Opening Screen
Click Here To Enlarge Screenshot

Game Screenshot

Four In A Row

Martin Roberts, Dewsbury, West Yorkshire

Four In A Row is exactly the same as the popular Connect Four game. The game can be played either against the computer or against another human being. The rules are very simple.

The game is played - in this case - on a 9 by 8 board. The player makes his move by dropping coloured disks down the board. The disk always falls to the bottom of each column. The next player then makes his move by dropping a different coloured disk.

The winner is the player who gets four of his disks in a row. The row can be either horizontal, vertical or diagonal. In computer play mode, the user is asked which level of difficulty he would like to play at. The levels are from 1 to 5. In level 1 the computer will only play defensively and so does not play avery good game. In level 5 however the computer will provide a challenge to most players. The speed of play varies with difficulty. The computer can take up to 40 seconds to make a move in difficulty factor 5.

A detailed description of the workings of the program would be beyond the scope of this article but there is a brief description of what each section of the program does.

Lines Operation
30 to 70 initialisation of variables and characters
160 to 200 instructions
310 to 390 initialisation of arrays
460 to 550 main loop of program
610 to 720 check for win
890 to 900 program data
920 to 1970 computer move section

Briefly the computer move making section operates as follows. The computer scans each column from left to right and calculates the numbers of disks in a straight line which would result in going in that column. Different values are assigned to each number in the row. So two in a row might be worth 10 points whereas three in a row might be worth 30 points - four in a row is of course given the maximum of 13,000 points as this wins the game.

Things do not stop there though, the computer must then calculate the values for stopping the opponent from going in that particular column. This is done in the same way but these values are negative since they are defensive.

But what about the position above? This must also be considered or there would be danger of letting the opponent in i.e. there would be no point in going in a column which lead to three in a row if the position above lead to your opponent getting his four in a row. So the position above is also examined in the way previously described.

When the computer has finished calculating the values it then simply scans all the columns to find the one with the highest value. This is the computers move. Readers may like to experiment with the computers play by changing the data in lines 890-900.