Connect 4 (Connections) - D.R. Tose (Your Spectrum-Issue 6-Page 77) Here's a game that's full of fun and frustration. Based on a popular board game, the idea is pretty similar to Noughts and Crosses - only this time you've got to line up four tokens in a row! On-screen you'll be presented with a grid made up of circles on the left side and instructions for play at the bottom. The grid comprises six rows of seven columns each, with an arrow character poised at the top of one of the columns. To release one of your pieces into the column, press the '0' key and it will fall to the lowest free position. If the arrow isn't pointing to the column in which you want to make your move, the arrow can be re-positioned using any key other than the '0' key. The game is played against the computer and the choice as to who plays first is decided at random by the program. When you've made your move, a message is flashed up on-screen announcing that the computer's thinking - always a good idea if nothing much is happening for a few seconds. The computer will then make its move and it's up to you again. The way to win is to place your pieces so that you achieve four in a row - either horizontally, vertically or diagonally. Of course your computerised opponent is using the same tactics as you, so watch out. There are two levels of difficulty - 'easy' and 'hard' (and when it says 'hard', it's not joking!). Each time a move is made, the 'number of moves' counter is incremented and displayed on-screen -just in case you'd like to know how many moves it has taken you to beat the Speccy (assuming, of course, that you do). Full instructions are provided at the beginning of each game, and when you've reached the final conclusion you'll be offered another game. Lines 5-9 Print the title page, complete with instructions for play. Lines 10-20 Select the level required and print the details of the control keys used. Lines 30-50 Set up the user-defined graphics for the tokens. Line8 55-70 Print the game board, minus the counters. Lines 75-90 Set up the user-defined graphics to position the arrow character. Lines 100-130 Set up the 'initial variables' array - a(9,8) - that will hold the state of play. Lines 135-140 Decide whether you or the computer will be first to start the game. Lines 150-200 Print the arrow at the top of one of the columns and set the PAPER colour to cyan. Lines 180-190 check if the board is full - if it is, then the game is said to be drawn. Lines 205-270 Make the player's move and increment the 'number of moves' counter. The keyboard is scanned for a key press, and the arrow character is moved accordingly. If the '0' key is pressed, a piece is placed in the grid and the routine is exited. Once the move has been made, the board is checked for a win. Lines 275-290 Make the computer's move and increment the 'number of moves' counter. Lines 295-510 The score for each possible move is calculated in lines 280-430, and the best score is recorded in line 490. If level two is selected, then line 480 calls the score routine again with different parameters to find your best reply and subtracts this score from its own. The score is calculated by adding up how many counters would be in a row by placing its piece in each column. The score is then incremented by 5^z (lines 340, 370, 400 and 430) where z holds the number in a row'. (This means that four tokens in a row - 5^4 = 625 - is a better score than four rows of three tokens - 4 x 5^3 = 500.) Lines 520-570 If no move can be made by the computer and hs (highest score) has not been changed, then the game is drawn. lf zz is set to equal 625, the computer announces that it has won. Lines 575-620 Print the token on the grid and alter the array so that the move is recorded on-screen. Lines 625-650 Contain the routine that displays the message if the player wins and offers another chance to play. Lines 655-660 Contain the routine controlling what happens if the game is drawn. Line 9990 The 'cassette save' routine. Lines 9998-9999 Contain the 'Microdrive save' routine. Omit these lines if you don't have an Interface 1 unit connected. ------------------------------------------------------------------------------ TYPE: Boardgame COMMENT: This info file was typed by Jim Grimwood Downloaded from: Desert Island Disks -- http://www.image.dk/~frankie/ Maintained by: Michael Bruhn -- frankie@image.dk