This page contains more detailed information about the Connect Four program requirements and interface.

Download the necessary calculator programs in the zip below. The CON4GAME program is the master program, start this program to play the game, the program will prompt you to select Player 1 and Player 2, to select Player 1 and 2's programs, input a number and press enter. The numbers correspond to values found in the CON4PGRM program. Edit this program to configure each value to an input program. By default, the value 0 corresponds to the human input program (CON4HU). You may expand CON4PGRM to support more input programs if you wish to do so. Expanding the program should be self explanatory.

If your AI program is comprised of more than one program, you only need to place the main program into CON4PGRM. After selecting Player 1 and 2, the CON4GAME program will draw the game board and the game will begin. AI programs should begin automatically. When CON4HU is selected as a player, it will provide an interface between a human player and the calculator. The left/right arrow keys move the cursor, and the down arrow key, 2nd, or Enter drops the chip. Player 1's chips are represented as O and Player 2's chips are represented by 0 (zero). The CON4GAME program will automatically detect when the game has ended and display the result of the game. 

Connect_Four_new.zip

Interface

The AI program(s) can use several variables to interface with the master program.

[A] stores the game board as a 6x7 matrix. [A](1, 1) represents the left bottom corner, [A](6, 7) represents the top right corner of the board. The value of the cell represents the contents of the corresponding space on the game board as follows. 0 - Empty, 1- Player 1 has played here, 2 - Player 2 has played here.

Y is the selected position to drop the token. The AI program should set Y to a value between 1 and 7 and then Return or exit. Remember that the AI program is responsible for selecting a valid position. A position that would place a token in a column that is already filled is not a valid position

Z is the number of the current player, either 1 or 2

N is the number of the current turn, starting at 1, up to 42

 

All other variables, except [H] and ∟CON4, are available for use by the AI program. These variables are reserved for the master Connect Four program.

Since all variables may be modified by another AI program or the master program, you are allowed to utilize one (1) named list (ex. ∟AILST) to store information that is carried over from turn to turn.