Question

Choose Ultrakarel as your starting point. World #1 RESET II » RUN World: Dog Maze1 Instructions: Write an algorithm that help please help with the code that would solve this
0 0
Add a comment Improve this question Transcribed image text
Answer #1

There are many ways to solve a maze, here we are going to consider the maze as a 2 dimensional array of values.

in our maze we can consider it as a 10x10 matrix.. (see the no. of dots vertically and horizontally).. let us consider 10 as the height of the maze and the other 10 as the width of the maze. now for each position we will assign a value. By doing that we will come to know the starting point the ending point,the ways that are blocked by walls,and the route taken.

so, it can be explained in simple steps:

step 1: enter the starting position.(in our case it is 0x0)

step 2: enter the end position..(in our case it is 10X10)

step 3: the row will increment , if the current position is not on a wall, the function will check other possible values for further movement,if such a value is not already visited it will follow that path, else if it is visited it will backtrack,visited positions are stored

step 4: if the current position is on the wall,then also it will do backtracking,

step 5: all above steps are repeated till it reaches the end position.

Algorithm:

int dog_maze[][] = new dog_maze[w][h];//we enter the maze in matrix

int x1,y1 //starting position

int x2,y2// end position

boolean[][] already_visited=boolean[w][h];// as i said already there will be a visited set

boolean[][] solution=boolean[w][h]// after reaching end position path is saved.

void help_dog()//function for solving the puzzle

{

dog_maze = createmaze()

for(row 0 to length)

for(column 0 to length)

already_visited[row][coloumn]=false;

solution[row][coloumn]=false;

}

public boolean tracking(int a, int b)

{

if(a==x2&&b==y2)//end position

return true;

if(dog_maze==2||already_visited)

return false;

already_visited=true;

if(a!=0)

if(help_dog(a-1,b))

{

solution[a][b]=true;

return true;

}

if(a!=w-1)

if(help_dog(a+1,b))

{

help_dog[a][b]=true;

return true;

}

if(b!=0)

if(help_dog(a,b-1))

{

solution[a][b]=true

}
}

now this function gets repeated till the end node is visited...

Add a comment
Know the answer?
Add Answer to:
please help with the code that would solve this Choose Ultrakarel as your starting point. World #1 RESET II » RUN Wo...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PLEASE HELP!!! C PROGRAMMING CODE!!! Please solve these functions using the prototypes provided. At the end...

    PLEASE HELP!!! C PROGRAMMING CODE!!! Please solve these functions using the prototypes provided. At the end please include a main function that tests the functions that will go into a separate driver file. Prototypes int R_get_int (void); int R_pow void R Jarvis int start); void R_fill_array(int arrayll, int len); void R_prt_array (int arrayl, int len) void R-copy-back (int from[], int to [], int len); int R_count_num (int num, int arrayll, int len) (int base, int ex) 3. Build and run...

  • You need not run Python programs on a computer in solving the following problems. Place your...

    You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...

  • Code is in C# Your instructor would like to thank to Marty Stepp and Hélène Martin...

    Code is in C# Your instructor would like to thank to Marty Stepp and Hélène Martin at the University of Washington, Seattle, who originally wrote this assignment (for their CSE 142, in Java) This program focuses on classes and objects. Turn in two files named Birthday.cs and Date.cs. You will also need the support file Date.dll; it is contained in the starter project for this assignment. The assignment has two parts: a client program that uses Date objects, and a...

  • C++ please Programming Assignment #6 Help Me Find The Secret Message Description: This assignment will require...

    C++ please Programming Assignment #6 Help Me Find The Secret Message Description: This assignment will require that you read in an encrypted message from a file, decode the message, and then output the message to a file. The encryption method being used on the file is called a shift cipher (Info Here). I will provide you with a sample encrypted message, the offset, and the decrypted message for testing. For this project I will provide you main.cpp, ShiftCipher.h, and ShiftCipher.cpp....

  • Edit a C program based on the surface code(which is after the question's instruction.) that will...

    Edit a C program based on the surface code(which is after the question's instruction.) that will implement a customer waiting list that might be used by a restaurant. Use the base code to finish the project. When people want to be seated in the restaurant, they give their name and group size to the host/hostess and then wait until those in front of them have been seated. The program must use a linked list to implement the queue-like data structure....

  • Hello! Could you please write your own four paragraph (5-6 sentences per paragraph) take away or...

    Hello! Could you please write your own four paragraph (5-6 sentences per paragraph) take away or reflection of the below information? Please complete in 24 hours if possible. Thank you! RIS BOHNET THINKS firms are wasting their money on diversity training. The problem is, most programs just don’t work. Rather than run more workshops or try to eradicate the biases that cause discrimination, she says, companies need to redesign their processes to prevent biased choices in the first place. Bohnet...

  • I need help with my very last assignment of this term PLEASE!!, and here are the instructions: After reading Chapter T...

    I need help with my very last assignment of this term PLEASE!!, and here are the instructions: After reading Chapter Two, “Keys to Successful IT Governance,” from Roger Kroft and Guy Scalzi’s book entitled, IT Governance in Hospitals and Health Systems, please refer to the following assignment instructions below. This chapter consists of interviews with executives identifying mistakes that are made when governing healthcare information technology (IT). The chapter is broken down into subheadings listing areas of importance to understand...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT