Xref: utzoo comp.sources.wanted:14521 alt.sources.d:1183 rec.games.misc:12857 rec.games.programmer:2704 Path: utzoo!utgpu!watserv1!watmath!att!news.cs.indiana.edu!spool2.mu.edu!sdd.hp.com!uakari.primate.wisc.edu!pikes!aspen.craycos.com!scott From: scott@craycos.com (Scott Bolte) Newsgroups: aus.games,comp.sources.wanted,alt.sources.d,rec.games.misc,rec.games.programmer Subject: Re: Maze generation Keywords: how-to maze generate program wanted Message-ID: <1990Dec16.181459.10786@craycos.com> Date: 16 Dec 90 18:14:59 GMT Article-I.D.: craycos.1990Dec16.181459.10786 References: <1215@syacus.acus.oz> <1990Dec13.190759.9297@craycos.com> <1990Dec15.093542.2725@pegasus.com> Organization: Cray Computer Corporation Lines: 95 In article <1990Dec15.093542.2725@pegasus.com> tleylan@pegasus.com (Tom Leylan) writes: > ... I'm using Microsoft C and it returns a random >value between 1 and 32767. Does this appear to conflict with anything ? I do not see how that would cause a problem. Why don't you try the following unrolled code... It is not nearly as obscure as the original code, which several people have confirmed came from the obfuscated code contest. #define HALF_LINE 40 char M[3], A, even, E = HALF_LINE, J[HALF_LINE], T[HALF_LINE]; main(argc,argv) char *argv[]; { int lines; char wall; srand(getpid()); if( argc > 1) lines = atoi(argv[1]); else (void) scanf("%d" , &lines); A = 1; /* * Top line */ for (*J = A ; --E; J[E] = T[E] = E) printf("._"); while( 1) { /* * even toggles between 0 and 1. */ even = !even; A -= even; if ( A == 0 ){ printf("\n|"); A = HALF_LINE - 1 ; if( lines-- == 0) exit(0); } E = A[J - even]; /* * default settings. */ if( even ) M[1] = '|'; else M[0] = ' '; if( A != E ) { if( lines != 0) /* * rule for the middle lines. */ wall = (0x30000000 < rand()); else /* * rule for the bottom line. */ wall = (A== T[A] | (0x30000000 < rand())) || !even; if( wall ) { T[E] = T[A]; J[T[E]] = E; T[A] = A - even; J[T[A]] = A; if( even ) M[1] = '.'; else M[0] = '_'; } } else /* * Very last printout. */ if ( !lines && !even ) M[0] = '_'; if( !even ) printf(M); } } Scott -- ___________________________________________________________________________ Scott Bolte scott@craycos.com +1 719 540 4186 Cray Computer Corporation, 1110 Bayfield Drive, Colorado Springs, CO 80906