Let's Connect! (Easy version)
This is the easy version of Connect4Bot. The only difference between this and the hard version is the strength of play required to defeat the grader. Solving one version does not guarantee solving the other.
This is an interactive problem.
Implement the class Connect4Bot, which plays the game Connect 4 with the goal of winning. Connect 4 (or Connect Four) is a classic two-player strategy game where players drop colored discs into a vertical grid, aiming to be the first to get four of their own color in a row (horizontally, vertically, or diagonally) before their opponent does.
For this problem, a heuristic approach should suffice — however, a simple solution that only looks one move ahead may be insufficient. Your bot should ideally be able to set up multi-move attacks such as creating or preventing positions where the opponent cannot block all threats.
The interactor is adaptive, meaning the judge will adjust its strategy in response to your bot's behavior.
Methods
move(board)
boardis the current state of the game board as a subscriptable 2-dimensional container. This board is guaranteed to be in size.boardis accessible with as a custom typeBoardwhich is guaranteed to be subscriptable. You should be using this typeBoardrather than a default container likestd::vector.board's columns are labeled0-6from left to right, and rows are labeled0-6from bottom to top.- Each
board[i][j]has an integer value. This value is either0,1, or2.0indicates an empty square at rowiand columnj.1indicates your bot's piece at rowiand columnj.2indicates the judge's bot's piece at rowiand columnj.
- The function should return an integer between and , inclusive, indicating the column in which your bot chooses to drop its disc.
Notes
You do not need to implement any input/output parsing.
Your submission will be evaluated against our reference bot. It plays at approximately the same strength level expected from your Connect 4 bot, but is intentionally slightly nerfed.
RUNNING TESTS... EVALUATING YOUR BOT IN A BEST OF 5