COMP1110 Assignment 1
The assignment is based on a simple children’s puzzle called Apple Twist, made by SmartGames, a producer of educational games. The design of the game and all imagery in this assignment comes from their Apple Twist game.
Figure 1: Apple Twist product photo
The game comes with 60 pre-defined challenges, organised into 4 difficulty levels from starter to master. Each challenge defines the board configuration, and some clues about where the caterpillars go.
The general objective of the game is to fit in all the caterpillars in the board by bending them as necessary.
We provide you with a paper version of the game (see assets folder), which you can print out to help you visualise the game if you wish.
Rules and terminology
Note: the following is adapted from the apple twist challenge book.
The apple game board is divided into 5 horizontal sections (called Row Templates in our implementation) that can each be flipped as required by each challenge (see first image in README).
· The frontside sections are indicated by numbers 1-5
· The backside sections indicated by letters A-E
The game includes a green caterpillar with six segments, a yellow caterpillar with 5 segments and a turquoise (blue) caterpillar with 6 segments. The goal is to place all three caterpillars on the apple board. Each caterpillar can be bent in different places along it’s length – in this assignment we call these places “Pivots”. All parts of the caterpillar must fit inside the dimples of the apple (in this assignment called “Spots” – see Figure 2). No part of the caterpillar can sit on a flat part of the apple.
Challenges
A challenge (see Figure 4 example) includes the information on which board sections are facing up. Challenges also include constraints / requirements about the position that caterpillar heads must go, but NEVER which direction the heads must be facing.
· A white caterpillar head is the equivalent of a ‘wildcard’ (see Figure 4 below) and indicates that any one of the three caterpillar’s heads must be placed in that position.
· Often a few of the board Spots will remain empty when completing a challenge.
· There are 60 challenges in the challenge booklet (for example see Figure 4 below).
· There is only one solution to each challenge!
This repository contains a java implementation of Apple Twist, including a graphical user interface (GUI). Unfortunately this version of the game has some parts missing. While the graphical user interface is complete, some of the important game logic is missing, so it won’t work as described above. It is your task to fix the problems. Each specific subtask is (a) listed as an issue in the issue tracker in this repository and (b) identified by a FIXME comment in the source code. You should not change other parts of the code than those indicated; however, feel free to add additional “helper” methods to the classes if you like. When all tasks are completed, the game will function correctly. Check your changes by using the provided unit tests.
The rest of this README file describes the components of the game, and how they are represented in the assignment, in more detail.
The board is defined as a 5 x 5 grid with some spots missing (see Figure 2). Below is a depiction of the board, along with each position’s Cartesian coordinates:
A place where a caterpillar segment can occupy is called a Spot (see Figure 2). Note that not all board coordinate positions in the 5 x 5 grid contain a Spot. For any given challenge different positions contain a Spot.
Caterpillars
Each Caterpillar is made up of segments (see Segment class), some segments can pivot (see Figure 2). Segments that can pivot can either have a LEFT_BEND, RIGHT_BEND or beSTRAIGHT (see enum PIVOT in Segment enum class). Note: the reference for LEFT_BEND and RIGHT_BEND is starting at the head and looking towards the tail of the caterpillar, so the apparent bend direction in the GUI will depend on the orientation of the caterpillar head.
Figure 2: Labelled game screenshot
Each caterpillar has a defined head direction of UP, DOWN, RIGHT or LEFT (see Direction class).
Like direction, the position of the Caterpillars are defined relative to the position of their head (headPosition in Caterpillar class). Note that unlike the caterpillar head direction, the head position is only defined for when the caterpillar is located on the board.
The getPositions(Position virtualHead) method (see Task #7) in the Caterpillar class provides the integer positions of each Segment in a given Caterpillar object, relative to a provided “virtual head” position. Until you implement this method (and all previous tasks), the provided graphic user interface will have limited functionality.
Encoding the Game
This section explains how certain elements of the game are encoded into strings. While such an encoding is not necessary for designing software using object orientation, the encoding and decoding used in this assignment will be very similar to the work you will be doing in Assignment 2.
Initial State
The initial state of a challenge describes the configuration of the board and some constraints / requirements about where to put the caterpillar heads. It is encoded as five letters and or numbers of the board configuration concatenated with up to three sets of caterpillar head requirements.
Note: for the following sections notation [A|B] denotes a string: “A” or “B”.
Board configuration
The board configuration describes which side of each row of the board (red apple) is face up and is comprised of the following:
[A|1][B|2][C|3][D|4][E|5][F|6]
For example, the encoded board configuration “ABCDE” is shown in the image below:
Figure 3: Example board configuration
Caterpillar head requirements
Each caterpillar head constraint is encoded as a letter representing the colour of the caterpillar ([G|T|Y|X] for Green, Turqoise, Yelllow and Wildcard) followed by the x then y axis coordinate for that head constraint. For example, “T22” means that position(2,2) is constrained to be the head of the Turqoise caterpillar (see Figure 4).
Each challenge includes from zero up to three concatenated head constraints, for example “T22Y31X14” is the encoded head constraints string for Challenge 17 – see image below:
Figure 4: Challenge 17 with “1BCD5T22Y31X14” string encoding
Overall challenge string encoding
The challenges are encoded by concatenating the board configuration and head requirements encoding. For example the encoding for challenge 17 in Figure 4 above has a string encoding of “1BCD5T22Y31X14”.
Evaluation Criteria
The mark breakdown / evaluation criteria are described on the deliverables page.
As part of fulfilling the requirements outlined on the deliverables page, your job is to complete tasks #1 to #9 which are provided as gitlab issues. Task #1 is setup, Task #10 is and extension, neither are marked.
The tasks in the following categories are marked:
· Tasks #2, #3, #4
· Task #5, #6, #7
Challenging
· Task #8 and #9
IMPORTANT NOTE: Recall that the assignment is redeemable against the final exam so don’t stress if you are new to programming and not able to complete all the tasks at this stage.