mining | 代写project | Python代做 | assignment | IT – FINAL PROJECT: THE COLOURFUL ZERO GAME


mining | 代写project | Python代做 | assignment | IT – 这是利用mining进行训练的代写, 对mining的流程进行训练解析, 涉及了mining/Python/IT等代写方面, 该题目是值得借鉴的assignment代写的题目

IT代做 代写IT

Game developers: Diana Cukierman and Matt Amy



You are asked to implement a Python program, allowing the user to play the Colourful Zero Game, possibly multiple times. This is a single player game where the goal is to make the rows and columns of a 2D game board all add to zero. The rules of the game are described in more detail below. At the end of each game, your program will display text based and save image based results and invite the user to play again. When the user is done playing, information about all games is shown.


With this project you will be working with: Reading text (csv) files Text interaction with the user Manipulating one, two, and three dimensional lists Working with single and nested loops, accumulation pattern and others Manipulating images (represented with the 2D lists with RGB pixel lists as seen in class) The module. Creating dictionaries based on preexisting text files Using dictionaries The code is required to be done in a modular way (and will be most useful for you), defining your own modules and your own functions, both productive and non-productive.


The game board

The game is played on a square matrix of varying sizes (e.g. 3×3, 4×4, 5×5). The size can be at most 9×9. In each cell of the matrix there is a number from 9 to 9. See Figure 1.

Game developers: Diana Cukierman and Matt Amy

Figure 1 Example of a 4×4 board. The board corresponds to the list of rows [[1,-1,2,0][9,2,3,-9],[5,-5,2,0],[-9,0,-3,8]]

The initial configuration of a game board is given by a file where the value in each cell of the matrix is given in comma separated format (csv). You have been given 5 initial board configurations in files boardX.csv (where X is the value 1 to 5, identifying the board). All boards are square, that is, they have the same number of rows and columns.

Game play

At the start of a game the user will be given the option to choose which board they would like to play by selecting a board number (1 to 5)^1. Your program must then load the selected board X from the file boardX.csv — marks will be deducted for hard-coded boards.

The object of the game is to repeatedly change values in the board (the square matrix) to make every row and column add up to 0. The player has several turns, selecting one cell on the board at a time to change to a new value from 9 to 9 to put in that cell. The same cell may be changed more than once.

One game is over if a) every row and column of the board sums to zero, in which case the player has won the game, or b) if the user decides to stop (typing 99 for the row number) , that is, they dont want to continue with that board (although they may want to play a new game later) c) if the player runs out of turns. The maximum number of turns the player should be given for one game, for an nxn board is n^2 / 2, rounded down — so, if the user is playing on a 3×3 board, the maximum number of turns would be 3×3/2 = 4.5, resulting in 4 turns rounded down.

The dialog with the user what to show to and ask of the user At the start of the game, once again, the user chooses the initial board (1 to 5).

(^1) Note: You may create additional initial board files if that helps you debug your program. The project may be marked with different boards than those provided (although with the same characteristics as described here). As a first stage make sure that you allow that your program at least works with the first three possible board files ( to 3) named exactly as described, without hardcoding them.

Game developers: Diana Cukierman and Matt Amy

The game proceeds as a text-based dialog with the user. During game play, on each turn the computer should show the user:

  1. The game board, including also the current sum of each row and column
  2. The number of turns the user has left to play in that game
  3. A dialog asking for their next move See Figure 2 and also the sample runs.

Figure 2 The user is informed the column sum (shown as a column to the right of the board, where each value is the sum of all elements in each row in the board), the row sum (shown as a row at the bottom of the board, where each value is the sum of all elements in each column) and the number of turns left. Note that row 2 and column 2 add up to 0.

At the end of each game (given any of the three reasons described above), the program will: Inform the player of whether or not they won, Show them how many points they scored (winning or not winning), and Use the final state of the last board in the game to create two jpg image files. (Details below)

At the start and after a game is over the program should ask the user if they would like to play a game. The user can play as many games as they want.

To further follow the program dialog and the game logic you should also check the sample runs provided, which are considered part of the problem description.

Scoring at the end of one game

The points won in a game are calculated as follows: The player receives 1 point for each row/column that sums to 0 Additionally, if all rows and columns sum to 0 (i.e. the player has won the game), the player gets an additional 10 points

See Figure 2 above again. This is a final game board (because the user decided to stop the game). This is not a winning board, since some (most) of the row and columns do not sum to 0. Notice however that the user gets some points; the points in this case would be 2, because row 2 and column 2 add to 0.

Game developers: Diana Cukierman and Matt Amy

Creating two images at the end of each game

At the end of a game, after the points are shown to the user, two images are to be generated and saved in your folders, based on the contents of the board at that point (the last board in the game). Associated to the board in Figure 2, the following two images are generated, a board image and a diagonal image. Details of how the images are generated are described below. You are recommended to leave developing your program to create the images after having implemented the game, the dialog with the user and including points calculations. You are also recommended to create the diagonal image before creating the whole board image. The colour coding for the images will be based on the provided colourcoding.csv file as described below.

