I need help with my C programing Problem Part 1A Develop the

I need help with my C programing.

Problem:

Part 1A: Develop the Maze

You will generate a random maze of characters in a two dimensional array. This will be the same maze that you output to the screen. Using good modular programming techniques, generate the maze and display it on the screen.

The rand() function in stdlib.h will be very useful, as it will return a new random int every time it is called that is from 0 to a very large number. HINT: Taking rand\'s output % 100 may be useful.

To allow for differing levels of difficulty, your code will be given a difficulty value of 0-100 on the command line. This difficulty is the probability in percent that a given space of the maze will be an obstacle. Hence, difficulty zero indicates a blank maze while 50 indicates that roughly half of the characters will be blank.

Part 1B: Character Movement

The second part of the state is the avatar\'s position. In the sample code provided, we have included a function that lets you write to a character to a specific x,y position on the screen. Be sure to use this function (draw_character). DO NOT MODIFY THIS FUNCTION.   In a loop, you will make the character begin at the top center of the screen and move downward every so often. Note that if you do this without a delay, the program will complete so fast that you can barely see the avatar move.

Code so far:

Thank you!

To add delay, remember that if the -t option is given to ds4rd.exe, the first argument is the time in milliseconds since the executable starts. Use this data to wait some number of milliseconds (a delay for you to determine), and then implement the avatar moving down the screen with the delay. You may wish to keep track of a moving average of the gryroscope as well here so that you can use them to control the avatar next week.home / study / engineering / computer science / questions and answers / i need help with my c programing. problem: part ...

Question: I need help with my C programing. Problem: Part 1A...

Bookmark

I need help with my C programing.

Problem:

Part 1A: Develop the Maze

You will generate a random maze of characters in a two dimensional array. This will be the same maze that you output to the screen. Using good modular programming techniques, generate the maze and display it on the screen.

The rand() function in stdlib.h will be very useful, as it will return a new random int every time it is called that is from 0 to a very large number. HINT: Taking rand\'s output % 100 may be useful.

To allow for differing levels of difficulty, your code will be given a difficulty value of 0-100 on the command line. This difficulty is the probability in percent that a given space of the maze will be an obstacle. Hence, difficulty zero indicates a blank maze while 50 indicates that roughly half of the characters will be blank.

Part 1B: Character Movement

The second part of the state is the avatar\'s position. In the sample code provided, we have included a function that lets you write to a character to a specific x,y position on the screen. Be sure to use this function (draw_character). DO NOT MODIFY THIS FUNCTION.   In a loop, you will make the character begin at the top center of the screen and move downward every so often. Note that if you do this without a delay, the program will complete so fast that you can barely see the avatar move.

To add delay, remember that if the -t option is given to ds4rd.exe, the first argument is the time in milliseconds since the executable starts. Use this data to wait some number of milliseconds (a delay for you to determine), and then implement the avatar moving down the screen with the delay. You may wish to keep track of a moving average of the gryroscope as well here so that you can use them to control the avatar next week.

Part 2A:

On the final page is a finite state machine for the event loop process. Think of it as a flow chart where on the arrowed lines, there is a condition that must be met to move forward. This will help you think through your logic for your event loop.

Manually step through the diagram. For each of the conditions (labels on the lines), consider how you will check each in your code.

In your final code, you must comment each point where one of these conditions is checked by adding a relevant label. For instance, where you check to see if the player has won there should be //Did we win? .

Code so far:

Thank you!

Solution

#include<stdio.h>

//the total Maze size

#define N 8

bool answerMazeUtility(int maze[N][N], int x, int y, int sol[N][N]);

/* This is a function to print solution matrix solution[N][N] */

void printSolution(int solution[N][N])

{

    for (int i = 0; i < N; i++)

    {

        for (int j = 0; j < N; j++)

            printf(\" %d \", solution[i][j]);

        printf(\"\ \");

    }

}

/* This is a utility function to check if x,y is valid index for N*N maze */

bool checkSafe(int maze[N][N], int x, int y)

{

    // if (x,y outside maze) return false

    if(x >= 0 && x < N && y >= 0 && y < N && maze[x][y] == 1)

        return true;

    return false;

}

// to find an answer to the maze problem

bool answerMaze(int maze[N][N])

{

    int solution[N][N] = { {0, 0, 0, 0},

        {0, 0, 0, 0},

        {0, 0, 0, 0},

        {0, 0, 0, 0}

    };

    if(answerMazeUtility(maze, 0, 0, solution) == false)

    {

        printf(\"The Solution doesn\'t exist\");

        return false;

    }

    printSolution(solution);

    return true;

}

/*This is a recursive utility function to solve Maze problem */

bool answerMazeUtility(int maze[N][N], int x, int y, int solution[N][N])

{

    // if (x,y is goal) return true

    if(x == N-1 && y == N-1)

    {

        sol[x][y] = 1;

        return true;

    }

    // Check if maze[x][y] is valid

    if(checkSafe(maze, x, y) == true)

    {

        // mark x,y as part of solution path

        sol[x][y] = 1;

        /*This will help to move in forward in x direction */

        if (answerMazeUtility(maze, x+1, y, solution) == true)

            return true;

        /* Now If by moving in x direction doesn\'t give solution then

           Move down in y direction */

        if (answerMazeUtility(maze, x, y+1, solution) == true)

            return true;

        /* Finally,if none of the above movements work then BACKTRACK:

            unmark x,y as part of solution path */

        solution[x][y] = 0;

        return false;

    }  

    return false;

}

// This is the driver program to test above function

int main()

{

    int createmaze[N][N] = { {1, 0, 0, 0},

        {1, 1, 0, 1},

        {0, 1, 0, 0},

        {1, 1, 1, 1}

{1, 0, 1, 1},

{1, 1, 0, 1},

{0, 1, 1, 1},

{1, 1, 1, 0}

    };

    answerMaze(createmaze);

    return 0;

}

I need help with my C programing. Problem: Part 1A: Develop the Maze You will generate a random maze of characters in a two dimensional array. This will be the
I need help with my C programing. Problem: Part 1A: Develop the Maze You will generate a random maze of characters in a two dimensional array. This will be the
I need help with my C programing. Problem: Part 1A: Develop the Maze You will generate a random maze of characters in a two dimensional array. This will be the
I need help with my C programing. Problem: Part 1A: Develop the Maze You will generate a random maze of characters in a two dimensional array. This will be the

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site