Skip to content

Semester 1: PSWP Lab Project. A simulation of "Connect Four" by Hasbro using Python 3.

Notifications You must be signed in to change notification settings

ashishkulkarnii/connect4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Connect4

The Objective

The board consists of a vertically mounted grid with 6 rows and 7 columns. Two players take turns dropping coins in each column. The objective of the game is for a player to drop his or her coins such that they create a row, column or diagonal of 4 coins.

Declaring a Winner

When a player gets four coins in a row (horizontally, vertically, or diagonally), the game logic registers the player as the winner of the game.

The Board

The game board is represented by a two-dimensional matrix of 6 rows and 7 columns. Each empty space is represented by ‘0’, and the spaces taken by a player are represented by their respective characters.

Dropping a Coin

In real life, the board is a vertically mounted grid. So, in order to simulate the effects of gravity, a coin when dropped into a particular column falls to the lowest unoccupied space. In case the column already has 6 coins, the function governing the ‘drop coin’ action asks for a different column number from the user.

You can try our code by installing all the files into the same folder and running main.py in the terminal.

About

Semester 1: PSWP Lab Project. A simulation of "Connect Four" by Hasbro using Python 3.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages