Mapa mental
Text-based Adventure Game: Part 1: Algorithm Challenge 2
Conteúdo do mapa
Text-based Adventure Game: Part 1: Algorithm Challenge 2
Criteria
- Context
- If the player talks to the baker he will give the player a loaf of bread. If the player eats the bread 1 health point is restored (up to a maximum health of 5).
- The player must be able to talk to the baker
- The baker must give the player a loaf of bread if talked to
- 1 health point must be restored if player eats bread
- The maximum health must be 5 health points
- If the player has 5 health points when eating bread, the health does not increase
- If the player talks to the baker he will give the player a loaf of bread. If the player eats the bread 1 health point is restored (up to a maximum health of 5).
- Task
- Write an algorithm that processes the player inputs in the table and returns the appropriate output message depending on the player location and contents in the player’s backpack.
- The algorithm must be a function (modularisation)
- The appropriate output must be displayed for the input
- The output must depend on the player's location
- The output must depend on the contents of the player's backpack/storage
- Write an algorithm that processes the player inputs in the table and returns the appropriate output message depending on the player location and contents in the player’s backpack.
- Context
Ideation/Processing
- Define function
- Name function as baker
- Include input data sets of (mapLoc, bakerMessage, backpackListLength, playerHealth, backpack, items)
- Eg. BEGIN bread (mapLoc, bakerMessage, backpackListLength, playerHealth, backpack, items)
- Include input data sets of (mapLoc, bakerMessage, backpackListLength, playerHealth, backpack, items)
- Name function as baker
- Define variables
- Number of items in backpack
- Eg. SET backpackListLength to number of items in backpack
- Responses to valid action
- Eg. SET bakerMessage = "You eat the bread."
- Possible items in backpack
- Eg. SET items[0] = "Bread"
- Location of bakery
- Eg. SET mapDesc[0] = "Bakery"
- Backpack variable
- Eg. backpack = []
- Number of items in backpack
- Selection of output depending on input
- Use of IF...THEN...ELSE statements
- Use conditions to regulate selection
- Eg. IF playerInput == "eat bread" AND backpacklistlength > 0 THEN ELIF playerInput == "eat bread" AND backpacklistlength NOT > 0 THEN
- Eg. IF playerInput == "talk to baker" AND mapLoc = 0 THEN ELIF playerInput == "talk to baker" AND mapLoc = 0 THEN
- Eg. IF playerInput == "eat bread" AND items[0] IN backpack THEN ELIF playerInput == "eat bread AND items[0] NOT IN backpack THEN
- Use conditions to regulate selection
- Account for user error
- Eg . ELSE PRINT "I do not understand."
- Use of IF...THEN...ELSE statements
- End
- End function
- END bread
- End IF...ELSE statement
- ENDIF
- End function
- Prescribe correct message for situation
- Eg. PRINT BakerMessgae[0]
- User receives the text "You eat the bread."
- Potential messages
- "You eat the bread."
- "You are not carrying the bread."
- "The baker gives you a loaf of bread."
- "The baker is not here."
- Eg. PRINT BakerMessgae[0]
- Error messages
- If the player types an invalid command
- Eg. "I don't understand. Please try another action."
- If the player types an invalid command
- Actions
- Interaction of items with backpack
- Eg. ADD items[0] TO backpack
- Eg. REMOVE items[0] TO backpack
- Interaction of items with backpack
- Define function
Input
- The player's current location on the map
- Variable name
- mapLoc[ ]
- Data type
- Integer
- Variable can range from 0 - 15 depending on the map location
- Integer
- Variable name
- The current contents of the player's backpack
- Variable name
- backpack[]
- Contains items[]
- backpacklistlength
- Index length of the backpack array
- backpack[]
- Data type
- Variable
- Eg. backpack[0] = items[4]
- Integer
- Eg. backpacklistlength = 4
- Variable
- Variable name
- The possible contents of the backpack
- Variable name
- items[]
- Data type
- String
- Eg. items[0] = "Bread"
- String
- Variable name
- The player's input
- Variable name
- playerInput
- Data type
- String
- Eg. playerInput == "eat bread"
- String
- Variable name
- The player's current health
- Variable name
- playerHealth
- Data type
- Integer
- Eg. 3
- Integer
- Variable name
- Error Messages
- Data type
- String
- Eg. "I don't understand."
- String
- Variable name
- errorMessages[]
- Data type
- Position of the bakery
- Variable name
- mapDesc[]
- Data type
- String
- Eg. mapDesc[0] = "Bakery"
- String
- Variable name
- The player's current location on the map
Output
- An array (list of statements) of responses to the input according to map location
- Variable name
- BakerMessage[]
- Data type
- String
- Eg. BakerMessage[0] = "You eat the bread"
- String
- Variable name
- Statement of health
- PRINT statement
- Text that is displayed to player
- Must change depending on the fullness of health
- Eg. "You gain 1 health point."
- Eg. "You gain no health points/are not hungry. To are already at maximum health."
- PRINT statement
- Error Messages
- Data type
- String
- PRINT statement
- Eg. "I don't understand. Please try another command."
- Data type
- An array (list of statements) of responses to the input according to map location
Constraints/Limitations
- See Text-based Adventure Game: Part 1: Algorithm Challenge 1
Available Resources
- See Text-Based Adventure Game: Part 1: Algorithm Challenge 1
Informações
- Descrição
- Year 11 Digital Solutions Mapa Mental sobre Text-based Adventure Game: Part 1: Algorithm Challenge 2, criado por Julia de Beer em 16-02-2021.
- Criado por
- Julia de Beer
- Visualizações
- 0
- Avaliação