联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> Python编程Python编程

日期:2020-11-08 07:59

JIT104 Building IT Systems

Fall, 2020

Take‐Home Task 1 (THT1): Picture Puzzle Blocks

(Weight: 20%.  Due: 8 November, 2020)

Overview

This is the first take home task.  It is worth 20% of your final grade for this unit.

Motivation

One of the most basic functions of any IT system is to process a given data set to produce some

form of human‐readable output.   This assignment requires you to produce a visual image by

following instructions stored in a list.  It tests your abilitiesto:

? Process lists of data values;

? Design a solution to a computational problem;

? Display information in a visual form; and

? Produce reusable code.

Goal

Picture block puzzles are traditionally toys for preschoolers, like these:

The idea behind the puzzle is for the child to

arrange each of the blocks to form a complete

image which is immediately recognisable.

More recently, the idea of picture puzzle blocks

has been used in the production of photo images.

In this assignment you are required to develop a

Python program which processes data stored in a list to display a specific arrangement of up to

four "blocks".    Each block must have a distinct part of an overall image on its face.  When the

blocks are stacked correctly the entire image must be produced.  Blocks can be stacked up to two

layers deep and can be placed in any of four possible orientations, upright, upside down, turned

left and turnedright – always with the face of the block, and therefore the image, visible.

To complete this assignment you will need to use basic Python features and the Turtle graphics

module.  You must also design four blocks which, when arranged in the correct order,produce a

single picture.  Note that you will only need to draw two dimensions of each block.  In other

JIT104 Building IT Systems

Fall, 2020

words, each block will be a square.  The whole picture must be non‐trivial, and must span all four

pieces, but otherwise you have a free choice of what to draw, e.g.,

? cartoon, game or science fiction characters,

? household objects,

? corporate or sporting logos,

? buildings or vehicles,

? animals or pets,

? landscapes, etc.

To stack the blocks you must develop your code so that each individual block can be drawn in any

of four different locations on the screen and in any of four differentorientations.

Resources provided

A template Python program, picture_puzzle_blocks.py, is provided with these

instructions.  This template:

? Creates a drawing canvas and displays a simple background image; and

? Optionally draws the Cartesian coordinates at which the blocks must be drawn.  When

you first run the program it will create the following drawingcanvas.

The red dots mark the centres of the locations where the blocks must be drawn and the dark blue

dots mark their corners.    Each block must be a square measuring 250 x 250 pixels.    The

coordinates are shown to help you position your images while you develop your program.  When

you have completed your solution you can turn them off by changing some parameters in the

template's main program.   Notice that in this canvas the "home" coordinate (0, 0) is at the

bottom, marking the ground on which the blocks will be stacked.

The provided template file also contains several data sets, in the form of lists, which specify how

you must arrange the blocks when drawing them.    These 'arrangement' lists each contain

JIT104 Building IT Systems

Fall, 2020

instructions in three parts:

? The identity of the block to draw, from 'BlockA' to 'BlockD'.

? The place where the block must be drawn, either 'Top left', 'Top  right', 'Bottom left' or

'Bottom right'.  Notice that the lists are ordered so that each block is placed either on the

ground or on top of an existing one, never in mid‐air.

? The orientation of the block, either 'Up', 'Down', 'Left' or 'Right', denoting up‐right, upside

down, on its left side or on its right side,respectively.

The template file also contains a dummy function definition, stack_blocks. Your task is to

complete this function definition so that it draws the blocks at the positions and orientations

specified by any of the given data sets(or any othersimilar data setsin the same format).    When

arranged the right way your blocks must produce a single, completepicture.

Illustrative example

Below is a sample solution to illustrate the requirement. (Don't copy this example.  Develop your

own idea!  Be imaginative!)

Firstly you will need to design each of your blocks. In the case below, four blocks are created in

their upright orientation.

Block A:    Block B:  

Block C:         Block D:

Each of the four blocks must contain a non‐trivial image clearly distinct from all the others,

regardless of their orientation and colour, i.e., no block drawing can be identical to another block

when rotated. Also, the images must be asymmetric so that it's easy to tell which way the block

is pointing. When arranged correctly the four blocks must combine precisely to produce a single

composite picture.

Although it's difficult to specify the artistic requirements for this assignment, given the wide

range of imagesthat could be chosen,the assembled picture must:

? involve a number of different shapes;  

? involve at least two colours;

JIT104 Building IT Systems

Fall, 2020

? completely obscure the background behind it – i.e., each square must be completely

filled‐in; and

? be immediately recognisable.  

Simple geometric shapes would not be considered sufficiently

challenging.    Similarly, four unrelated images, one per block, would be

