Program listing on 48K Spectrum.
1 PAPER 6: CLS : DIM t(62): READ n,p,g: FOR a=1 TO 6: FOR b=1 TO 6: PRINT AT 20,b*3;CHR$ (64+b);AT a*3-1,21;a; PAPER t(a*7+b); FLASH t(a*7+b)=8;AT a*3-1,b*3;" ";AT a*3,b*3;" ": NEXT b: NEXT a: POKE g*n,37: FOR i=9 TO 46: FOR j=1 TO 4: LET d=j+4*(j>1): POKE (t(i)=0)*n,21: LET s=t(i-d)*t(i)*t(i+d)*t(i+d+d): FOR l=i-d TO (i+d+d)*(s=1 OR s=16) STEP d: LET g=1: LET t(l)=8: NEXT l: NEXT j: NEXT i: POKE g*n,5: BORDER p: INPUT ': LET k=PEEK 23556: LET h=7*(k-48)*(k>48)*(k<55)+(k-64)*(k>64)*(k<71): POKE (h=0)*n,25: PRINT #0;"MOVE: ";CHR$ k: BEEP .1,0: LET d=1+6*(h<7): FOR l=h+d TO h+d*5 STEP d: LET t(l)=t(l+d): NEXT l: LET t(l)=p: LET p=3-p: POKE n,5: BORDER 6: BEEP .1,12: BEEP .1,24: DATA 23620,1,0
Download the game
Conexão PvP is a two player game, with player one playing blue, and player two playing red. To play the game, wait until the BORDER colour changes to your colour, which indicates the computer is ready to accept your move. Select either a row or a column to place a token on the game board by pressing any of the keys 1-6 or a-f respectively. On making a selection, the computer will BEEP, and the selection will appear in the bottom left-hand portion of the screen. When you make a move, either the selected row is shifted left (or if a column was selected, it is shifted upwards) by one position, and your token will be placed on the rightmost postion of the selected row (or bottom position of column, if a column was selected). Play alternates between two players until the end of the game. There are no invalid moves, as all rows and columns are permanently available to both players. The game ends when one or more four-in-a-row lines of consecutive tokens all belonging to the same player are found, in which case the BORDER will turn yellow, and the found rows will FLASH. Diagonal rows are permitted. If a single four-in-a-row is found at the end of the game, then the player who owns the row wins the game. If more than one four-in-a-row is found, and all of the rows are owned by the same player, then again, that player wins the game. However if multple four-in-a-rows are found and both players own at least one of the rows, then the game is drawn.
On the technical side, Einar developed the algorithm to search for four-in-a-rows on the game board, and the routine to print the board is dervied also based on his compact method originally made for the one-liner othello PvP game. Einar also made many optimisations, and improvements to this one-liner program. A hugely important one was a speed optimisation that made the board scanning a lot faster, particularly at the beginning of a new game.
Back to Sinclair stuff index