COMP1110 Assignment 1 Academic Honesty and Integrity
Honesty and integrity are of utmost importance. These goals are not at odds with being resourceful and working collaboratively. You should be resourceful and you may discuss the assignment and other aspects of the course with others taking the class. However, the golden rule is simple: you must never misrepresent the work of others as your own.
If you have taken ideas from elsewhere or used code sourced from elsewhere, you must say so with utmost clarity. At each stage of the assignment you will be asked to submit a statement of originality, either as a group or as individuals. This statement is the place for you to declare which ideas or code contained in your submission were sourced from elsewhere.
Please read the ANU’s official position on academic honesty. If you have any questions, please ask me.
Carefully review the statement of originality which you must complete. Edit that statement and update it as you complete the assignment, ensuring that when you complete the assignment, a truthful statement is committed and pushed to your repo.
Purpose
This assignment is introductory, helping you gain familiarity with the basics of Java, but doing so in the context of slightly larger piece of code. Most of the assignment is composed of a series of small tasks.
Assignment Deliverable
The assignment is worth 5% of your total assessment, and it will be marked out of 5. However, these marks are redeemable by the exam, so if your exam mark / 20 is higher than your assignment one mark, you will get the exam mark / 20 rather than the assignment one mark. The mark breakdown is described on the deliverables page.
The assignment is due at 14:45 Monday Week 4, 16 August 2021 (time remaining), giving you two weeks in which to complete it. You can find this deadline on the deliverables page, where all assignment deadlines for this semester are listed. Your tutor will mark your assignment by accessing your GitLab repository, so it is essential that you carefully follow instructions for setting up and maintaining your repository. You will be marked according to whatever is committed to your repository at the time of the deadline. Since the first assignment is redeemable, late extensions are not offered and will not be given. As always, throughout the course, if some significant circumstance arises outside of the course that affects your capacity to complete the course, please carefully follow the ANU’s special consideration process, and your circumstances will be accounted for in your final assessment.
Overview
The assignment is based on a simple children’s puzzle called Walk the Dog, made by SmartGames, a producer of educational games. The design of the game and all of the imagery in this assignment comes from their WALK THE DOG game.
The game is played by placing all 4 dogs in the park with enough space between them to avoid a fight!
Pieces
The game consists of trees, cats and required dog and owner positions which define the objective of the game; as well as 4 dog pieces to solve the challenge.
3 of the 4 dog pieces are connected to an owner by leashes of different lengths, and the final dog is owner- less. The colour of the owner and dog indicates the length of its leash:
The red dog is connected to the red owner with a leash of length 3
The yellow dog is connected to the yellow owner with a leash of length 2 The blue dog is connected to the blue owner with a leash of length 1 The green dog does not have an owner (a leash of length 0)
Objective
Objective
The objective of the game is to place all 4 dog pieces on the board defined by a given objective such that they abide by the rules of the game.
Each objective defines the initial positions of cats and trees as well as required owner and dog positions. A sample objective initial state is shown here:
The green tree indicates the position for the tree piece
The black or gray cats indicate the position for the cat pieces
A white owner icon in the objective indicates that an owner must be placed on that spot in the board. It can be any one of the 3 owners.
A dog with a brown collar indicates that a dog must be placed in that position. It can be any one of the 4 dogs.
Note that the orientation of pieces is not relevant to this game.
The game is successfully completed once all 4 dog pieces are placed validly on the board (see the Rules section below).
The game comes with 80 pre-defined objectives, organized into four difficulty levels from starter to master. Each time the game is played, the objective may be different. Some objectives are easier to solve than others. The game is designed so that the player may specify a difficulty level. In the real game there are four difficulty levels, each with 20 different possible objectives. In our version, the user may select the level of difficulty on a slider.
We have provided you with a paper version of the game, which you can print out and use to help you visualise the game if you wish.
Rules
To complete the challenge, all dogs and owner must be placed validly on the game board. Dogs and owners can be placed anywhere on the board following these rules:
1. Dogs can never be placed directly adjacent to other cats or dogs.
2. Three of the dogs are connected to owners by a leash. Leashes must form horizontal or vertical lines with the game board (diagonal leashes are not allowed). Leashes must also be taught (ie straight).
3. Leashes can pass straight by or bend around the tree at a 90 degree angle.
4. Leashes can never cross each other or pass over owners, dogs or cats.
Each objective has only one solution. For example, the unique solution to the objective above is
Encoding the Game Locations
In our game we encode Locations on the board as a string of two numbers between 0 and 3 representing the (x, y) coordinates of the location. For example, the string “03” corresponds to the location (0, 3) . Locations correspond to board positions as follows:
There is also a Location class that stores this information as well as some useful methods that you will implement in this assignment.
More information can be found in the Location class.
It is also useful (for storing the game state) to encode these Locations as positions, that is an integer from 0-
15 corresponding to a Location as follows:
0123
00123 14567 2 8 9 10 11 3 12 13 14 15
For example, the Location (2, 1) may be represented as the position 6 and vice versa. Objective Encoding
The initial state of the game is encoded as a string that represents the tree, cat and required dog and owner locations.
The type of piece is indicated by the letters ‘T’ , ‘C’ , ‘D’ and ‘O’ respectively. This letter is then followed by a list of location encodings denoting all of the locations that the particular piece occurs on the game board. If the list is empty then the letter is not included. In general the encoding takes the following form:
Note that the order of the letters is important.
For example, the string “T23C0132O00” defines the following board state
T{tree location}C{List of cat locations}D{List of required dog locations}O{List of
required owner locations}
Exhaustively, this initial state means:
“T23” : the tree is located at the location (2, 3)
“C0132” : there are two cats on the board at locations (0, 1) and (3, 2) The absence of a “D” clause means that there are no required dog positions
“O00” : there is one required owner position at the location (0, 0) The Objective class has all of the objectives encoded for you already.
Dog Piece Encoding
A dog piece is encoded as either a 2 character or 4 character string.
If the piece is the single green dog then the encoding is 2 characters long, namely the string encoding of the location of the dog. For example, the dog piece encoding “03” indicates that the green dog is placed at the location (0, 3) .
All other dog pieces are encoded with a 4 character string, the first two characters represent the location of the dog while the second two represent the location of the owner. For example, the string “0121” indicates that the yellow piece is placed with the dog at the location (0, 1) and the owner at the location (2, 1) with the leash horizontally stretched between them (note that we can tell that this encoding represents the yellow dog because the Manhattan distance between the locations (0, 1) and (2, 1) is 2, and the yellow dog is the one with a leash of length 2). Similarly, the string “2302” indicates that the red piece is placed with the dog at (2, 3) and the owner at (0, 2) . Note that this placement will not be valid unless the tree is located at (0, 3) or (2, 2) . (You may find it helpful to use the paper version of the game to think through these examples concretely.)
Solution Encoding
An encoding of the solution to an objective is a 14 character string representing the placements of each piece on the board. Since the game is solved by placing the dogs, the solution is simply a concatenation of 4 dog piece string encodings as follows:
{Red piece}{Yellow piece}{Blue piece}{Green piece}
For example, the solution to the game state above has the following encoding “21331311100030” which
corresponds to the solution:
Finally, note that a partially completed objective is encoded similarly to the solution, namely, it is simply a concatenation of all placed pieces placement strings. The ordering of these placement strings is not altered from the solution string, but placements are simply excluded if the corresponding piece is not on the board. To determine what piece the string is referring to one should calculate the Manhattan distance between the two encoded locations.
For example, the placement string “0003101120” implies that the red piece is placed from location (0, 0) to location (0, 3) ( “0031” ); the yellow piece is not placed (as the Manhattan distance from (1, 0) to
(1, 1) is 1 ); the blue piece is placed from (1, 0) to (1, 1) ( “1011” ); and the green dog is placed at (2, 0) ( “20” ).
Note that this can be accessed using the getPlacements() method in the WalkTheDog class.
Your task
Unfortunately your version of the assignment has some missing code. While the graphical user interface is complete, some of the important logic is missing, so it won’t work as described above. It is your job to fix the problems, each identified by a FIXME comment in the source code, so that the code works. Do not change the code except by following each of the assigned tasks. When those tasks are completed, the game will function correctly. Check your changes by using the provided unit tests.
Legal and Ethical Issues
First, as with any work you do, you must abide by the principles of honesty and integrity. I expect you to demonstrate honesty and integrity in everything you do.
In addition to those ground rules, you are to follow the rules one would normally be subject to in a commercial setting. In particular, you may make use of the works of others under two fundamental conditions: a) your use of their work must be clearly acknowledged, and b) your use of their work must be legal (for example, consistent with any copyright and licensing that applies to the given material). Please understand that violation of these rules is a very serious offence. However, as long as you abide by these rules, you are explicitly invited to conduct research and make use of a variety of sources. You are also given an explicit means with which to declare your use of other sources (via originality statements you must complete). It is important to realize that you will be assessed on the basis of your original contributions to the project. While you won’t be penalized for correctly attributed use of others’ ideas, the work of others will not be considered as part of your contribution. Therefore, these rules allow you to copy another student’s work entirely if: a) they gave you permission to do so, and b) you acknowledged that you had done so. Notice, however, that if you were to do this you would have no original contribution and so would receive no marks for the assignment (but you would not have broken any rules either).
Evaluation Criteria
The mark breakdown is described on the deliverables page. Pass
Tasks #1, #2, #3, #4, #5, and #6
Credit
Tasks #7, #8, and #9 (in addition to all tasks required for Pass) Distinction
Tasks #10 and #11 (in addition to all tasks required for Credit) High Distinction
Tasks #12 and #13 (in addition to all tasks required for Distinction)