Submitted-by: gr
...@otc.otca.oz.au
Archive-name: maze_solving_vi_macros
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 alt.sources last month. (Maze.c is also included
in this posting as well as an example of its output.)
The uncommented version of the macros was sent to alt.sources last month.
However, so many people mailed me requesting the commented version of the
macros that I decided to post it. I have made some modifications to the
original macros to make them easier to follow and also after I learnt
that you can escape the special meaning of '|' in macros by using '^V|'.
Save this article and unshar it. Then read maze.README.
After studying these macros, anyone who cannot write an emacs emulator
in vi macros should just curl up and :q!.
Coming soon to a newsgroup near you: "Vi macros solve Tower of Hanoi",
and a repost of the original "Turing Machine implemented in Vi macros"
Anyone who has a version of these macros for edlin or nroff, please post.
---- Cut Here and unpack ----
#!/bin/sh
# This is maze_solving_vi_macros, a shell archive (shar 3.32)
# made 02/07/1991 14:24 UTC by gr...@otc.otca.oz.au
# Source directory /n/arrakis/u/sysdev/gregm/vi.macros
#
# existing files will NOT be overwritten
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 1666 -rw-rw-r-- maze.README
# 16793 -rw-rw-r-- maze.vi.macros.uu
# 481 -rw-rw-r-- maze.out
# 441 -rw-rw-r-- maze.c
# 441 -rw-rw-r-- maze.ansi.c
#
if touch 2>&1 | fgrep 'amc' > /dev/null
then TOUCH=touch
else TOUCH=true
fi
# ============= maze.README ==============
if test X"$1" != X"-c" -a -f 'maze.README'; then
echo "File already exists: skipping 'maze.README'"
else
echo "x - extracting maze.README (Text)"
sed 's/^X//' << 'SHAR_EOF' > maze.README &&
XTo prove that you can do anything in vi, I wrote a couple of macros that
Xallows vi to solve mazes. It will solve any maze produced by maze.c
Xthat was posted to the net recently.
X
XJust follow this recipe and SEE FOR YOURSELF.
X 1. run uudecode on the file "maze.vi.macros.uu" to
X produce the file "maze.vi.macros"
X (If you can't wait to see the action, jump to step 4)
X 2. compile maze.c with "cc -o maze maze.c"
X 3. run maze > maze.out and input a small number (for example 10 if
X you are on a fast machine, 3-5 if slow) which
X is the size of the maze to produce
X 4. edit the maze (vi maze.out)
X 5. include the macros with the vi command:
X :so maze.vi.macros
X 6. type the letter "g" (for "go") and watch vi solve the maze
X 7. when vi solves the maze, you will see why it lies
X 8. now look at maze.vi.macros and all will be revealed
X
XTested on a sparc, a sun and a pyramid (although maze.c will not compile
Xon the pyramid).
X
XAnyone who can't get the maze.c file to compile, get a new compiler,
Xtry maze.ansi.c which was also posted to the net.
XIf you can get it to compile but the maze comes out looking like a fence
Xand not a maze and you are using SysV or DOS replace the "27" on the
Xlast line of maze.c by "11"
XThanks to John Tromp (tr...@piring.cwi.nl) for maze.c.
XThanks to anto...@nntp-server.caltech.edu (Bill T. Cat) for maze.ansi.c.
X
XAny donations should be in unmarked small denomination bills :^)=.
X
X ACSnet: gr...@otc.otca.oz.au
XGreg McFarlane UUCP: {uunet,mcvax}!otc.otca.oz.au!gregm
X|||| OTC || Snail: OTC R&D GPO Box 7000, Sydney 2001, Australia
X Phone: +61 2 287 3139 Fax: +61 2 287 3299
X
X
SHAR_EOF
$TOUCH -am 0208005691 maze.README &&
chmod 0664 maze.README ||
echo "restore of maze.README failed"
set `wc -c maze.README`;Wc_c=$1
if test "$Wc_c" != "1666"; then
echo original size 1666, current size $Wc_c
fi
fi
# ============= maze.vi.macros.uu ==============
if test X"$1" != X"-c" -a -f 'maze.vi.macros.uu'; then
echo "File already exists: skipping 'maze.vi.macros.uu'"
else
echo "x - extracting maze.vi.macros.uu (Text)"
sed 's/^X//' << 'SHAR_EOF' > maze.vi.macros.uu &&
Xbegin 664 maze.vi.macros
XM(B!4:&5S92!M86-R;W,@)W-O;'9E)R!A;GD@;6%Z92!P<F]D=6-E9"!B>2!T
XM:&4@82UM87IE+6EN9R!M87IE+F,@<')O9W)A;2X*(B *(B!&:7)S="P@82!B
XM:70@;V8@;6%Z92!T:&5O<GDN"B(@268@>6]U('=E<F4@<'5T(&EN=&\@82!M
XM87IE+"!A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<PHB("!.,2 @(" @(" @(" @(" @5R @(" @(" @(" @(" @
XM(&A&"B(@($XR(" @(" @(" @(" @("!.(" @(" @(" @(" @(" @:T8*(B @
XM4S$@(" @(" @(" @(" @($4@(" @(" @(" @(" @("!L1@HB("!3,B @(" @
XM(" @(" @(" @4R @(" @(" @(" @(" @($8*(B @13$@(" @(" @(" @(" @
XM($X@(" @(" @(" @(" @("!K1@HB("!%,B @(" @(" @(" @(" @12 @(" @
XM(" @(" @(" @(&Q&"B(@(%<Q(" @(" @(" @(" @("!3(" @(" @(" @(" @
XM(" @1@HB("!7,B @(" @(" @(" @(" @5R @(" @(" @(" @(" @(&A&"B(@
XM"B(@=VAE<F4@1B!I<R!A(&UA8W)O('=H:6-H('EA;FMS('1H92!C:&%R86-T
XM97(@=6YD97(@=&AE(&-U<G-O<B!I;G1O"B(@=&AE($YE>'1#:&%R(')E9VES
XM=&5R("AN*2X*(B *(B!3=&%T92!T86)L93H*(B!);B!T:&4@)W9I(&-O;6UA
XM;F1S)R!C;VQU;6X@:7,@9VEV96X@=&AE(&%C=&EO;G,@=&\@8V%R<GD@;W5T
XM('=H96X@:6X*(B!T:&ES('-T871E(&%N9"!T:&4@3F5X=$-H87(@:7,@87,@
XM9VEV96XN(%1H92!C;VUM86YD<R!K+"!J+"!L;"P@:&@@;6]V90HB('1H92!C
XM=7)R96YT('!O<VET:6]N(&YO<G1H+"!S;W5T:"P@96%S="!A;F0@=V5S="!R
XM97-P96-T:79E;'DN(%1H90HB(&-O;6UA;F0@;6T@:7,@=7-E9"!A<R!A(&YO
XM+6]P(&-O;6UA;F0N"B(@26X@=&AE("=N97AT('-T871E)R!C;VQU;6X@:7,@
XM9VEV96X@=&AE(&YE=R!S=&%T92!O9B!T:&4@;6%C:&EN92!A9G1E<@HB('1H
XM92!A8W1I;VX@:7,@8V%R<FEE9"!O=70N"B(@"B(@8W5R<F5N="!S=&%T92 @
XM(" @(" @3F5X=$-H87(@("
...
read more »