Connect four is a unique structured game that works almost like a Tic Tac Toe game. Player have to connect FOUR consecutive Dots to win. If all the dots are filled it is a draw. It is a little complex game than TIC TAC TOE in terms of codding as it requires more definitions and conditions to win. It requires to check for the win condition with each move and with each moved position on the board.
This function was designed to create the game board where the players would play the game. Each iteration will call the gameboard() function and it will present throughout. The game board looks like this:
The board will look something like this.
This function will check if the box where player wants to move is empty or is already occupied. It will send a signal if it is valid to move there.
This function will move the current player's sign(X, O) in one of the columns given by the Player. First turn is X's turn by default, it would look something like this-
After implying few MOVES the Board will look something like this-
This Function will check of the board is full or not. If the board is full, the game will result in Draw otherwise next move is played.
This function will check the condition for four consecutive same signs(X, O). If X are present in consecutive order in four of the below ways-
- Linear / Horizontal
- Vertical
- Left Diagnal
- Right Diagnal Then X Wins.
Similarly Player O can win.








