Classic Computer Magazine Archive ANTIC VOL. 6, NO. 3 / JULY 1987

Game of the Month

Red, White and Blue

More devilish than Rubik's Cube?

BY HEIDI BRUMBAUGH, ANTIC EDITORIAL ASSISTANT

Celebrate July Fourth by trying to beat your Atari at the challenging logic game of Red, White and Blue. It's a kind of solitaire Othello, with no less thun 30 skill levels. So go ahead and put "Stars and Stripes Forever" on your stereo, turn up the volume as loud as you can stand it, light up your sparklers, firecrackers and Piccolo Petes-- making sure to observe the local fire safety codes, of course--and get ready to play Red, White and Blue, the first publication of a Game of the Month written by an employee ofAntic Publishing. This BASIC program works on all 8-bit Atari computers of any memory size, with disk or cassette.

You win the game of Red, White and Blue by converting all the squares from red to blue. To change the color of a square, you just move onto it. The problem is--you can't move onto a square that is adready blue.

To play Red White and Blue, type in Listing 1, RWB.BAS, check it with TYPO II and SAVE a copy before you RUN it.

At the start of the game, all the squares except the one you occupy are white. This means their true colors are hidden. The only way to discover a square's true color is to try moving onto it.

Use your joystick to move up, down, right or left. The color of the new square you have chosen is displayed. If the square is red you will move onto it at once, changing it to blue. However, if the square is already blue the computer will beep, indicating that you cannot move into it.

The red and blue squares are arranged randomly at the beginning of a new game, so you get a different pattern every time you play.

The reason the game can be so hard to win is that once you make a move, you can't go back the way you came. This makes it easy for you to get surrounded by blue squares and blocked from any further moves.

FLIP THE BOARD

But there's a way to escape. You can "flip" the entire board by pressing your joystick button. At once, all the squares that were previously blue will be red--and vice versa. The only square that doesn't change color is the one you occupy. It always remains blue.

After you flip the board, you will be free to continue moving about the grid with your joystick, trying to forge a path that allows you to change all the red squares to blue without getting trapped again. But even with the help of repeated flipping, some boards will be impossible to solve.

Skill level is determined by the size of the grid. At the opening screen, move your joystick up or down to change the skill level, then press the joystick button to start playing.

There's not much challenge to a low skill level--a 2x2 or 3x3 grid. It will either be very easy to win or immediately obvious that the board is impossible to solve. However, this is a good place to start if you want to get an idea of how the game works. The highest skill level is limited only by the number of squares that can fit on your video screen. As written, the program's maximum is eight squares. But you can shrink the square size to squeeze more into the grid. Do this by decreasing the value of LSQR in line 11000 to 3 (or even 1) or change MODE 7+16 to get a higher resolution.

For a super-challenging grid size of 32 x32 use MODE 7+16 and a LSQR of 1. However, game speed will slow considerably at this point.

If you get stuck, quit a game and randomize the squares for a new game by pressing the [ESC] key. Or do the same thing by pressing the joystick forward and giving a light tap to the trigger button. Then use the joystick to confirm that you want to quit and tap the trigger once again. (Antic is fulfilling the request of a March 1987 I/O letter. For the convenience of physically handicapped players, all commands in this game can be given with the joystick.)

ABOUT THE PROGRAM

I originally wrote this game for the IBM PC as a way of better understanding MicroSoft BASIC's logical operators. Commands such as AND, OR and XOR (eXclusive OR) made it very simple to flip a square's value back and forth without using any math. Ironically, when I translated the program into Atari BASIC I had to change the data structure completely to account for that language's sometimes limited syntax.

The values of the squares are held in a two-dimensional array (STAT(X,Y)). If a square is blue (already captured) it has a value of 1. If it is red, its value is 0. To "hide" the squares at the beginning of the game, simply add 10 to that value.

This way, it is easy to see that the integer value of a hidden square (10 or 11) will be 1 if it divided by 10 (see line 5030). If it is not hidden, you "flip" the square by taking the absolute value of STAT(X,Y) subtracted by 1, as in line 5050. (ABS(1-1)=0; ABS(0 - 1) = 1.)

In the original PC version of the program, the four possible square values-- 0, 1, 10 and 11--were given in binary(0, 1, 2 and 3), to make it easier for the computer to perform its logical operations. The Atari version uses decimal instead, to make it easier on the programmer.

PROGRAM TAKE-APART

Lines 100-499 use subroutines for initialization and opening menus.
500-999 puts the often-use subroutine to draw a square at the beginning to save processing time
1000-1999 is the main routine. It reads joystick value, makes sure the user doesn't want to quit and checks for win after each turn.
2000-2999 makes sure the move is within the grid. The updated position is held in temporary variables during a checkup that the user isn't trying to move into a blue square.
3000-3999 paints the new square color, moves the place marker and updates the STAT(X,Y) values if the move is valid. If not, the compputer beeps and saves the old values.
5000-5499 flips the board. We save time by redrawing the board as we flip the squares.
6000-6999 draws the gameboard.
7000-7999 is the opening menu.
10000-10999 randomizes for new game.
11000-11999 initializes.

Heidi Brumbaugh joined the Antic editorial department a year after graduating from Grinnell College, Iowa where she majored in Russian language. After taking a few programming courses, she became a fixture in the computer center until they felt so sorry for her they gave her a job as a user consultant. We promised Heidi we'd publish this first submission (originally titled Pathfinder) as the July Game of the Month if she let us change the title--and the game colors--to a suitable patriotic Red, White and Blue.

Listing: RWB.BAS Download