From: peterb@cs.rug.nl (Peter J. de Bruin)
Subject: Re: VI ! ach welk een eenvoud! Maar o rampspoed, Esther is een ketter!
Organization: Dept. of Computing Science, University of Groningen
Distribution: nlnet
Date: Tue, 15 Dec 1992 09:06:51 GMT

In article <8310@charon.cwi.nl> dik@cwi.nl (Dik T. Winter) writes:
>In article <wsinmh.723997997@rwb.urc.tue.nl> wsinmh@urc.tue.nl writes:
> > Kijk dat is de spirit! Editing is war! En vergeet vooral niet te
> > vermelden dat een van de belangrijkste criteria van een editor is,
> > hoeveel dingen je ermee kan doen die niets met editen te maken hebben
> > (ideaal zijn spelletjes, programmeertalen en koffiezetten!)
> > 
>Inderdaad.  Een van de belangrijkste zaken is doolhoven oplossen.  Hieronder
>een artikel dat ik nagenoeg 2 jaar geleden van het net plukte: vi kan een
>doolhof oplossen, nu hetzelfde voor emacs graag (gnu-emacs bij voorkeur,
>unipress-emacs mag ook, voor cca-emacs kun je het wel vergeten).
>
>dik

Hier is een gnu-emacs oplossing.
1. Compileer maze.c:		cc -o maze maze.c
2. Genereer doolhof met:	maze > maze.out
   en geef gewenste hoogte op:	20
3. Start Emacs met doolhof:	emacs maze.out
4. Programma laden met:		M-x load-file
				walk
5. Starten met:			M-x walk

-------------------------- Cut here for walk.el ------
(defun walk () "Walk through maze"
  (interactive)
  (goto-char (point-max)) (search-backward "_")
  (delete-char 1) (insert "X")
  (goto-char 2) (next-line 1)
  (let ((dir 0) c)
    (while (not (looking-at "X"))
      (setq c (following-char))
      (delete-char 1) (insert "O") (sit-for 0)
      (delete-char -1) (insert-char c 1) (backward-char)
      (setq dir (% (+ dir 1) 4))
      (while (< ?.(char-after
		   (cond ((= dir 0) (1+ (point)))
			 ((= dir 1) (save-excursion
				      (previous-line 1) (point)))
			 ((= dir 2) (1- (point)))
			 ((= dir 3) (point)))))
	(setq dir (% (+ dir 3) 4)))
      (cond ((= dir 0) (forward-char 2))
	    ((= dir 1) (previous-line 1))
	    ((= dir 2) (backward-char 2))
	    ((= dir 3) (next-line 1))))))
-------------------------------------------- Cut here

>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
>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
	/* overbodige regel weggelaten */
|6<<27<rand()||!C&!Z?J[T[E]=T[A]]=E,J[T[A]=A-Z]=A,"_.":" |"];}

----------------- cut here for maze.c ----------------------
-- 
 Peter de Bruin             +------------------------------------------+
 University of Groningen    |  Awareness of our Universal Brotherhood  |
 The Netherlands            |  shall irresistably penetrate society.   |
 ( P.J.de.Bruin@cs.rug.nl ) +------------------------------------------+
Newsgroups: nlnet.misc