Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Project: Create a Maze Runner game in C programming *NOT C++, The project must d

ID: 3707920 • Letter: P

Question

Project: Create a Maze Runner game in C programming *NOT C++,

The project must demonstrate that a maze from a file, stored in a specified format, can be: • Read into their program’s data structure from a text file, where the name is specified through command-line input • Presented back to the user through standard out.

An example encoding format for the maze could be as follows: • a plus-sign “+” for walls inside the maze. • a space “ “ for non visited locations in the maze. a period “.” for visited locations in the maze. • When the maze is printed, some special character can be used to designate the entrance and exit, and the outside walls can be made with “|” and “-”, corners with a “+”.

Could Also use 1s for wall and 0s for spaces, Need help getting started with this and where to go, anything helps.

Explanation / Answer

#include<conio.h>

#include<stdio.h>

#define SIZE 15

#include<stdlib.h>

void main()

{

int maze[SIZE][SIZE],mark[SIZE][SIZE],stack[SIZE][3];

static int

move[8][2]={-1,0,-1,1,0,1,1,1,1,0,1,-1,0,-1,-1,-1};

int i,j,m,n,top,mov,g,h;

clrscr();

printf("enter size");

scanf("%d%d",&m,&n);

for(i=1;i<=m;i++)

{

for(j=1;j<=n;j++)

{

scanf("%d",&maze[i][j]);

}

}

for(i=0;i<=n+1;i++)

maze[0][i]=1;

for(i=0;i<=n+1;i++)

maze[m+1][i]=1;

for(i=0;i<=m+1;i++)

maze[i][0]=1;

for(i=0;i<=m+1;i++)

maze[i][n+1]=1;

for(i=1;i<=m;i++)

{

for(j=1;j<=n;j++)

{

mark[i][j]=0;

}

}

mark[1][1]=1;

stack[0][0]=1;

stack[0][1]=1;

stack[0][2]=2;

top=1;

while(top!=0)

{

i=stack[0][0];

j=stack[0][1];

mov=stack[0][2];

top=top-1;

while(mov<=7)

{

g=i+move[mov][0];

h=j+move[mov][1];

if(mark[g][h]==0&&maze[g][h]==0)

{

mark[g][h]=1;

top++;

stack[top][0]=i;

stack[top][1]=j;

mov=-1;

i=g;j=h;

}

mov=mov+1;

if(g==m&&h==n)

{

printf("

path made by the rat is");

for(i=1;i<=top;i++)

printf("

%d %d",stack[i][0],stack[i][1]);

printf("

%d %d",m,n);

getch();

exit(0);

}

}

}

}