Question: please provide full implementation for functions Provided Functions: - - - - - - - - - - - - - - - - -

please provide full implementation for functions
Provided Functions:
-----------------------------------------
Wall.h:
// Interface to the Wall ADT
//!!! DO NOT MODIFY THIS FILE !!!
#ifndef WALL_H
#define WALL_H
typedef struct wall *Wall;
// Rock colours
#define NUM_COLOURS 4
// enums are used to create groups of related constants. It is like
// creating multiple #defines, except you can also provide a type name.
typedef enum {
NONE =-1,
GREEN =0,
TEAL =1,
PINK =2,
RED =3,
} Colour;
// Terminal output colours
#define GRN "\x1B[32m"
#define CYN "\x1B[96m"
#define MAG "\x1B[95m"
#define RD "\x1B[91m"
#define RESET "\x1B[0m"
struct rock {
int row;
int col;
Colour colour;
};
/**
* Creates a new blank wall with the given dimensions
*/
Wall WallNew(int height, int width);
/**
* Frees all memory allocated to the wall
*/
void WallFree(Wall w);
/**
* Returns the height of the wall
*/
int WallHeight(Wall w);
/**
* Returns the width of the wall
*/
int WallWidth(Wall w);
/**
* Adds a rock to the wall
* If there is already a rock at the given coordinates, replaces it
*/
void WallAddRock(Wall w, struct rock rock);
/**
* Returns the number of rocks on the wall
*/
int WallNumRocks(Wall w);
/**
* Returns the colour of the rock at the given coordinates, or NONE if
* there is no rock at those coordinates.
*/
Colour WallGetRockColour(Wall w, int row, int col);
/**
* Stores all rocks on the wall in the given `rocks` array and returns
* the number of rocks stored. Assumes that the array is at least as
* large as the number of rocks on the wall.
*/
int WallGetAllRocks(Wall w, struct rock rocks[]);
/**
* Stores all rocks that are within a distance of `dist` from the given
* coordinates in the given `rocks` array and returns the number of rocks
* stored. Assumes that the array is at least as large as the number of
* rocks on the wall.
*/
int WallGetRocksInRange(Wall w, int row, int col, int dist,
struct rock rocks[]);
/**
* Stores all rocks with the colour `colour` that are within a distance
* of `dist` from the given coordinates in the given `rocks` array and
* returns the number of rocks stored. Assumes that the array is at
* least as large as the number of rocks on the wall.
*/
int WallGetColouredRocksInRange(Wall w, int row, int col, int dist,
Colour colour, struct rock rocks[]);
/**
* Prints the wall out in a nice format
*/
void WallPrint(Wall w);
#endif
-------------------------------------------
climber.h:
// Interface to boulder climbing algorithms
//!!! DO NOT MODIFY THIS FILE !!!
#ifndef CLIMBER_H
#define CLIMBER_H
#include "Wall.h"
struct path {
int numRocks;
struct rock *rocks;
};
struct path findShortestPath(Wall w, int reach, Colour colour);
struct path findMinEnergyPath(Wall w, int reach, int energyCosts[NUM_COLOURS]);
struct path findMinTurnsPath(Wall w, int reach, int energyCosts[NUM_COLOURS],
int maxEnergy);
#-----------------------------------------------
climber.c:
endif
// Implementation of boulder climbing algorithms
#include
#include
#include
#include
#include
#include
#include "climber.h"
#include "Wall.h"
struct path findShortestPath(Wall w, int reach, Colour colour){
// TODO - Task 2
struct path p ={0, NULL};
return p;
}
struct path findMinEnergyPath(Wall w, int reach, int energyCosts[NUM_COLOURS]){
// TODO - Task 3
struct path p ={0, NULL};
return p;
}
struct path findMinTurnsPath(Wall w, int reach, int energyCosts[NUM_COLOURS],
int maxEnergy){
// TODO - Task 4
struct path p ={0, NULL};
return p;
}
----------------------------------------
We are allowed to create extra .c and .h files such as graph.c or graph.h for any extra functions/structs we need to implement the task functions.
Please provide a solution that includes the full implementation of these functions please
Implementing findShortestPath Function:-
This function aims to find the shortest path to reach a certain distance on the climbing wall.
To implement it, we can use graph traversal algorithms such as Breadth-First Search (BFS) or Dijkstra's algorithm.
We'll start from the start position and explore neighboring rocks until we reach the desired reach or exhaust all reachable rocks.
Implementing findMinEnergyPath Function:-
This function aims to find the path with the minimum energy cost to reach a certain distance on the climbing wall.
We'll likely need to modify Dijkstra's algorithm to consider energy costs associated with each color.
We'll maintain a priority queue to explore paths with minimum energy cost first.
Implementing findMinTurnsPath Function:-
This function aims to find the path with the minimum number of color changes (turns) to reach a certain distance on the climbing wall.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!