Python代写:COMP9021Tangram


Introduction

用Python解一个 Tangram
,也就是七巧板问题,作业给基本框架,往里面填写逻辑即可。

Introduction

The assignment consists of three parts, from easiest to more difficult. Each
part is worth 3 marks.
For each test, the automarking script will let your program run for 30
seconds.
As all output is True or False, each test will actually consist of a number of
subtests of similar difficulty, and passing one test will mean passing all
associated subtests; failing at least one of the subtests of a test will
result in scoring 0 to that test.
Up to one mark will reward good comments, good choice of names for identifiers
and functions, readability of code, simplicity of statements, compactness of
functions. This will be determined manually.
One extra mark will be awarded for making available to the class a good test
case, consisting of two similar sets of pieces and two solved tangrams built
from such a set, which can then be used by everyone for testing purposes.
Late assignments will be penalised: the mark for a late submission will be the
minimum of the awarded mark and 10 minus the number of full and partial days
that have elapsed from the due date.

Background

The game of tangram consists in creating shapes out of pieces. We assume that
each piece has its own colour, different to the colour of any other piece in
the set we are working with. Just for reference, here is the list the colours
that are available to us

Pieces

Here is an example of the contents of the file pieces A.xml, typical of the
contents of any file of this kind (so only the number of pieces, the colour
names, and the various coordinates can differ from one such file to another -
we do not bother with allowing for variations, in the use of space in
particular).









—|—
Note that the coordinates are nonnegative integers. This means that the sets
of pieces we consider rule out those of the traditional game of tangram, where
2 is involved everywhere…
We require every piece to be a convex polygon. An .xml file should represent a
piece with n sides (n > 3) by an enumeration of n pairs of coordinates, those
of consecutive vertices, the first vertex being arbitrary, and the enumeration
being either clockwise or anticlockwise.
The pieces can have a different orientation and be flipped over. For instance,
the file pieces_AA.xml whose contents is









—|—

Shapes

A representation of a shape is provided thanks to an .xml file with the same
structure, storing the coordinates of the vertices of just one polygon.
The file shape_A_1.xml whose contents is



—|—
Contrary to pieces, shapes are not assumed to be convex polygons. Still they
are assumed to be simple polygons (the boundary of a simple polygon does not
cross itself; in particular, it cannot consist of at least 2 polygons that are
connected by letting two of them just “touch” each other at one of their
vertices - e.g., two rectangles such that the upper right corner of one
rectangle is the lower left corner of the other rectangle; that is not
allowed).
Whereas you will have to check that the representation of the pieces in an
.xml file satisfies our constraints,
you will not have to do so for the representation of a shape; you can assume
that any shape we will be dealing with satisfies our constraints.

First Task

You have to check that the pieces represented in an .xml file satisfy our
constraints. So you have to check that each piece is convex, and if it
represents a polygon with n sides (n > 3) then the representation consists of
an enumeration of the n vertices, either clockwise or anticlockwise. Here is
the expected behaviour of your program.

Second Task

You have to check whether the sets of pieces represented in two .xml files are
identical, allowing for pieces to be flipped over and allowing for different
orientations. Here is the expected behaviour of your program.

Third Task

You have to check whether the pieces represented in an .xml file are a
solution to a tangram puzzle represented in another .xml file. Here is the
expected behaviour of your program.


文章作者: SafePoker
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 SafePoker !
  目录