Question: write a matlab function that fits the following 1) Accepts at least 2 parameters a. An NxN array of strings b. A 1x2 array of
write a matlab function that fits the following
1) Accepts at least 2 parameters
a. An NxN array of strings
b. A 1x2 array of numbers representing a players stats (health and damage)
i. The first element represents how much health the player has
ii. The second element represents how much damage the player can do with a
single attack
iii. You will potentially need to modify this in your algorithm if you fight a
monster
2) Returns at least 3 things
a. An NxN array of strings
i. Given a maze in state X (parameter 1), returns a maze in state Y.
Represents a SINGLE move.
b. A 1x2 array of numbers representing a players stats (health and damage)
c. A value used to represent whether or not the game is over (if the game has been
won OR lost, then it is over).
3) Your algorithm should move the player string P +-0,1 for both x and y coordinates of
current location of string P in the array.
a. If the new coordinates for P has the string E inside
i. Display winning message
ii. Set all array elements to W
iii. Set game_over variable accordingly
iv. Return 2d array (maze), game_over variable, and player
b. If the new coordinates for P has the string 0
i. Set new coordinates for P to P
ii. Set old coordinates for P to 0
iii. Display current coordinates
iv. Set game_over variable accordingly
v. Return 2d array (maze), game_over variable, and player
c. If the new coordinates for P has the string M inside
i. Generate a 1x2 array that will be used to represent the monsters health
and damage
1. The first element should represent how much health the monster
has
2. The second element should represent how much damage it can do
with a single attack
ii. Randomly roll some number
iii. Ask the player to guess the number
iv. If the player guesses the number correctly
1. The player and the monster will take turns attacking each other
until one of them has health <= 0. Player gets to attack first.
2. MUST use some iterative construct to simulate fight.
v. If the player guesses incorrectly
1. The player and the monster will take turns attacking each other
until one of them has health <=0. Monster gets to attack first.
2. MUST use some iterative construct to simulate fight.
vi. If player wins the fight
1. display message indicating monster was defeated
2. set element that previously contained M to P
3. set previous player element to 0
4. set game_over variable accordingly
5. display new coordinates of player
6. Return 2d array (maze), game_over variable, and player
vii. If player loses fight
1. Set all maze elements to L
2. Display losing message
3. Set game_over variable accordingly
4. Return 2d array (maze), game_over variable, and player
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
