hello everyone, i'd like some help with a program i have to solve..i must make a program which solves a maze by using the "right-hand rule" solving method...
they've asked me to make the maze in a 2-dimentions array and make and use 5 functions:
void moveforward( );
void turnright( ); /*turns right WITHOUT moving*/
void turnleft( ); /*turns left WITHOUT moving*/
int isfacingwall( ); /*TRUE if he faces a wall*/
int isoutside( ); /*TRUE if he has escaped the maze*/

the initial maze should be like this:

011001
000011
011001
100001
001100
100000

and the escape path should be like this:

011881
000811
011881
100081
001188
100008

please, if someone has any ideas let me know!!

thank you:)

• What is your problem exactly?

The question makes sence to me, have a go at it and tell us where you are going wrong.

Just don't expect people to do your homework for you.
• : hello everyone, i'd like some help with a program i have to solve..i must make a program which solves a maze by using the "right-hand rule" solving method...
: they've asked me to make the maze in a 2-dimentions array and make and use 5 functions:
: void moveforward( );
: void turnright( ); /*turns right WITHOUT moving*/
: void turnleft( ); /*turns left WITHOUT moving*/
: int isfacingwall( ); /*TRUE if he faces a wall*/
: int isoutside( ); /*TRUE if he has escaped the maze*/
:
: the initial maze should be like this:
:
: 011001
: 000011
: 011001
: 100001
: 001100
: 100000
:
: and the escape path should be like this:
:
: 011881
: 000811
: 011881
: 100081
: 001188
: 100008
:
: please, if someone has any ideas let me know!!
:
: thank you:)
:
it looks to me like from left to right:
outside, facewall, left, right, forward, back

is that right??
I further assume:
1 is a choice
8 is a action

can you clear this up; i hate to assume?
• : hello everyone, i'd like some help with a program i have to solve..i must make a program which solves a maze by using the "right-hand rule" solving method...
: they've asked me to make the maze in a 2-dimentions array and make and use 5 functions:
: void moveforward( );
: void turnright( ); /*turns right WITHOUT moving*/
: void turnleft( ); /*turns left WITHOUT moving*/
: int isfacingwall( ); /*TRUE if he faces a wall*/
: int isoutside( ); /*TRUE if he has escaped the maze*/
:
: the initial maze should be like this:
:
: 011001
: 000011
: 011001
: 100001
: 001100
: 100000
:
: and the escape path should be like this:
:
: 011881
: 000811
: 011881
: 100081
: 001188
: 100008
:
: please, if someone has any ideas let me know!!
:
: thank you:)
:
Just cause I'm feel like it, here is something to get you started.
This is not complete (obviously) and you will need to verify syntax.
[code]
void moveforward( );
void turnright( ); /*turns right WITHOUT moving*/
void turnleft( ); /*turns left WITHOUT moving*/
int isfacingwall( ); /*TRUE if he faces a wall*/
int isoutside( ); /*TRUE if he has escaped the maze*/

int currentDirection; // what direction it is currently facing
int currentLocation[1][1] = {04}; // hold current positionin maze
int maze[6][6] = {011001
000011
011001
100001
001100
100000};

int main()
{
while (!isoutside())
{
if (!isfacingwall() /* && NOT VISITED NEXT LOCATION YET)
{
moveforward();
// Add code to mark location as visited (8?)
continue;
}
else
{
// Add code to determine direction to turn in
continue;
}
}
}

void moveforward( )
{
// after verifying we are not facing a wall
}
void turnright( )
{
// add code to turn right WITHOUT moving
}

void turnleft( )
{
//add code to turn left WITHOUT moving
}

int isfacingwall( )
{
int returnValue = 0;
//determine if a wall is in the current facing direction
return returnValue;
}
int isoutside( )
{
int returnValue = 0;
// determine if we are about to exit the maze
return returnValue;
}
[/code]
• ok guys, sorry for my previous post:)

the functions i made are these ones:

int isfacingwall(int a[][cols],int i,int j)
{
if(a[i][j]==1)
return 1;
else
return 0;
}

void printarray (int a[][cols],int size)
{
int i,j;
for(i=0;i=0 && x=0 && y<cols))
return 1;
else
return 0;
}

int isoutside(int x, int y)
{
if(x==finish_x && y==finish_y)
return 1;
else
return 0;
}

my problem is to develop the algorithm of the right hand rule in c code..if you have any ideas pls let me know:)

thanks
• Try something like this (I'll let you figure out the syntax :-)) :
[code]bool Move (current location)
If atGoal return true;

TurnRight
for (int x = 0; x < 3; x++)
if !FacingWall()
if Move(1SpaceForward) return true;
TurnLeft
return false;
[/code]

: ok guys, sorry for my previous post:)
:
: the functions i made are these ones:
:[code]
: int isfacingwall(int a[][cols],int i,int j)
: {
: if(a[i][j]==1)
: return 1;
: else
: return 0;
: }
:
: void printarray (int a[][cols],int size)
: {
: int i,j;
: for(i=0;i=0 && x=0 && y<cols))
: return 1;
: else
: return 0;
: }
:
: int isoutside(int x, int y)
: {
: if(x==finish_x && y==finish_y)
: return 1;
: else
: return 0;
: }
: [/code]
: my problem is to develop the algorithm of the right hand rule in c code..if you have any ideas pls let me know:)
:
: thanks
:

• This brings up an interesting question. If you programmed a maze generator to make a maze in 3-dimensions how hard would it be to adapt the right hand logrythm to find the solution in 3D? Has this question been explored before.