/* Maze detection )*/
/* Recursivemaze. c */
/* 2003-10-16 */
# Include <stdlib. h>
# Include <time. h>
# Include <math. h>
# Include <stdio. h>
# Include <graphics. h>
# Define N 22
# Define M 22
# Define maxlen m * N
Int bg [M] [N];
Int aa [M] [N];
Struct pace {
Int dir;
Int ri;
Int rj;
} Road [MAXLEN];
Int length = 0;
Int dj [] = {1, 0,-1, 0 };
Int di [] = {0, 1, 0,-1 };
Void makebg (int, int );
Void drawbg (int [] [], int );
Void drawman (int, int, int );
Void rect (int, int );
Int go (int, int, int );
Void main () {/* main () start */
Int step = 20;
Int len = 10;
Int size = 20;
Int x = 0, y = 0;
Int I = 0, j = 0;
Int gdriver = DETECT, gmode;
Makebg (M, N );
/* Registerbgidriver (EGAVGA_driver );
Initgraph (& gdriver, & gmode, "c: \ turboc2 ");*/
Initgraph (& gdriver, & gmode, "c: \ tc20 \ bgi ");
Cleardevice ();
Setwritemode (XOR_PUT );
Settextstyle (1, 0, 3 );
Setcolor (GREEN );
Outtextxy (100,180, "recursive maze ");
Setcolor (BLUE );
Setfillstyle (LINE_FILL, BLUE );
/* Drawbg (bg, M, N, size, 0, 0 );*/
Drawbg (aa, M, N, size, 0, 0 );
Setcolor (WHITE );
X + = len; y + = len;
Drawman (x, y, len );
/* Computer Control */
Aa [0] [0] = 1;
Road [0]. ri = 0;
Road [0]. rj = 0;
Road [0]. dir = 0;
Go (0, 0, 0 );
/* Output */
Getch ();
Drawman (x, y, len );
For (I = 0; I <= length; I ++ ){
Drawman (x + road [I]. rj * step, y + road [I]. ri * step, len );
Delay (80000 );
Drawman (x + road [I]. rj * step, y + road [I]. ri * step, len );
}
I --;
Drawman (x + road [I]. rj * step, y + road [I]. ri * step, len );
Getch ();
Closegraph ();
}
/* Main () ends */
/* Draw the villain */
Void drawman (int x, int y, int len ){
Int r = len/4;
Rect (x-r, y-len, x + r, y-len + 2 * r );
Line (x, y-len + 2 * r, x, y );
Line (x-len, y, x + len, y );
Line (x, y, x-len, y + len );
Line (x, y, x + len, y + len );
}
/* Draw a maze map */
Void drawbg (int bg [] [N], int a, int B, int size, int x, int y ){
Int startx = x;
Int I, j;
For (I = 0; I <a; I ++ ){
For (j