Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

TREASURE HUNTER A treasure hunter is trying to find diamonds in a 10x10 field. Each diamond is guarded by a soldier. The aim of the

TREASURE HUNTER
A treasure hunter is trying to find diamonds in a 10x10 field. Each diamond is guarded by a soldier. The aim of the hunter is to collect the diamonds without being caught by the soldiers.
Rules and Constraints;
Row and column indices on the game board start from 0.
The hunter's starting position on the board is fixed. So the hunter's position every time the game starts
It will be (2,4).
There are 5 diamonds on the field and these diamonds must be placed in random cells when the game first starts. The player will not see the diamonds on the board. While diamonds are randomly assigned to cells, it should be prevented that more than one diamond coincide with the same cell. (You can use the rand() function to determine a random position).
Every diamond has a guardian. This guard will be randomly placed in one of the cells adjacent to the diamond. Even if 2 diamonds are
randomly placed on adjacent positions on the board, they will each have a separate guardian and a guardian cannot be in the same cell with another guardian or diamond. (So overlapping should be avoided)
What the player has to do is move on the board using the right, left, up and down keys and find the cell with the diamond without being caught by the guard. The player cannot go diagonally.
Each time the player takes a step, the distance of each diamond on the board relative to the player's current position should be informed to the user. Here, the distance is the minimum number of steps it takes to reach the corresponding diamond. To calculate this, you must subtract the diamond's position from the player's current position at each step. For example, if the position of the diamond is (0,2) and the position of the player is (2,4), then the distance of this diamond to the player is |2-0|+|4-2|=4. (You should take the absolute value to avoid getting a negative distance in this subtraction step). That means the player can reach this diamond with 4 steps.
If the player hits the guard, he returns to the starting position (2,4) as a penalty. It can come across as a guard up to 3 times. If he hits the guard again the 4th time, he loses the game. (So it has 3 lives.)
A single user will play the game. In other words, you will choose which direction the hunter will advance with the arrow keys during the game. Therefore, the locations of the diamonds and guards will be randomly determined when the game first starts, and the player must not see their location. However, he can decide where to go with the distance information to the diamonds at every step.
After each step of the hunter, information about the game board and the location of the diamonds should be printed on the screen. (Diamonds and guards will not be visible in this printed chart.)
Diamonds or guards cannot be outside the game board. The hunter cannot leave the game board.
Images on the board are for animation only. You do not need to create such an image on your game board. Instead, you can encode each group with a symbol. For example, E for diamonds, M for guards.
The project will be coded in C language.
EXAMPLES:
When the game first starts, the position of the diamonds and guards should be as on the board above. However, the board to be pressed to the user should be the board that only shows the current status of the player as follows. (It is a matrix image you need to provide for the board you will be printing on the screen. It is not necessary to have lines here.)
The positions of the diamonds were: (0.2), (4.1), (8.3), (8.7), (1.8), respectively. (These locations are randomly assigned. It should be different when you close the game and run it again. And the user who is playing the game will not see and know this information.)
Let the player step to the left. In this case, the game board should be pressed to the screen to show only the player's position.
The information that should be automatically calculated and printed on the screen after each step is as follows;
1. Distance to diamond: 3, 2. Distance to diamond: 4, 3. Distance to diamond: 6,
4. Distance to diamond: 10, 5. Distance to diamond: 6
These distances are obtained by subtracting the position of the hunter after the step, from
the position of the diamonds. Therefore, the positions of the diamonds need to be hidden from the user.
Let's step up in step 2. He was caught because he was a guard in an upper cell. In this case, his health, which was 3 at the beginning, drops to 2 and returns to the point where he started, that is, cell (2,4). You are back to the beginning because you were caught by the 'guard. A warning is given as "Your remaining life is 2".

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David J. Auer David M. Kroenke

13th Edition

B01366W6DS, 978-0133058352

More Books

Students also viewed these Databases questions

Question

Discuss compensation for sales representatives.

Answered: 1 week ago