2965 - CS2351_DS_24Spring_HW1 Scoreboard

Time

2024/03/11 12:00:00 2024/03/31 23:59:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
14241 Gold Miner

14241 - Gold Miner   

Description

Introduction:

"Gold Miner" is a classic arcade-style game that gained popularity in the late 1990s and early 2000s. It's a simple yet addictive game where players take on the role of a miner on a quest to collect valuable resources such as gold, diamonds, and gems from deep underground.

This homework is inspired by the “Gold Miner” game, but the rules and mechanics are different from the original game.

Students need to implement an internal monitor system tracking the player’s bag and the items’ positions. The game logic is modified to make sure the problem can be solved with C/C++ programming and understanding of stack and queue.

Problem Detail:

In this homework, a miner can dig into the ground and find valuable items. There are 7 types of items as listed below. The items will be placed in a grid, their positions along with their types will be specified in the input

  1. D (Diamond)
  2. G (Gold)
  3. B (Bomb)
  4. F (Flashlight)
  5. M (Magnet)
  6. C (Lucky Clover)
  7. P (Pig)

The player’s actions (dig or use items) will also be specified in the input. For the output, students need to print out the order of DIAMOND and GOLD which the player collects from first to last, and also print the remaining items’ location after the player's actions.

 

A player can either DIG or USE at any move. The player uses DIG to dig up the item that is closest to the player (top) in a column:

  1. If that item is either Diamond or Gold, it will be added to the player’s loot. Player’s loot will be empty at the beginning of the game.
  2. If that item is either Flashlight, Magnet, it will be added to the player’s inventory which can be used later. Players do not have any special items at the beginning of the game. Once a player earns some special items, the player can use them one by one in the same order as they are collected, which means the player cannot decide which items to be used first.
  3. If that item is a Bomb, Lucky Clover or Pig, it won’t be added to the player’s bag or inventory. Instead, it will have a special effect either on the map or on the player's bag.

Note that, if the player digs into a column that is empty, nothing will happen.

Items that can be used

  • Flashlight: it allows the player to check the highest level of all the columns that contains at least 1 item and see the type of the item located at that level in every single column. If there are no items on the map, you can simply print an underscore “_” for each column at level 1. Example on what to print if map is empty: "MINE LEVEL:1\n_ _ _ _ _ _ \n" 

  • Magnet: it allows the player to collect the item at the top of each column. Straightforwardly, using a magnet equals the DIG action to all the columns on the map, each DIG for each column. The smallest numbered column will be dug first. If Bomb, Lucky Clover, or Pig is dug, the special effect will take place immediately.

INPUT: USE

No description available.

Items that cannot be used:

  • Diamond: nothing special happen, it will be added to player’s bag
  • Gold: nothing special happen, it will be added to player’s bag

 

  • Bomb: it will destroy the items in the surrounding 8 grids

Input: DIG 2

  • Lucky Clover: if a Lucky Clover is dug up at column numbered x, after it is dug up, at columns x-2 to x+2 will generate three new items that share the same type with the top item in their loot (either GOLD or DIAMOND). If x < 0 or x is larger than the maximum column number in the mine map, ignore the column. Let the maximum level that at least 1 item exists in these 5 columns be t, the 3 new items will be placed at level t+1, t+2, t+3 for each column. If the loot/map is empty, simply ignore this turn.

Input: DIG 3

  • Pig: if a Pig is dug up,it will steal all the most recently dug up GOLDs that precedes the first DIAMOND in your loot. If the most recent dug up is a DIAMOND, no effect, if no DIAMOND is in your, all GOLD will be stolen

Input: DIG 4

Update 11/03 22:45 Reworded rule number 4 & 5 in output.

Update 13/03 16:34 Reupload the photo example after using MAGNET.

Update 13/03 17:26 Added clarification on CLOVER.

Update 18/03 22:16 Give explicit example on format for Flashlight usage when map is empty. Reworded the print format of bag and map when empty.

Input

The first line contains three integers:

  1. Integer R representing the number of columns on the map, (0 ≤ R ≤ 100; R ∈ N)
  2. Integer L representing the maximum number of items might exists in each column in the initial state (0 ≤ L ≤ 100; L ∈ N)
  3. Integer representing the number of actions the player will do (0 ≤ N ≤ 100; N ∈ N)

Starting from the second line, there are L lines each containing R characters. The R characters in each line are separated by a space between each of them, each character represents an item and its type (Diamond, Gold, Bomb, Flashlight, Magnet, Lucky Clover, Pig). Overall, in the initial state of the game, there will be at most RxL items on the map. The empty space in the grid of the stage that doesn't contain any item will be represented by a “_”.

Following the L lines will be N lines, each representing the action the player will take. Each of these N lines starts with an action string Ai. Ai will be only one of two available actions: DIG or USE.

          If Ai is DIG, it means the player wants to dig into one of the columns. Ai is followed by a space and an integer Si which indicates the column that the player is digging. If Si is not a valid column, simply skip this turn.

          If Ai is USE, it means the player wants to use one item in their bag. Remember that the player can only use the items in the same order as they are collected. If the player doesn't have any items, simply skip this turn. There is no more following input in the same line.

Output

  1. If the player uses DIG, there is no need to print anything.
     
  2. If the player uses USE, and the item is Magnet, there is no need to print anything.
     
  3. If the player uses USE, and the item is Flashlight, you need to print the string “MINE LEVEL:” followed by an integer Lf which represents the topmost level that contains at least 1 item. Finish the line with a new line symbol.
    • In the next line, print the type of the item at the level Lf in each column. Separate each item by a space. If there isn't an item existing at the level Lf for some columns, print an underline “_” to fill the empty slot. Print a new line symbol at the end of the line. If there are no items on the map, you can simply print an underscore “_” for each column at level 1
       
  4. After all N movements are done, you need to print a string “FINAL BAG:”, followed by a new line symbol.
    • In the next line, you need to print the order in which GOLD and DIAMOND are collected, starting from the first item. Each item will be separated by a space, and for the last item, after space will be a new line symbol. If the bag is empty, print another new line. Example if empty: "FINAL BAG:\n\n"
       
  5. After printing all the items in the loot, you need to print a string “FINAL MAP:”, followed by a new line symbol.
    • Starting from the next line, print the positions and types for each item level by level. You need to print every level from level 1 to the max level that contains at least 1 item (basically you ignore the higher levels that are empty on all columns, Example: Level 3 is empty so you print only level 1 and 2. As for the lower level that is empty when there's a higher level that still has item, Example: Level 1 and 2 is empty, but Level 3 got item, then still print them out). Separate each item from the same level by a space and separate each level by a new line symbol (after the last item with a space). Print an underline “_” to fill the empty slot if no item exists at some places. If there are not any items existing on the stage (whole map), you just need to print a newline after "FINAL MAP:". However, if there is an empty level between two levels that are not empty, just print them like normal. Example if map is empty: "FINAL MAP:\n"

Sample Input  Download

Sample Output  Download

Tags




Discuss