logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

The project is an assignment that has to be completed in groups of 3 persons maximum

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

 

The project is an assignment that has to be completed in groups of 3 persons maximum (the persons have to be in the same lab group). This project will test your ability to use Python in a more concrete and complex setting than what you were used to during the tutorials/lab sessions. Also, it will improve your ability to work as a team when having a project to complete. The goal of the project is to program the game Connect4 in Python (the pop out version), with a simple user interface and game display, and where a human can play against either a human or a computer player.

Very Important!!! Please follow the instructions below. Projects that will not strictly follow  these instructions will risk getting big grade penalty.

 

       The Python script to execute the program must be in your project repertory and named exactly connect4.py (no uppercase letter). For submission of your project on NTU Learn, please create a zip archive from your project repertory, name the archive according to your matric number (i.e. <YourMatricNumber>.zip), and upload it on NTU Learn. If two or three people are in your group, simply separate the matric numbers with an underscore character.

       The submission system automatically closes exactly at the deadline. Hence, after that,  if  you  didn’t submit, you will get 0 point for your project. You can update your submission as many times as you want on NTU Learn, only the last submission will be taken into account. Thus, I advise you to submit an earlier version much before the deadline, to be sure you won’t end up with no submission at all.

       Only one person of your group submits the project on NTU Learn. Do not submit the same project for all your group members.

       Make sure your project works properly (i.e.  the program doesn’t output errors).   If errors are output during the test of a functionality of your project, this functionality will be considered as not working at all.

       Do not copy any code (or part of) from other groups, from implementations available online, from previous years, or from any code that is not yours.. Special software will be run to check for such cheating cases. If you are caught copying code, you will risk serious consequences (see course guidelines). Also, do not let other groups copy your code, as both groups with similar code will get 0 mark for the project (regardless on who copied on who). Note that every year several groups get 0 mark (or worse: academic misconduct) because of plagiarism. To avoid any possible issues, I would strongly advise you to not collaborate among different groups.

       Your Python script must implement the functions check victory, apply move, check move, computer move, display board and menu (see below). Make sure you don’t miswrite the functions names, or make an error in the input/output that are expected for these functions. The grading will be mostly be based on these functions.

       You can find on NTU Learn a file test.py to pre-test your functions (simply copy the file in your repertory and run it). It should output OK for all tests (note that getting a OK does not necessarily mean your function is working perfectly). You can also find on NTU Learn a skeleton of the connect4.py file.

       You should not have any Python code that does not belong to a function (i.e. all your Python code must be inside a function), except the module imports at the very beginning, and except the call to the menu function, which will start your program. You can define and use your own functions in addition to the existing ones.

 

1 Connect 4 game

Connect4 is a two-player game in which the players first choose a color and then take turns dropping colored discs from the top into a 7-column, r-row vertically suspended grid. The pieces fall straight down, occupying the next available space within the column.  The object  of the  game is  to  connect four  of one’s own discs of the same color next to each other vertically, horizontally, or diagonally before your opponent (description taken from wikipedia: http://en.wikipedia.org/wiki/Connect_Four).

 

 

 

 

Figure 1: Example of a Connect4 game.  The yellow player wins with 4 consecutive yellow discs in the second row.

 

For those who don’t know the game, I would advise you spend ten minutes to try it on this website:

http://www.mathsisfun.com/games/connect4.html

You will have to implement the pop out version of this game: during each turn, instead of adding disks, a player can otherwise choose to “pop out” one of  its own disk on the bottom row (i.e.  only a single column of the board is impacted). Popping a disc out from the bottom drops every disc above it down one space, changing their relationship with the rest of the board and changing the possibilities for a connection.

 

2 Objectives

The objective of the project is to write in Python a working Connect4 (pop out version) program that allows a human player to play  Connect4 against another human player or against a computer player through a menu. Be VERY careful to implement EXACTLY the game rules (test your program thoroughly and try to think of all the special cases). The program must allow the user to configure:

       the number of rows of the board (i.e. the number of rows r and the number of columns c of the board, the default values must be r = 6). You can set minimum and maximum values if you want. Note that the number of columns is not configurable and always set to 7.

       the type of the two players (human or computer), and the difficulty level in case of a computer player (two levels).

You have to use the skeleton file connect4.py provided on NTU Learn. Moreover, note that every time you add a feature to your program, you should test it thoroughly before continuing. Testing your program only at the very end is the best way to render the bug hunting close to impossible !

 

3 Three steps to complete the project

3.1 1st step: implementing the skeleton of the project and the user interface

The first step in a programming project is perhaps the most important  one:  before writing any  Python  code, you should think about the functions you will need to implement, their input/output, their goal, the overall

 

structure of the entire program. This step has already be done for you and you have to use the skeleton file connect4.py provided on NTU Learn. Make sure you understand what each function is supposed to do and try to get an idea of how the entire program will be organised. In short, you have a menu function to handle the interface with the user, and one function for each filter/transformation functionality to be added.

 

3.1.1 Data Structure for the game.

In order to represent the board in Python, you can use a simple data structure: a list of 7 r integers (r being the configurable number of rows of the board), where 0 represents an empty slot of the board, 1 stands for disc from player 1 and 2 stands for a disc from player 2. The disc located at row i and column j of the board (starting the counting at 0) is therefore represented at index 7 i + j of the list. The row 0 will correspond to the bottom row of the board, and the column 0 will correspond to the left-hand side column of the board.

Note that a move from a player can then be described by a column index (an integer [0, . . . , 6]) and a Boolean value (True or False) representing the decision of the player to perform popup action (True) or not (False).

 

3.1.2 Skeleton of the project.

You will have to implement the following functions for your project. Note that board will denote a list of integers representing the board, turn will denote an integer representing who’s turn it is to play (thus equal to either 1 or 2).

 

       check move(board, turn, col, pop). This function’s role is to check if a certain move is valid for a certain board. It will take an integer list board, an integer turn, as well as an integer col (that will represent the column index of the disc played, counting starting at 0) and a Boolean value pop  (that will represent the decision of the player to pop a disc or not) as inputs. It returns a boolean value False if the move is not allowable, and it return True if the move is allowable. Carefully check the game rules to properly implement this function.

       apply move(board, turn, col, pop). This function’s role is to apply a certain move to a game. It will take an integer list board,  an integer turn,  as well as an integer col  (that will represent the column index of the disc played, counting starting at 0) and a Boolean value pop (that will represent the decision of the player to pop a disc or not) as inputs. For this function, you can assume that the move is always an allowable one. It returns an updated board according to that move.

       check victory(board, who played). This function’s role is to check if a victory situation has been reached. It will take an integer list board and an integer who played  (that will represent which player played the last move) as inputs. It will return:

0 if no winning situation is present for this game

1 if player 1 wins

2 if player 2 wins

 

 

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

936 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

635 Answers

Hire Me
expert
Husnain SaeedComputer science

529 Answers

Hire Me
expert
Atharva PatilComputer science

831 Answers

Hire Me

Get Free Quote!

377 Experts Online