首页 > > 详细

代写Assignment 2: Blocky: CSC148H1S 20241 Introduction to Computer Science代写留学生Python程序

项目预算:   开发周期:  发布时间:   要求地区:

Assignment 2: Blocky: CSC148H1S 20241 Introduction to Computer Science

Assignment 2: Blocky

Due date: Monday, March 25, at 6:00 PM.

You may work individually or with one other person on this assignment. Partners must be invited in MarkUs (and invitations accepted) by Monday, March 18 at 6:00 p.m.

Important: To find out what you can and cannot do in the code you write for your assignments, please review the “Technical (programming) requirements” on the course page Policies and Guidelines:

Assignments (https://q.utoronto.ca/courses/336881/pages/policies-and-guidelines-assignments? module_item_id=5314700) .

FAQ

Please refer to the A2 FAQ post on piazza (https://piazza.com/class/lqb4rm6drad417/post/1588)for any common questions or clarifications about the assignment. The FAQ is required reading for the

assignment.

Learning Goals

By the end of this assignment, you should be able to:

· model hierarchical data using a tree structure

· use diagrams to help you design and implement complicated algorithms

· implement recursive operations on trees (both non-mutating and mutating)

· convert a tree into a flat, two-dimensional structure

· use inheritance to design classes according to a common interface

Domain Comprehension Quiz

As you get started on the assignment, you should first complete the A2 Domain Comprehension

Quiz (https://q.utoronto.ca/courses/336881/quizzes/377088) . The quiz requires you to read through the handout and starter code to ensure you understand the game before starting to write any code. The quiz counts as part of your A2 grade and must be completed individually. Reminder that there are no extensions available for this quiz; you can only get an extension for the MarkUs submission.

Introduction: the Blocky game

Blocky is a turn-based game with simple moves on a simple grid structure where players try to achieve the highest score depending on their goals.

The game is played on a randomly-generated game board made of squares of four different colours.  Each player has their own goal that they are working towards, such as creating the largest connected “blob” of blue or getting the most red on the perimeter of the board. To achieve their goal, players can perform. a number of actions that change the configuration of the board such as rotating a block, smashing a block, or painting a block a new colour. After each move, the player sees their current score, which is determined by how well they have achieved their goal and which moves they have made. The game continues for a certain number of turns, and the player with the highest score at the end is the winner.

The following sections will explain the rules of the game in more detail, and then you will be asked to implement the game in Python.

The Blocky board and terminology

We call the Blocky board a ‘block’, which is best defined recursively. A block is either:

· a square of one colour, or

· a square that is subdivided into 4 equal-sized blocks (children).

Each block can be found at a level within the board defined by how deep the block appears in the recursive subdivision. The largest block containing the whole board is called the top-level block and lies at level 0. If the top-level block is subdivided, the four sub-blocks lie at level 1. If these sub-blocks are further subdivided, the sub-sub-blocks lie at level 2, and so on. In general, if a block at level k is subdivided, its four sub-blocks lie at level k+1.

To prevent infinite subdivsion, a Blocky board has a maximum level depth, which is the highest level a block can lie on. This maximum level depth determines the most number of recursive subdivisions    that can be made in the board. For example, a board with maximum depth 0 would display one solid   color. A board with maximum depth 1 would be subdivided into four equal-sized blocks, and so on.

The smallest block of all is called the unit cell and lies at this maximum level. A block which is not subdivided is called a leaf.

The following example board was generated with a maximum depth of 5 using an algorithm we will     describe later for you to implement. The numbers indicate the level the block lies at. Notice that there are at most 5 subdivisions of a block.

Actions and Moves

A number of actions can be performed in Blocky. A move is an action that is performed on a specific block.

The actions are:

Choosing a block and levels

We can select blocks and levels by hovering the mouse around the board and increasing/decreasing the levels to select (Keys S/W).

Actions can be applied to any block at any level (with some exceptions as mentioned above of course). For example, given this example board with maximum depth level 4:

We can change the level to apply a rotate clockwise action for a different block:

Of course there are many other blocks within the board at various levels that the player could have chosen.

Players

The game can be played solitaire (with a singleplayer) or with two to four players. There are three kinds of players:

1. A human player chooses moves based on user input.

2. A random player is a computer player that chooses moves randomly.

3. A smart player is a computer player that chooses moves more intelligently: Asmart player   generates a set of random moves and, for each move, calculates the score if the move were

played. The player would perform. the move that yields the best score.

Goals and scoring

At the beginning of the game, each player is assigned a randomly-generated goal. There are two types of goal:

1. Blob goal

The player must aim for the largest “blob” of a given colour c. A blob is a group of connected unit cells with the same colour. Two unit cells are connected if their sides touch; touching corners doesn’t count. The player’s score is the number of unit cells in the largest blob of colour c.

For example, for the following board with maximum depth level 3, Player 2’s goal is to create the largest blob for the Old Olive colour. Player 2’s score for this blob goal is 26.

2. Perimeter goal

The player must aim to put the most possible units of a given colour c on the outer perimeter of the   board. The player’s score is the total number of unit cells of colour c that are on the perimeter. There is a premium on corner cells: they count twice towards the score.

For example, for the following board with maximum depth level 3, Player x’s goal is to put the most  blocks of the Daffodil Delight colour on the perimeter as possible. Player 0’s score for the perimeter goal is 14.

Notice that both goals are relative to a particular colour. We will call that the target colour for the goal.

In addition to the points gained by the player from achieving their goal, a player can also lose points based on the actions they perform.

· Rotating, Swapping, and Passing cost 0 points.

· Painting and Combining cost 1 point each time they are performed. · Smashing costs 2 points each time it is performed.

Configurations of the game

A Blocky game can be configured in several ways:

· Maximum depth: While the specific colour pattern for the board is randomly generated, we control how finely subdivided the squares can be.

· Number and type of players: There can be any number of players of each type. The “difficulty” of a smart player (how hard it is to play against) can also be configured.

· Number of moves: A game can be configured to run for any desired number of moves. (A game will end early if any player closes the game window.)



软件开发、广告设计客服
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 9951568
© 2021 www.rj363.com
软件定制开发网!