Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this homework assignment, we will improve on the text-based game we started on in HW1. Players now have health bars and do certain amount

For this homework assignment, we will improve on the text-based game we started on in HW1.

Players now have health bars and do certain amount of damage (relative to health bars), as do monsters. For example, a player may have 5 health bars and do 2 health bars of damage each attack. (So, to kill another player given the EXAMPLE above, you would need 3 attacks).

NOTE: The algorithms (and functions for part 2) you are describing, UNLESS EXPLICITLY STATED, should NOT depend AT ALL on each other. They are separate entities that should always return what they say they will, if you provide the parameters you describe. They are dependent on input and ouput (DATA), NOT other algorithms/functions.

Part 1 (Due Friday, November 16)

Algorithms ONLY

Algorithm 1: Write an algorithm for a function that has the properties described below

Accepts at least 2 parameters

A size for the maze (maze should be square or NxN)

A value that will be used to determine whether or not to include monsters AND how many

Returns a complete maze (NxN string array) populated with at least 1 string P, E, 0 3 strings M, and the rest of the elements of the array should contain the string 0

The string P inserted into a random position in the maze array

The string E should be inserted into a random position in the maze array.

You MUSTuse some type of iterative construct to ensure that E is placed randomly (no offsets this week). That means that if your first random number lands on P, you HAVE TO randomly choose another position.

The string(s) M for monsters should be inserted into random positions in the maze array.

You MUSTuse some type of iterative construct to ensure that M is placed randomly (no offsets this week). That means that if your first random number lands on P or E OR M (another monster) you HAVE TO randomly choose another position.

You cant overwrite monsters this week.

If the monster parameter indicates that you should include 3 monsters, your maze MUST have 3 monsters in it.

Algorithm 2: Write an algorithm for a function that has the properties described below

Accepts at least 2 parameters

An NxN array of strings

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

Returns at least 3 things

An NxN array of strings

i.Given a maze in state X (parameter 1), returns a maze in state Y. Represents a SINGLE move.

A 1x2 array of numbers representing a players stats (health and damage)

A value used to represent whether or not the game is over (if the game has been won OR lost, then it is over).

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.

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

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

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

The first element should represent how much health the monster has

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

The player and the monster will take turns attacking each other until one of them has health <= 0. Player gets to attack first.

MUST use some iterative construct to simulate fight.

v.If the player guesses incorrectly

The player and the monster will take turns attacking each other until one of them has health <=0. Monster gets to attack first.

MUST use some iterative construct to simulate fight.

vi.If player wins the fight

display message indicating monster was defeated

set element that previously contained M to P

set previous player element to 0

set game_over variable accordingly

display new coordinates of player

Return 2d array (maze), game_over variable, and player

vii.If player loses fight

Set all maze elements to L

Display losing message

Set game_over variable accordingly

Return 2d array (maze), game_over variable, and player

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

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

More Books

Students also viewed these Databases questions