This is a test project. This readme will be updated with various notes and progress markers as I go through, including a to-do list and project outline.
Connect Four is played on a 7x6 board. This program will take player and computer input, visually represent the game board in console output, track the moves, and identify wins.
To begin the program, run ConnectFour.java.
- Board size is set initially, but this program can support any size board. The formatting is weird with even-width columns, but that's an artifact of blocks the size of letters.
- Level 1/2: Human/AI selector for P1 and P2 (the player will be a controller and its input will come from the command line or from a decision engine of some kind); in this case, we will also initialize first player selection
- Boss: Difficulty selector for each AI that governs whether it plays randomly except to win or block or plays with an advanced (look-ahead) strategy.
- Checks for threats across the whole board.
- If a win is possible, play to win.
- If a win-block is possible, play to block.
- If neither win nor win-block are available, play randomly.
- Build the threat detection and reaction system such that its thresholds can be altered and the AI can play more aggressively.
- Takes console input and passes to board.
- Displays message to player if the requested move is invalid.
- Checks return value from board and passes play to the other player (0), displays tie message (1), or displays win (2) or loss (3) message.
- Model is an int[rows][columns], where -1 means empty and 0 or 1 is player ID.
- Takes column from player or move from AI.
- Checks the column's validity (it must be a real column, the coordinate BoardSquare(c, r) must be empty).
- Returns value to player, triggering message.
- Finds the lowest open row in the given column.
- Displays the board by iterating through the matrix and printing output to the console.
- Otherwise returns (0) to the player.
- Fixed formatting for 10+ columns.
- Keeps track of current turn.
- Checks for a win or tie. If the game is over, returns tie (-1) or win (player ID + 1) to the player. Otherwise returns 0 and the game continues.
- Calls player action (listener for human, decision method for AI).
- Model is an ArrayList of BoardMoves. BoardMoves contain a a date and time (java.util.Date), a player ID (0 or 1), and a BoardSquare<c, r>.
- Model is two ints (r, c).
- Methods to get row and column.
- The game checks win conditions and displays the current board
- The player controller displays any applicable message
- The player or AI generates a move and submits it to the board object
- The board object checks the validity of the move and rejects (GOTO 3) or accepts the move
- The board logs the move as coordinates + player + timestamp.
- The board updates the model. GOTO 1.