image.png
If the user inputs an invalid command your program must output:
No menu item
Level File
The level file will contain data related to the game such as the planet’s dimensions, name, rover placement and attributes and tile information.
The format of the file follows:
[planet]
name,
[tiles]
[,]
The number of tiles is based on the dimensions of the planet. For ple, if the width is 6 and the height is 5, the number of tiles listed should be strictly 30.
A level file is considered correctly structured if:
• There is exactly 4 fields specified under the planet section and the number of tiles match the dimensions of the planet.
• The rover’s coordinates specified are greater than or equal to 0.
• The rover’s coordinates must be within the bounds of the planet’s dimensions.
• Both width and height values need to be greater than or equal to 5.
• highest elevation is strictly greater than lowest elevation for a tile. An segment of a correctly structured level file:
[planet] name,pluto width,5 height,5 rover,1,0
[tiles] plains,0 shaded,0 plains,1 shaded,0,-1
The tiles are arranged in row-major order. You must insert your tiles from top-down, left-to-right. A rule to remember for placing the rover: x corresponds to the row index while y corresponds to the column index. As an ple:
[tiles]
Corresponds
to:
A
|A|B|
B
|C|D|
C
D
Your program must be able to support loading any level file that uses this format. However, your program needs to detect if level file is correct. To detect if the level file is correct, it will need both segments for planet and tiles.
You will be provided some demo levels for you to use while testing but it is advised that you write your own test levels or a script that generates your own test levels.
Planet
The planet is defined as a two dimensional grid of terrain tiles. All tiles are square-shaped and of unit length. Each tile will have different data as outlined in the Tile section.
Planets are spherical and not flat. This means the left-most column of the grid should "meet up" with the right-most column. Similarly, the top-most row should meet up with the bottom-most.
You will need to design your program which allows for navigation on the planet and keep track of what tile the rover is on. The planet has the following properties:
• Width.
• Height.
• Tiles (Must contain width ∗ height number of tiles) with tile attributes that will affect the rover.
You are free to add additional properties for your Planet class.
Tiles
A planet is made of up many individual terrain tiles and each tile has the following properties:
• Elevation relative from 0 (can be negative or positive).
• Effect: Each tile will have its own effect on the rover. This will be described in the following section Terrain and slope.
Terrain and slope
Terrain is an attribute of a tile. There are two allowed types of terrain:
Terrain types
• " " – Unshaded Plains (exposed to sunlight), plains.
• "#" – Shaded Plains, shaded.
Elevation effect
• "+" – Elevated tile relative to the rover.
• "-" – Descended tile relative to the rover.
Tiles that are described by 2 elevation values are sloped. This will allow the rover to move up or down elevation between the two given elevation values provided. The slope will only have a difference of 1 between the highest and lowest ( highest − lowest ).
• "\" – Down slope, allows for movement to lower level.
• "/" – Up slope, allows for movement to upper level.
As an ple: shaded,0,-1
If the rover has an elevation of -1, the tile would appear as an up slope. This allows the rover to access tiles with elevation of 0.
If the rover has an elevation of 0, the tile would appear as an down slope This allows the rover to access tiles with elevation of -1.
Rover
The rover is the object that the player controls during the game. It is represented with the H symbol when it scans the area around it and must occupy a terrain tile at any given time.
• In the level file, the line rover, indicates the rover’s starting position. For ple,
rover,1,0 means that the rover starts at (x, y) coordinates (1, 0).
• Current coordinates (x, y).
• Battery charge, maximum charge is 100 and always starts with a charge of 100.
• Number of tiles it has explored.
The rover will move around on the planet’s surface, being able to explore different parts of the terrain. The objective for the rover is to explore the entire surface, once the rover has explored the entire planet or runs out of power, the player can type the FINISH command (specified in the following section) to finish the game and output how much they explored of the planet.
You explored {percentage} % of {planet}
Battery
The rover will lose power when moving around shaded areas. Every time it moves to a shaded tile, it will decrease the battery charge by 1. The battery charge stays the same while the rover moves on unshaded tiles. If the rover waits on an unshaded tile, it will recharge.