3 — The Image
Due Wednesday, 13 October 2021, 11:59:59pm
Delivery Use the Trains directory in your repository to deposit the products of this week’s milestone:
Since Python’s naming system is badly designed and its convention interfere with the specified name, Pythonistas may substitute _ for - in these file names.
for the Programming Task, place map-editor.PP in a new Trains/Editor/ directory
Some languages demand a specific organization within the file system. In that case, you may place a link to map-editor.PP into Editor/.
for the Design Task, place game-state.md in Planning/
for the Testing task, place xmap and Tests/ into a top-level repo directory named 3
Keep in mind our Trains.Com, a Plan when you work on designs.
Programming Task Your programming task is to implement a map visualizer.
The visualizer should consume a data representation of a map and display the map.
the map’s Width and Height are natural numbers in [10, 800] and [10, 800], respectively, and denote numbers of pixels
as a string, a city’s Name satisfies the regular expression "[a-zA-Z0-9\\ \\.\\,]+" [i.e., all letters of the English alphabet, all digits, plus space, dot, and comma] and has at most 25 ASCII characters.
Completely, Totally, Optional Fun Turn the visualizer into a map editor so you can visually design your railroad maps. The ideal map editor consumes and produces a data representation of a map. You may wish to use it for creating test cases, but it is easily possible to write down interesting test cases manually.
The referee must should use this knowledge to check the legality of actions.
A player may use this knowledge to decide on which actions to take or plan ahead.
Design data representations for the state of the game for both referees and players. If you think identical representations are appropriate, explain so in your memo.
To describe the data representation, mix English and references to the data sub-language of your chosen programming language. For the operations, choose the wish list format that you got to know in Fundamentals I and Fundamentals II, depending on which of the languages used in these courses matches your chosen language most closely. Distinguish the two parts clearly.
The memo should not exceed two pages. Less is more.
Keep in mind our Trains.Com, a Plan when you work on designs.
Testing Task Create a test harness named xmap. The harness consumes its JSON input from STDIN and produces its results to STDOUT. Create three tests and place them in the specified folder.
A test case always consists of given inputs and expected outputs. For this course, a test consists of a pair of files: n-in.json, the input file, and n-out.json, the expected output file, where n is an integer between 1 and the requested number of tests.
Constraint No test file may exceed the size limit of 20Kb.
Its inputs consists of three JSON values: two Strings and a Map object. The two strings are Names of cities, and these cities must be on the Map.
The expected outputs is a Boolean, indicating whether the two give cities are connected form a destination or not.
{ "width" : Width, |
"height" : Height, |
"connections" : Connection Connections } |
|
TESTING CONSTRAINT For testing purposes, a Map should consist of at |
most 20 cities and 40 connections. |
|
INTERPRETATION specifies the logical and visual layout of a game map |
|
in [0,W] and Y is a natural number in [0,H] with W and H as specified |
in the map object's "width" and "height" fields, respectively. |
|
CONSTRAINT No two cities may have the same name or occupy the same spot. |
|
INTERPRETATION specifies a city's name and location on the map |
|
A Connection Connections is an object whose domain elements are Names |
and whose range elements are Targets. |
|
CONSTRAINT Every Name must be a member of the Names in the "cities" field. |
The domain name must be string<? to the range's name. |
|
INTERPRETATION specifies from where connection originates (domain), |
to where they go and the nature of the connection (range) |
|
A Target is an object whose domain elements are Names |
and whose range elements are Segments. |
|
CONSTRAINT Every Name must be a member of the Names in the "cities" field. |
The domain name must be string<? to the range's name. |
|
INTERPRETATION specifies where a connection goes (domain) |
and their nature (range) |
|
A Segment is an object whose domain elements are Colors |
and whose range elements are Lengths. |
|
CONSTRAINT The Colors must be pairwise distinct. |
|
INTERPRETATION specifies the color and length of a connection |
Hint This textual interchange representation enforces game-centric constraints on the map, but it is not intended to be identical to your data representation (and it is certainly not the one used for the oracle implementation).
Well-formed and Valid For now, you may assume that all inputs to your test harnesses will be well-formed and valid JSON.. As a reminder, a well-formed piece of JSON satisfies the grammar of JSON; such a piece is valid if it also satisfies all the constraints of the above specification. For example, ["Washington, D.C.", [700,-2]] is a well-formed piece of JSON but an invalid City. ["Washington, D.C.", [200,600]] is both well-formed and valid.
Beyond integeration testing, we should eventually move to stress testing. The course will touch on this idea in November or December.
Pedagogy Besides unit tests, multi-component projects also need integration tests. Such tests compose several components and run tests on the composite that exercise functions across the components. This task is a lightweight illustration of this idea.
When a milestone assignment requests an integration test harnesses, you should not
have to modify the core functionality from the previous milestone—