OTHELLO GAMES CODED IN 1 LINE! Both of the below games fit within a single line of ZX-BASIC code. They also fit within the single screen limit so that none of the listings scroll when LIST-ed on a 48K spectrum. To run the games, type 'r' (i.e. RUN) after the game has loaded. Click on either of the below links for relevant game documentation. Both games were developed by Einar Saukas, Dr BEEP and Digital Prawn in 2007, based on a previous Othello game developed by Einar Saukas and Eduardo Ito back in 1989. Othello Othello PvP Othello In-game screen. Program listing on 48K Spectrum. Key showing in-game features (labels refer to single player mode). Text Listing 1 DIM t(91): INPUT "1-2?";f: READ n,t(41),t(42),t(50),t(51),t(1),z,p: DATA 23620,2,1,1,2,3,2,2: LET p=3-p: LET q=z>1: DIM c(3): FOR a=1 TO 8: FOR b=1 TO 8: LET k=t(a*9+b+1): PRINT AT 9,b;b;AT a,0;a;AT a,b; PAPER k+p*p*(a*9+b+1=z);" ": LET c(k+1)=c(k+1)+1: NEXT b: NEXT a: PRINT ''c(2);"x";c(3),: IF c(1)*c(p+1) THEN BORDER p: POKE (f^ULC9876fedcka4,ph;1:bg5!"(i)-32+(a*9+b)*(a*b>0)*(b<9): BEEP .01,i: FOR j=0 TO 9*(t(z)=0)-1: LET d=j+INT (j/3)*6-10: LET w=z+d: POKE (t(w)<>3-p)*n,32: LET w=w+d: POKE (t(w)<>p)*n,26: LET w=w-d: LET t(w)=p: POKE (w<>z)*n,29: NEXT j: POKE n,4+15*(2*(i*q<62)-(z>1=i))*(t(z)*j=0): NEXT i About the game This one-liner implements the popular board game Othello with support for matches between 2 human players or against the computer. The number of human players is selected by answering the initial INPUT prompt 1-2? During the course of the game, the players alternate turns to place a piece onto an empty square on the board, with the human player always moving first. The most recent move taken by either player is highlighted in a lighter colour than usual, so it is easy to stay aware of the last move made. Human player is blue (last move appears in cyan), CPU (or second player) is red (last move appears in magenta). How to play At your turn, you must select an empty square to place a piece onto by inputting a pair of numbers for ROW and COLUMN respectively. A move is valid if your placed piece is immediately adjacent to a contiguous block of one or more opponent's pieces, with another one of your pieces already situated at the other end of a straight line, so that two of your pieces "bridge over" the opponent pieces. On taking your move, all of the opponent's pieces that you have "bridged over" will flip over, changing into your colour. However, if your selected move is invalid (i.e. no pieces could be flipped), then you will be returned to the INPUT prompt, so you can try again another move without wasting your turn. If there are no valid moves available for you to play, simply enter your move as 0 (for both ROW and COLUMN) to request a PASS. In this case, the computer will scan the board to confirm that you really don't have any valid move before accepting your PASS. However, if you attempt a PASS when there are still valid moves available, then the computer will interpret it as a request for HELP, and choose the best move it can find on your behalf. The match is finished when one of the following end game conditions is met:- (1) A player has had all of his pieces eliminated from the board (he loses the game); (2) The board is completely full (the player with the highest number of pieces on the board at this point wins the game); or (3) Neither player has a valid move remaining (again, highest number of pieces wins). Technical Details The design of this game features some very clever concepts from Einar Saukas. The CPU AI is compressed down to a single string of 60 characters length, which lists the desired positions to hold on the board, in order of decreasing tactical importance. This seems at first sight to be quite simple, but in fact has proven able to beat the AI of all three other Othello games (two of them commercial releases) tested against it. Another clever part is the algorithm to both validate and execute player moves, which was whittled down into a compact sequence of logical tests and conditional jumps, aided by the fact that the underlying board data structure is a folded one-dimensional numeric array. Credits Einar had this idea to implement an OTHELLO game in a one-liner, as he had previously developed an Othello game along with Eduardo Ito back in 1989 (published by ZX-SOFT Brasil Ltda). Einar was responsible for the top-level design of the game (explained above), and jointly implemented and optimized it along with Dr BEEP and Digital Prawn. Othello PvP In-game screen. Program listing on 48K Spectrum. Text Listing 1 DIM t(91): READ n,t(41),t(42),t(50),t(51),t(9),t(83),z,p,q: POKE n+73,32: CLS : DIM c(3): FOR a=1 TO 8: FOR b=1 TO 8: LET k=t(a*9+b+1): PRINT AT 18,b+b;b;AT a+a,0;a;AT a+a,b+b; PAPER k+p*p*(a*9+b+1=z);" ": BEEP (k>0)/20,k*9: LET c(k+1)=c(k+1)+1: NEXT b: NEXT a: PRINT '''c(2);"x";c(3),: BORDER 4: IF c(1)*c(p+1)*(q-z) THEN BORDER p: LET q=z: INPUT a,b: LET v=(a*b>0)*(a<9)*(b<9): FOR i=7 TO 72: LET z=i+INT (i/8)+2+(a*9+b-8)*v: FOR j=0 TO 9*(t(z)=0)-1: LET d=j+INT (j/3)*6-10: LET w=z+d: POKE (t(w)<>3-p)*n,33: LET w=w+d: POKE (t(w)<>p)*n,26: POKE n-v*n,19: LET w=w-d: LET t(w)=p: POKE (w<>z)*n,30: NEXT j: POKE n,36-(1+16*v)*(t(z)*j=0): NEXT i: LET p=3-p: POKE n,5: DATA 23620,2,1,1,2,3,3,1,1,0 About the game The game is based on the first Othello game in this package. It is recommended that you check that game out first, since its documentation provides playing instructions and detailed background information. This game differs from the above in that it only supports PvP ("Player versus Player") mode. Removing the "CPU AI" (thus disabling single player mode) freed up enough space within the one-liner limits to allow additional features unique to this version: a bigger game board, refusal of invalid attempts to PASS (instead of playing on player's behalf in such case), added in-game sound, and a few other small changes from the original game.