Question: How to implement the following Algorithm in C programming: description below To implement you will need an array of rooms and an 8021 matrix of
How to implement the following Algorithm in C programming:
description below
To implement you will need an array of rooms and an 8021 matrix of cells representing the dungeon. I initialize the dungeon by setting an immutable flag on the outermost cells and assigning a hardness to the material in every cell. I then attempt to randomly place random rooms in the available space, checking that the room can be placed legally each time until some termination criterion is reached. Example criteria: the dungeon is at least 7% open (not rock); there were 2000 failed placement attempts in a row; a create new room() predicate failed; etc. After placing rooms, move through the room array of n rooms, connecting room 1 with room 2, then room 3 with rooms 12, . . . until youve connected room n with rooms 1(n 1). Okay, so how do we make that connection? Find the closest room in the already connected set using Euclidean distance to its centroid then carve a path to it by changing rock to open space; this can always be done with zero or one change of direction.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