unacceptable.    A good example of an image that would not be

considered suitable for this assignment is the Commonwealth Bank

logo, which is largely just a yellow square.  Even apart from the logo's

simplicity, the top left and bottom left blocks would be identical when

rotated in thisinstance.

Your solution must be capable of drawing blocks in any specified arrangement.    This will be

achieved by virtue of function arguments.    Each call to your stack_blocks function will

provide values representing the specified arrangement.  In the Python template file there are

several data sets in the form of lists, each describing a particular arrangement of one or more

blocks which will be used as such an argument.  For instance, one of the simplest such lists is as

follows:

arrangement_01 = [['Block A', 'Bottom left', 'Up']]

This list tells us that we are required to position Block A in the bottom left location, in its upright

orientation.    When our stack_blocks function is called with this list as the argument it

produces the image displayed below.

Another such data set is as follows.

arrangement_12 = [['Block A', 'Bottom left', 'Right']]

In this case Block A is to be drawn in the same location but lying on its right side, which produces

the following image.

Commonwealth Bank Logo

JIT104 Building IT Systems

Fall, 2020

Other data sets require multiple blocks to be stacked.    For instance, the following data set

specifiesthatthree blocks must be shown, Block B in the bottom rightlocation lying on itsleftside,

Block D in the bottom left also on its left side, and Block C stacked in the top right position and

upside down.

arrangement_42 = [['Block B', 'Bottom right', 'Left'],

['Block D', 'Bottom left', 'Left'],

['Block C', 'Top right', 'Down']]

The resulting image in this case is as shown below, for our particular collection of blocks.

JIT104 Building IT Systems

Fall, 2020

The final data sets require all four blocks to be drawn, in various locations and orientations.  The

very last data set provided is as follows.

arrangement_99 = [['Block C', 'Bottom left', 'Up'],

['Block D', 'Bottom right', 'Up'],

['Block A', 'Top left', 'Up'],

['Block B', 'Top right', 'Up']]

Most importantly, this arrangement stacks all four blocks upright and in an order that completes

the image, as shown below.  In this case it at last reveals that our chosen overall picture is the

well‐known logo for the Yellow Pages telephone directory.  So that this final image looks nice we

have turned off the coordinate markings below.    We have also given the window a title,

describing the image.

Requirements

To complete this task you are required to extend the provided

picture_puzzle_blocks.py  Python file by completing the function stack_blocks so

that it can draw blocks at the places and orientations specified by a data set provided as its single

parameter.  Your code must work for all the supplied "arrangement" data sets and any other data

set in the sameformat.

JIT104 Building IT Systems

Fall, 2020

Yoursubmitted solution will consist of a single Python file, and mustsatisfy the following criteria.  

1. Drawing four distinct picture puzzle blocks 2%.  Your program must be able to draw four

distinct blocks, each containing part of a single overall picture. Each block must be a 250 x 250

pixel square and must be of a reasonable degree of complexity, involving multiple shapes and

colours.  Each block must have a border, so its edges are clearly defined.  The entire square must

be filled in with colour.  Each block must be clearly different from all the others, regardless of

their orientation, and the image on each individual block must be asymmetric so that it is easy to

tell which way it is oriented.

2. Creating a single picture in four parts 2%.  When arranged correctly, as per the final data

set provided, the separate parts of the image must align perfectly to produce a single, clearly

recognisable picture.    The title of the drawing canvas must describe the picture drawn. (NB: If

your solution is incapable of drawing all the blocks in their final arrangement I cannot assess this

criterion and must award zero for it.)

3. Relocating blocks 2%.  Your code must be capable of drawing each of the four blocks at

any of the four marked places, as per the coordinates (optionally) drawn on the screen by the

provided template.  The blocks must be sufficiently different that it is easy to distinguish which

one is being drawn in each location. The images on the blocks must preserve their integrity no

matter where they are drawn and must fit perfectly into the marked places.  No extraneous lines

or shapes should be drawn outside the boundaries of the blocks.  Your solution for relocating the

blocks must work for all of the provided data sets and any other data sets in the same format.  

(You must not "hardwire" your code for specific data sets and you must not change the data sets

provided.)

4. Rotating blocks 2%.  Your code must be capable of drawing each of the four blocks in

any of the four possible orientations, upright, upside down, on its left side or on its right side.  

The images on each block must be sufficiently asymmetric that it is easy to tell one orientation

from another.    The images of the blocks must preserve their integrity no matter how they are

oriented and must fit perfectly into a 250 x 250 pixel space regardless of their orientation.    No

extraneouslines orshapes may be drawn outside the boundaries of the blocks.  Your solution for

reorienting the blocks must work for all of the provided data sets and any other data sets in the

