random maze generator
Markus Fischer
fisher at sc2a.unige.ch
Wed Sep 20 01:18:27 AEST 1989
In article <14777 at swan.ulowell.edu>, smarison at hawk.ulowell.edu (Dr. oTTo) writes:
> Does anyone have any good random maze generators written in C?
You want a maze ? Here is one:
char*M,A,Z,E=40,J[40],T[40];main(C){for(*J=A=scanf(M="%d",&C);
-- E; J[ E] =T
[E ]= E) printf("._"); for(;(A-=Z=!Z) || (printf("\n|"
) , A = 39 ,C --
) ; Z || printf (M ))M[Z]=Z[A-(E =A[J-Z])&&!C
& A == T[ A]
|6<<27<rand()||!C&!Z?J[T[E]=T[A]]=E,J[T[A]=A-Z]=A,"_.":" |"];}
It works, too !
The program first pauses to have you enter the number of lines of maze you
want, then goes about to write it (on 79 char).
Ah, before i forget: the left shift of the rand() function is implementation
specific. Correct it if needed... (where? on the bottom left corner :-)
NOTE: This aMAZEing program isn't mine, it's just the source on which I
learned C for the first time (indentation and comments came later :-). As a
rough guess, this *must* be the winner of an `obfuscated c code contest'
some years ago, but i got this without reference...
If the author is listening, congratulations and apologies !
Markus
More information about the Comp.lang.c
mailing list