Figure 3. Diagonal image and board image corresponding to the board in Figure 2

At the end of all games

Your program should keep a tally of the points the player has scored considering all games. When the user confirmed that they do not want to play any more games, the program will inform the total points of all games and the total of won games. Then the program will greet the user and the program ends.


You are highly recommended to implement this project in stages. Also, save often and keep more than one copy as back up.

First, ensure that the basic game works. You can try implementing a game first on a hard coded board, then increase the complexity by adding the ability to load boards from files. To start, you may want to only deal with boards 1,2 or 3, which include only values that are 0 or positive. (Notice that board 3 is a winning board from the start).

Game developers: Diana Cukierman and Matt Amy

As a next stage you may want to allow the user to play multiple games and keeping a running tally of their score. You may then consider boards with both positive and negative values

We recommend leaving the colour coded diagonal and board image to the end.

A useful (and required) tip to help break up a large program into manageable chunks is to design functions which will perform specific functionality, such as display the game board on the screen, or compute whether the player has won the game. We have included in the project materials some function parts (including the suggested function name and some comments) which you may want to consider implementing and may help you to organize your program.


FILES boardX.csv These files will have in the first line, the board number of rows (which is the same as the number of columns), and then one row per line (comma separated) with the numbers. The board in Figure 1 above corresponds to the file in Figure 4 next.

Figure 4 Provided board4.csv file, here shown in excel. The format is comma-separated strings. The first row indicates the dimension of the board. This file corresponds to the board in Figure 1 above.

FILE: colorcoding.csv. In this file there is a titles line and then each line contains a dig IT (between 0 and 9) and for each digit there are 3 RGB values (each between 0 and 255, extremes included). Values were generated randomly. For example, in Figure 5, line 4 has the color coding for digit 2, representing the RGB color [207,81,85]

(^2) Note that your project may be marked with different files contents than the ones provided, but will have the same format and file names.

Game developers: Diana Cukierman and Matt Amy

Figure 5. Provided colorcoding.csv file, here shown in excel. The format is comma-separated strings.

Description of the colour coded board image and diagonal image

The board image is a 100n x 100n pixel image for an n x n game board. This image is made up of n^2 squares of 100 x 100 pixels. Each 100 x 100 pixel square is given a solid colour corresponding to the number in that cell of the game board. See Figure 3 above — the board image is a 400×400 pixel image, it has 4×4 colors, and corresponds to the board in Figure 2.

The diagonal image is a 100 x 100n pixel image for an nxn board. This image is made up of n squares of 100×100 pixels. Each 100 x 100 pixel square is given a solid colour corresponding to the number in each of the cells in the matrix main diagonal in the board. See Figure 3 above, the main diagonal has the values 1,2,-2,8; the image has 4 colours, and it is a 100×400 pixels image.

The correspondence between the number in a cell and the colour is given by the colourcoding.csv file. You are required to load this file into a dictionary in your program so that the colour value associated with a particular number from 0 to 9 can be looked up efficiently, without needing to read the file every time. If you do not load the colourcoding.csv file into a dictionary, you will lose marks.

You may notice that the colourcoding.csv file only contains the digits 0 to 9, while the game boards may also have negative numbers. The RGB colour for a negative number x, for example -7, should be the inverse of the corresponding positive number. Recall from the image processing assignment that to invert a colour with RGB values [r, g, b], you would calculate the colour value [255 r, 255 g, 255 b]. So, if the colour associated to 7 is [239, 179, 253], the colour associated to 7 is [255 239, 255 179, 255 253] = [16, 76, 2].

Name the files where you save the images as: diagimageB-G.jpg and boardimageB-G.jpg where G is the game number and B is the board number. For example boardimage4-1.jpg would be the image for the 4 th board , 1st game.

Game developers: Diana Cukierman and Matt Amy


The information that your program asks from and shows to the user should be analogous to and in the same order and detail as in the sample runs. Ask if in doubt.

(^) E. WHAT YOU ARE PROVIDED a. This description b. Five files boardX.csv, (X is 1 to 5) c. The file colorcoding.csv d. The file e. Sample runs f. A file with some recommended functions to be developed g. Additional sample runs may be posted later for further clarifications F. WHAT YOU NEED TO SUBMIT a. Two Python files: and i. should include the functions that you will use for creating the images at the end of the game ii. Your main file should implement the game, dialog with the user, creating the board, deter mining winning points, etc. To be able to use the creation of images functions, import in main the module that you create myCreateImages b. The associated reflection survey If you have any questions consult with the Teaching Team. Make sure that you check email and Canvas announcements in case that additional clarifications are provided.