From: gregm@otc.otca.oz.au (Greg McFarlane)
Newsgroups: alt.sources
Subject: VI SOLVES MAZE (and lies about it)
Date: 11 Jan 91 01:56:21 GMT
Reply-To: gregm@otc.otca.oz.au (Greg McFarlane)
Organization: OTC Development Unit, Australia

A real working model. See it walk the maze in front of your very own eyes.

To prove that you can do anything in vi, I wrote a couple of macros that
allows vi to solve mazes. It will solve any maze produced by maze.c
that was posted to the net last month. (Maze.c is also included below.)

Just follow this recipe and SEE FOR YOURSELF.
	1. save this article and strip off all lines except those between
		the "cut here for vi macros" markers
	2. run uudecode on the file to produce "maze.vi.macros"
	3. if you haven't already done so, compile maze.c
		(cc -o maze maze.c)
	4. run maze > maze.out and input a small number (for example 10 if
		you are on a fast machine, 3-5 if slow) which
		is the size of the maze to produce
	5. edit the maze (vi maze.out)
	6. include the macros with the vi command:
		:so maze.vi.macros
	7. type the letter "g" (for "go") and watch vi solve the maze
	8. when vi solves the maze, you will see why it lies

Tested on a sparc, a sun and a pyramid (although maze.c will not compile
on the pyramid).

Any donations should be in unmarked small denomination bills :^)=.

uuencoded maze.vi.macros:
(note that the second last line (above "end") consists of a single space)
----------------- cut here for vi macros ----------------------
begin 664 maze.vi.macros
M<V5T(')E;6%P"G-E="!N;VUA9VEC"FUA<"!G($E,"FUA<"!)($<_+@U>,D=1
M;&UA1UE*>DIE2D1*2U P4V!A"FUA<"!,(%%!;6%'3D(P33!%0&T-=UA@84!M
M1U0D0B12,$TP14!M#69:8E-B6$=62C!(8&% <D!M50IM87 @52!,"FUA<"!1
M(")C>6P*;6%P($$@<D\*;6%P(%X@<E@*;6%P($X@0R]N&PIM87 @0B B<W *
M;6%P($T@(FUY) IM87 @5"!#+W,;"FUA<"!2(")N< IM87 @4R B<WEL"FUA
M<"!8(")M>70@"FUA<"!6(&%R&PIM87 @2B B8W *;6%P($@@(G)Y) IM87 @
M1B B;GEL"FUA<"!9(&]S02 @:R!%6B!S05\@;6T@0EH@<T(;"FUA<"!Z("1A
M(&UM($=:('-"("!L;"!!6B!S0BX@;&P@05H@<T,@(&H@1UH@<T,N(&H@1UH-
M<T-?(&UM($1:('-$&PIM87 @92 D82!M;2!%6B!S1"X@:&@@0UH@<T4N(&AH
M($-:('-%&PIM87 @1" D82!M;2!&6B!S1B @:R!%6B!S1E\@;6T@05H-<T<N
M(&QL($%:('-'("!L;"!!6B!S1QL*;6%P($L@)&$@;6T@2%H@<T@@(&H@1UH@
M<TA?(&UM($-:&PIM87 @4"!O;D$@:T8@;D(@;$8@;D,@1R1*1B!N1"!H1B!N
F12!H1B!N1B!K1B!N1R!L1B!N2"!')$I&( U!&PIM87 @12!D) IN
 
end
----------------- cut here for vi macros ----------------------


maze.c: (if using SysV or DOS replace the "27" on the last line by "11")
credit to John Tromp (tromp@piring.cwi.nl)
----------------- cut here for maze.c ----------------------
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,"_.":" |"];}
----------------- cut here for maze.c ----------------------


-- 

                   ACSnet:  gregm@otc.otca.oz.au
Greg McFarlane       UUCP:  {uunet,mcvax}!otc.otca.oz.au!gregm
|||| OTC ||         Snail:  OTC R&D GPO Box 7000, Sydney 2001, Australia
                    Phone:  +61 2 287 3139    Fax: +61 2 287 3299
$B%$%C%U(J $B%f!<(J $B%+%s(J $B%j!<%C%I(J $B%:%#%9(J $B!<(J $B%9%^%$%k(J


-- 
dik t. winter, cwi, kruislaan 413, 1098 sj  amsterdam, nederland
home: bovenover 215, 1025 jn  amsterdam, nederland; e-mail: dik@cwi.nl
Newsgroups: nlnet.misc