same format. (You must not "hardwire" your code forspecific data sets and you must not change

the data setsprovided.)

5. Code quality and presentation 2%.    Your program code must be presented in a

professional manner. See the coding guidelines in the ITD104 Code Marking Guide (on Blackboard

under Assessment) for suggestions on how to achieve this.  In particular, given the obscure and

repetitive nature of the code needed to draw complex images using Turtle graphics, each

significant code segment must be clearly commented to say what it does, e.g., "Draw index

finger", "Draw left side of book", etc.

The mark for this criterion will be proportional to the amount of functionality attempted in the

other criteria (above).  That is, if only half the functionality is attempted, the code quality and

presentation mark will be out of 1%.

You must complete the task using basic turtle graphics and maths functions only.  You may

not import any additional modules into your program other than those already included in the

given picture_puzzle_blocks.py template.    In particular, you may notimport any image

files for use in creating your blocks.

Finally, you are not to copy the example shown in this document, nor any example that may be

demonstrated in class.  Instead you are strongly encouraged to be creative and to choose your

own picture thatinterests you personally.

JIT104 Building IT Systems

Fall, 2020

Artistic merit

You will not be assessed on the artistic merit of your solution, only the ability to create a

recognisable picture in four parts.  

Development hints

? This can be a time‐consuming task, so you are strongly encouraged to design your blocks

carefully before developing any programcode.

? The hardest part of this assignment is the need to allow the pieces to be drawn in

different locations and orientations.  You therefore need to devise a way of drawing each piece

so that you canmake all drawingmovesrelative to the starting position and orientation (e.g., using

Turtle'sforward, leftand rightcommands).  [Although it is possible to calculate absolute positions

for each drawing move (e.g., using Turtle's goto command) in terms of a given position and

orientation using trigonometricfunctions – this option tends to be more difficult and is therefore

not recommended.]

? The use of repetition will be required for this assignment (to visit each element of a given

data set, to determine which block to draw, where).  Repetition is a topic completed in week 5.  

Before then, you should:

? Decide what drawing to create.

? Write a function to draw each block of that drawing (so four functions).  I strongly

suggest you start each drawing in the same location e.g., at the bottom left hand

corner of the block.

? Parameterise each function to specify where to start drawing the block on the

canvas.

? Add another parameter to specify which orientation to draw the block.

Once you are familiar with repetition and iterating over sequences (from week 5), you

can make calls to each of your drawing functions from the supplied stack_blocks

function, using the values contained in the supplied data sets as arguments.

? If you are unable to complete the whole task, just submit whatever parts you can get

working.  You will receive partial marks for incompletesolutions.

? To help you debug your code there are several data sets provided, numbered 1 to 4 and

10 to 21, which draw just one piece at a time. You can use these to help create the code for each

block separately.

Deliverable

You must develop your solution by completing and submitting the provided Python file

picture_puzzle_blocks.py as follows.

1. Complete the "statement" at the beginning of the Python file to confirm that this is your own

individual work by inserting your name and student number in the placesindicated.  If you do

not complete this statement, I will assume that you do not wish to claim authorship of it, and

will give you a mark of 0.

2. Complete your solution by developing Python code to replace the dummy stack_blocks

function.  You must complete your solution using only the modules already imported by the

provided template.    You may not use orimport any other modules to complete this program.  

In particular, you may not import any image files into your solution.

3. Submit a single Python file containing your solution for marking.  Do not submit an archive

(e.g., in 'zip' or 'rar' formats) containing several files.  Only a single file will be accepted, so

JIT104 Building IT Systems

Fall, 2020

you cannot accompany your solution with other files or pre‐defined images.

Apart from working correctly your program code must be well‐presented and easy to understand,

thanksto (sparse) commenting that explainsthe purpose ofsignificant code segments and helpful

choices of variable and function names.  Professional presentation of your code will be taken into

account when marking this assignment.

If you are unable to solve the whole problem,submit whatever parts you can get working. You will

receive partial marks for incomplete solutions.

Academic Integrity

This assignment is for individual assessment only.  That means the work you submit must be your own

work and not the work of anyone else.  You are not permitted to collaborate with your peers on this

assignment, other than to discuss high‐level strategies.    You are not permitted to ask or commission

someone else to write the assignment for you, or help you write the assignment.  

If you are in any doubt as to what is permitted and what is considered a breach of academic integrity,

please talk to one of the teaching staff as soon as possible.  

Author:   Colin Fidge (QUT)

Revised:   Donna Kingsbury (QUTC 2020)

 

JIT104 Building IT Systems

Fall, 2020

Appendix: Some standard Turtle graphics colours


版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp