home *** CD-ROM | disk | FTP | other *** search
- From: xanthian@zorch.SF-Bay.ORG (Kent Paul Dolan)
- Newsgroups: rec.games.programmer,alt.sources,alt.sources.amiga
- Subject: townmaze part 01/04
- Message-ID: <1991Apr18.034540.7109@zorch.SF-Bay.ORG>
- Date: 18 Apr 91 03:45:40 GMT
-
-
- Archive-name: townmaze/part01
-
- Sorry to be so slow at this, but enough folks asked for it I thought
- I'd better go ahead and clean up the hacked up mess it began as. It
- now compiles, with only make file changes, on an ANSI C and an old
- C compiler on two different architectures/OSs, so perhaps most of the
- portability problems will be small ones. No longer a slave to #defines,
- it now has 8 optional command line parameters, malloc()s its work space,
- frees it on exit(), and otherwise behaves itself. It's also grown huge,
- from 30K when it first worked as one monolithic file to around 170K now,
- aided and abetted by over 50K of documentation, and lots of overhead
- from make files and splitting the files out and putting in prototypes
- and such stuff. Enough whining; give this kid a job! An excerpt from
- the README file follows, and then part one of the shar. This is a
- vanilla cshar makekit production (thanks as always to Rich Salz) in four
- parts.
-
- Kent, the man from xanth.
- <xanthian@Zorch.SF-Bay.ORG> <xanthian@well.sf.ca.us>
-
-
- Townmaze -- A Program to Design "Bard's Tale I"-Style City Mazes
-
- Copyright 1991 by Kent Paul Dolan, Mountain View, CA, USA 94039-0755
-
- This program was written in response to a request in USENet newsgroup
- rec.games.programmer for "code that designs a town-shaped maze like the
- town Bard's Tale I uses"; you be the judge how well it does; I'm quite
- proud of the result. The goal is not a great "pencil and paper" maze,
- but instead a fun town for a 3D dungeon crawl game to incorporate.
- Here's a tiny (7/64 the size of the BT-I town) example output, big ones
- look better:
-
- ht 15 wd 33 gates 8 left 1 courts 4 unused 2 straight 950 seed 113181
- #################################
- ### | | # | | # | | # | # # # ###
- ##### ##### ##### ##### #-#-#-###
- # | | # | | # | # # # #
- ###-# ##### ### #####-# ### #-#
- # # # | # | | # | | # #
- #-### ####### #-####### ###-###-#
- | | ### | # ### # | # # # # #
- #-### ####### #####-### #-###-###
- # # # # # # | | #
- ###-# #-# ### ### ###
- # | | # | #
- ###-### #-#-#-#-#-#-#-#-# ###-###
- ### # | # # # # # # # # # | # ###
- #################################
-
- There are now _lots_ of command line parameters; (continued in README file).
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 1 (of 4)."
- # Contents: MANIFEST README cleanupmap.c closedoors.c closegates.c
- # filllist.c fillmaze.c finishalleys.c freespace.c interiorcell.c
- # makecourts.c makegates.c makespace.c movefromto.c nhbrexists.c
- # nhbris.c showdbmaze.c showlistdet.c showlistsum.c showmaze.c
- # townmain.c townmaze.with usage.c
- # Wrapped by xanthian@zorch on Wed Apr 17 20:34:37 1991
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'MANIFEST' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'MANIFEST'\"
- else
- echo shar: Extracting \"'MANIFEST'\" \(1106 characters\)
- sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
- X File Name Archive # Description
- X-----------------------------------------------------------
- X MANIFEST 1 This shipping list
- X README 1
- X cleanupmap.c 1
- X closedoors.c 1
- X closegates.c 1
- X connectst.c 2
- X filllist.c 1
- X fillmaze.c 1
- X finishalleys.c 1
- X freespace.c 1
- X getargs.c 2
- X interiorcell.c 1
- X makecourts.c 1
- X makegates.c 1
- X makespace.c 1
- X makestreet.c 3
- X makeunused.c 2
- X movefromto.c 1
- X nhbrexists.c 1
- X nhbris.c 1
- X showdbmaze.c 1
- X showlistdet.c 1
- X showlistsum.c 1
- X showmaze.c 1
- X townmain.c 1
- X townmaze.h 2
- X townmaze.lmk 2
- X townmaze.with 1
- X townpgmr.doc 4
- X townproto.h 2
- X townuser.doc 2
- X usage.c 1
- END_OF_FILE
- if test 1106 -ne `wc -c <'MANIFEST'`; then
- echo shar: \"'MANIFEST'\" unpacked with wrong size!
- fi
- # end of 'MANIFEST'
- fi
- if test -f 'README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'README'\"
- else
- echo shar: Extracting \"'README'\" \(3940 characters\)
- sed "s/^X//" >'README' <<'END_OF_FILE'
- XTownmaze -- A Program to Design "Bard's Tale I"-Style City Mazes
- X
- XCopyright 1991 by Kent Paul Dolan, Mountain View, CA, USA 94039-0755
- X
- XThis program was written in response to a request in USENet newsgroup
- Xrec.games.programmer for "code that designs a town-shaped maze like the
- Xtown Bard's Tale I uses"; you be the judge how well it does; I'm quite
- Xproud of the result. The goal is not a great "pencil and paper" maze,
- Xbut instead a fun town for a 3D dungeon crawl game to incorporate.
- XHere's a tiny (7/64 the size of the BT-I town) example output, big ones
- Xlook better:
- X
- Xht 15 wd 33 gates 8 left 1 courts 4 unused 2 straight 950 seed 113181
- X#################################
- X### | | # | | # | | # | # # # ###
- X##### ##### ##### ##### #-#-#-###
- X# | | # | | # | # # # #
- X###-# ##### ### #####-# ### #-#
- X# # # | # | | # | | # #
- X#-### ####### #-####### ###-###-#
- X| | ### | # ### # | # # # # #
- X#-### ####### #####-### #-###-###
- X# # # # # # | | #
- X###-# #-# ### ### ###
- X# | | # | #
- X###-### #-#-#-#-#-#-#-#-# ###-###
- X### # | # # # # # # # # # | # ###
- X#################################
- X
- XThere are now _lots_ of command line parameters; you can choose the maze
- Xheight in characters, the maze width in characters, number of edge
- X"gate" street starting positions in the start of the maze design, the
- Xnumber of these gates that survive in the finished maze, the number of
- Xinner "courtyard" street starting positions in the start of the maze
- Xdesign, the number of unused cells in the interior to provide more
- Xcomplex branching in the building nets, how hard the program tries to
- Xmake the streets run straight, and you may override the clock seed of
- Xthe random number generator with a forced seed, to get a repeat of an
- Xespecially nice maze that flashed by while you weren't saving the
- Xoutput.
- X
- XThings to try: no gates, no courtyards, lots of gates, lots of
- Xcourtyards, straightnesses of 0, 250, 500, 750, 950, 980, 996, a few
- Xunused cells to make four way branch points.
- X
- XYou can make as big a maze as your machine has memory to hold; the maze
- Xelements are dynamically allocated from free memory, and freed before
- Xthe program exits. The mazes get pretty spectacular several pages long,
- Xand need to be at least a full screen to see much of the "town" effect
- Xat all.
- X
- XThat much stuff made the command line pretty busy, so things like
- Xdebugging are still controlled by #defines in the townmaze.h file.
- X
- XFor reasons having to do with Lattice C use, one of the two places I
- Xwrote this, the makefile is that thing called "townmaze.lmk"; at least
- Xon my BSD 4.3 Unix system, "make -f townmaze.lmk" works. You may need
- Xto edit the makefile a little to work on your system.
- X
- XFor compiling on the Amiga, make the indicated edits. Due to the short
- Xcommand line allowed by AmigaOS, the blink command must run using the
- Xauxiliary command input file townmaze.with.
- X
- XOne big gotcha for porting to various systems is the name of the good
- Xrandom number generator; if you work on a system that uses the drand48
- Xfamily instead of random() and srandom(), you'll want your compiles to
- Xhave RAND48 defined; see the townmaze.lmk file for an example of how
- Xthat works under Lattice C.
- X
- XWhen you have the program built, "townmaze help" will get you a usage
- Xdisplay. You may also want to read the townuser.doc and townpgmr.doc
- Xfiles for more information about the program for users and programmers
- Xrespectively.
- X
- XAny non-commercial use of this code is permitted, in whole or in part;
- Xcredit to the author is requested but not demanded. Commercial use may
- Xbe arranged with the author for little or no fee. The primary reason for
- Xthe copyright is to keep some yokel from patenting the algorithms
- Xcontained herein and spoiling programming for the rest of us.
- X
- XThis program is for fun; you use it at your own risk, of course.
- X
- XKent, the man from xanth.
- X<xanthian@Zorch.SF-Bay.ORG> <xanthian@well.sf.ca.us>
- END_OF_FILE
- if test 3940 -ne `wc -c <'README'`; then
- echo shar: \"'README'\" unpacked with wrong size!
- fi
- # end of 'README'
- fi
- if test -f 'cleanupmap.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'cleanupmap.c'\"
- else
- echo shar: Extracting \"'cleanupmap.c'\" \(937 characters\)
- sed "s/^X//" >'cleanupmap.c' <<'END_OF_FILE'
- X/*
- X** cleanupmap.c Copyright 1991 Kent Paul Dolan,
- X** Mountain View, CA, USA 94039-0755
- X**
- X** Written to satisfy an inquiry on USENet's rec.games.programmer newsgroup.
- X** May be freely used or modified in any non-commercial work. Copyrighted
- X** only to prevent patenting by someone else.
- X*/
- X
- X#include <stdio.h>
- X#include "townmaze.h"
- X#include "townproto.h"
- X
- X#ifdef __STDC__
- Xvoid cleanupmap()
- X#else
- Xint cleanupmap()
- X#endif
- X{
- X
- X/*
- X** Isolated "posts" of wall segments are left by the normal map making
- X** process; clean them up to make nice open courtyards.
- X*/
- X
- X int i, j;
- X
- X#if PROGRESS
- X fprintf(stderr,"Clean up map ");
- X#endif
- X
- X for (i = 4; i < (mazeheight - 4); i += 2)
- X for (j = 4; j < (mazewidth - 4); j += 2)
- X if ( (cmaze[i-1][j] == BLANK)
- X && (cmaze[i][j+1] == BLANK)
- X && (cmaze[i+1][j] == BLANK)
- X && (cmaze[i][j-1] == BLANK)
- X )
- X cmaze[i][j] = BLANK;
- X return;
- X
- X}
- END_OF_FILE
- if test 937 -ne `wc -c <'cleanupmap.c'`; then
- echo shar: \"'cleanupmap.c'\" unpacked with wrong size!
- fi
- # end of 'cleanupmap.c'
- fi
- if test -f 'closedoors.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'closedoors.c'\"
- else
- echo shar: Extracting \"'closedoors.c'\" \(1887 characters\)
- sed "s/^X//" >'closedoors.c' <<'END_OF_FILE'
- X/*
- X** closedoors.c Copyright 1991 Kent Paul Dolan,
- X** Mountain View, CA, USA 94039-0755
- X**
- X** Written to satisfy an inquiry on USENet's rec.games.programmer newsgroup.
- X** May be freely used or modified in any non-commercial work. Copyrighted
- X** only to prevent patenting by someone else.
- X*/
- X
- X#include <stdio.h>
- X#include "townmaze.h"
- X#include "townproto.h"
- X
- X#ifdef __STDC__
- Xvoid closedoors()
- X#else
- Xint closedoors()
- X#endif
- X{
- X
- X/*
- X** The map as built so far has far too many doors per room. Close all
- X** but one door of each room to make a "Bard's Tale I"-like maze.
- X*/
- X
- X int deadwalk; /* nothing interesting left but the dead cells */
- X int doorct, whichdoor;
- X int celli, cellj;
- X
- X#if PROGRESS
- X fprintf(stderr,"Close Doors ");
- X#endif
- X
- X deadwalk = dead;
- X
- X while (deadwalk != NOPOINTER)
- X {
- X
- X celli = deadwalk/(mazewidth/2);
- X cellj = deadwalk%(mazewidth/2);
- X
- X celli = (2*celli) + 1;
- X cellj = (2*cellj) + 1;
- X
- X doorct = 0;
- X if (cmaze[celli - 1][cellj] == HDOOR) doorct++;
- X if (cmaze[celli][cellj + 1] == VDOOR) doorct++;
- X if (cmaze[celli + 1][cellj] == HDOOR) doorct++;
- X if (cmaze[celli][cellj - 1] == VDOOR) doorct++;
- X
- X if ( doorct > 1 )
- X {
- X whichdoor = RANDOM()%doorct; /* keep this one */
- X doorct = 0;
- X if (cmaze[celli - 1][cellj] == HDOOR)
- X {
- X if (doorct != whichdoor) cmaze[celli - 1][cellj] = WALL;
- X doorct++;
- X }
- X if (cmaze[celli][cellj + 1] == VDOOR)
- X {
- X if (doorct != whichdoor) cmaze[celli][cellj + 1] = WALL;
- X doorct++;
- X }
- X if (cmaze[celli + 1][cellj] == HDOOR)
- X {
- X if (doorct != whichdoor) cmaze[celli + 1][cellj] = WALL;
- X doorct++;
- X }
- X if (cmaze[celli][cellj - 1] == VDOOR)
- X {
- X if (doorct != whichdoor) cmaze[celli][cellj - 1] = WALL;
- X doorct++;
- X }
- X }
- X deadwalk = statlist[deadwalk].next;
- X }
- X}
- END_OF_FILE
- if test 1887 -ne `wc -c <'closedoors.c'`; then
- echo shar: \"'closedoors.c'\" unpacked with wrong size!
- fi
- # end of 'closedoors.c'
- fi
- if test -f 'closegates.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'closegates.c'\"
- else
- echo shar: Extracting \"'closegates.c'\" \(2275 characters\)
- sed "s/^X//" >'closegates.c' <<'END_OF_FILE'
- X/*
- X** closegates.c Copyright 1991 Kent Paul Dolan,
- X** Mountain View, CA, USA 94039-0755
- X**
- X** Written to satisfy an inquiry on USENet's rec.games.programmer newsgroup.
- X** May be freely used or modified in any non-commercial work. Copyrighted
- X** only to prevent patenting by someone else.
- X*/
- X
- X#include <stdio.h>
- X#include "townmaze.h"
- X#include "townproto.h"
- X
- X#ifdef __STDC__
- Xvoid closegates()
- X#else
- Xint closegates()
- X#endif
- X{
- X int gatesleft;
- X int chosengate;
- X int foundgate;
- X int gatewalk;
- X int possiblegates;
- X
- X int mazei, mazej;
- X
- X#if PROGRESS
- X fprintf(stderr,"Close Gates ");
- X#endif
- X
- X if (mazegates <= leftgates) return;
- X
- X gatesleft = mazegates;
- X
- X possiblegates = (mazeheight-1) + (mazewidth-1);
- X
- X/*
- X** fprintf(stderr,
- X** "\nmazegates %d leftgates %d gatesleft %d possiblegates %d\n",
- X** mazegates,leftgates,gatesleft,possiblegates);
- X*/
- X
- X while (gatesleft > leftgates)
- X {
- X chosengate = RANDOM()%gatesleft;
- X
- X foundgate = 0;
- X
- X for (gatewalk = 0; gatewalk < possiblegates; gatewalk++)
- X {
- X if (gatewalk < (mazewidth-1)/2)
- X {
- X mazei = 0;
- X mazej = 2 * gatewalk + 1;
- X }
- X else
- X if (gatewalk < ((mazewidth-1)/2 + (mazeheight-1)/2))
- X {
- X mazei = 2 * (gatewalk - (mazewidth-1)/2) + 1;
- X mazej = mazewidth-1;
- X }
- X else
- X if (gatewalk < ((mazewidth-1) + (mazeheight-1)/2))
- X {
- X mazei = mazeheight-1;
- X mazej = 2 * (((mazewidth-1)/2)-
- X (gatewalk-((mazewidth-1)/2 + (mazeheight-1)/2))) + 1;
- X }
- X else
- X {
- X mazei = 2 * (((mazeheight-1)/2)-
- X (gatewalk-((mazewidth-1) + (mazeheight-1)/2))) + 1;
- X mazej = 0;
- X }
- X
- X/*
- X** fprintf(stderr,
- X** "gatesleft %d chosengate %d foundgate %d gatewalk %d",
- X** gatesleft,chosengate,foundgate,gatewalk);
- X** fprintf(sdterr," mazei %d mazej %d %c\n",
- X** mazei,mazej, cmaze[mazei][mazej]);
- X*/
- X
- X if ((cmaze[mazei][mazej] == VDOOR) || (cmaze[mazei][mazej] == HDOOR))
- X if (foundgate < chosengate)
- X foundgate++;
- X else
- X {
- X cmaze[mazei][mazej] = WALL;
- X gatesleft--;
- X break;
- X }
- X }
- X }
- X return;
- X}
- END_OF_FILE
- if test 2275 -ne `wc -c <'closegates.c'`; then
- echo shar: \"'closegates.c'\" unpacked with wrong size!
- fi
- # end of 'closegates.c'
- fi
- if test -f 'filllist.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'filllist.c'\"
- else
- echo shar: Extracting \"'filllist.c'\" \(1622 characters\)
- sed "s/^X//" >'filllist.c' <<'END_OF_FILE'
- X/*
- X** filllist.c Copyright 1991 Kent Paul Dolan,
- X** Mountain View, CA, USA 94039-0755
- X**
- X** Written to satisfy an inquiry on USENet's rec.games.programmer newsgroup.
- X** May be freely used or modified in any non-commercial work. Copyrighted
- X** only to prevent patenting by someone else.
- X*/
- X
- X#include <stdio.h>
- X#include "townmaze.h"
- X#include "townproto.h"
- X
- X#ifdef __STDC__
- Xvoid filllist()
- X#else
- Xint filllist()
- X#endif
- X{
- X int i;
- X
- X#if PROGRESS
- X fprintf(stderr,"Fill list ");
- X#endif
- X
- X
- X/*
- X** Everything starts in the isolated list; the others start empty.
- X*/
- X
- X isolated = 0;
- X live = NOPOINTER;
- X dead = NOPOINTER;
- X street = NOPOINTER;
- X unused = NOPOINTER;
- X
- X for (i = 0; i < listsize - 1; i++)
- X statlist[i].next = i+1;
- X statlist[listsize -1].next = NOPOINTER;
- X for (i = 1; i < listsize; i++)
- X statlist[i].prev = i-1;
- X statlist[0].prev = NOPOINTER;
- X for (i = 0; i < listsize; i++)
- X {
- X statlist[i].status = ISOLATED;
- X statlist[i].streetnum = -1;
- X statlist[i].streetdir = -1;
- X }
- X
- X isolatedct = listsize;
- X livect = 0;
- X deadct = 0;
- X streetct = 0;
- X unusedct = 0;
- X
- X/*
- X** Corner cells are too hard to use; get them off the list.
- X*/
- X
- X movefromto(&isolated,&isolatedct,&unused,&unusedct,UNUSED,0);
- X movefromto(&isolated,&isolatedct,&unused,&unusedct,UNUSED,
- X (mazewidth/2) - 1);
- X movefromto(&isolated,&isolatedct,&unused,&unusedct,UNUSED,
- X listsize-(mazewidth/2));
- X movefromto(&isolated,&isolatedct,&unused,&unusedct,UNUSED,listsize - 1);
- X
- X/*
- X** There are no streets yet, so the streetnumct is zero too.
- X*/
- X
- X streetnumct = 0;
- X
- X return;
- X}
- END_OF_FILE
- if test 1622 -ne `wc -c <'filllist.c'`; then
- echo shar: \"'filllist.c'\" unpacked with wrong size!
- fi
- # end of 'filllist.c'
- fi
- if test -f 'fillmaze.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'fillmaze.c'\"
- else
- echo shar: Extracting \"'fillmaze.c'\" \(1358 characters\)
- sed "s/^X//" >'fillmaze.c' <<'END_OF_FILE'
- X/*
- X** fillmaze.c Copyright 1991 Kent Paul Dolan,
- X** Mountain View, CA, USA 94039-0755
- X**
- X** Written to satisfy an inquiry on USENet's rec.games.programmer newsgroup.
- X** May be freely used or modified in any non-commercial work. Copyrighted
- X** only to prevent patenting by someone else.
- X*/
- X
- X#include <stdio.h>
- X#include "townmaze.h"
- X#include "townproto.h"
- X
- X#ifdef __STDC__
- Xvoid fillmaze()
- X#else
- Xint fillmaze()
- X#endif
- X{
- X int i, j;
- X
- X#if PROGRESS
- X fprintf(stderr,"Fill maze ");
- X#endif
- X
- X/*
- X** Fill maze with "wall" characters and "blank" characters,
- X** so that entire maze starts out as doorless rooms with walls
- X** between.
- X*/
- X
- X for (i = 0; i < mazeheight; i++)
- X for (j = 0; j < mazewidth; j++)
- X switch (((i%2)<<1) + (j%2))
- X {
- X case 0:
- X cmaze[i][j] = WALL;
- X break;
- X case 1:
- X cmaze[i][j] = WALL;
- X break;
- X case 2:
- X cmaze[i][j] = WALL;
- X break;
- X case 3:
- X cmaze[i][j] = BLANK;
- X break;
- X default:
- X fprintf(stderr,"failure in maze fill section\n");
- X freespace();
- X exit(1);
- X }
- X/*
- X** The corner cells are too hard to use, so nuke them in the drawing.
- X*/
- X
- X cmaze[1][1] = WALL;
- X cmaze[1][mazewidth - 2] = WALL;
- X cmaze[mazeheight - 2][1] = WALL;
- X cmaze[mazeheight -2][mazewidth - 2] = WALL;
- X
- X return;
- X}
- END_OF_FILE
- if test 1358 -ne `wc -c <'fillmaze.c'`; then
- echo shar: \"'fillmaze.c'\" unpacked with wrong size!
- fi
- # end of 'fillmaze.c'
- fi
- if test -f 'finishalleys.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'finishalleys.c'\"
- else
- echo shar: Extracting \"'finishalleys.c'\" \(1589 characters\)
- sed "s/^X//" >'finishalleys.c' <<'END_OF_FILE'
- X/*
- X** finishalleys.c Copyright 1991 Kent Paul Dolan,
- X** Mountain View, CA, USA 94039-0755
- X**
- X** Written to satisfy an inquiry on USENet's rec.games.programmer newsgroup.
- X** May be freely used or modified in any non-commercial work. Copyrighted
- X** only to prevent patenting by someone else.
- X*/
- X
- X#include <stdio.h>
- X#include "townmaze.h"
- X#include "townproto.h"
- X
- X#ifdef __STDC__
- Xvoid finishalleys()
- X#else
- Xint finishalleys()
- X#endif
- X{
- X
- X int i, nhbrid;
- X int livewalk, targetcell;
- X
- X#if PROGRESS
- X if (livect > 0) fprintf(stderr,"Alleys ");
- X#endif
- X
- X while(livect > 0)
- X {
- X targetcell = RANDOM()%livect;
- X livewalk = live;
- X for (i = 0; i < (targetcell - 1); i++)
- X if (livewalk == NOPOINTER)
- X {
- X fprintf(stderr,"live list too short in finishalleys\n");
- X showdebugmaze();
- X freespace();
- X exit(1);
- X }
- X else
- X {
- X livewalk = statlist[livewalk].next;
- X }
- X/*
- X** Since this is a live cell, it is supposed to have a street cell
- X** neighbor; find one and adopt its street number. If directions
- X** are implemented, then this has to be expanded to pick a random
- X** neighbor street fairly and adopt its number and direction.
- X** [Done in makestreet(), enabled by the "-1" last parameter.]
- X*/
- X for (nhbrid = 0; nhbrid < 4; nhbrid++)
- X if (nhbrexists(livewalk,nhbrid))
- X if (statlist[nhbris(livewalk,nhbrid)].status == STREET)
- X {
- X makestreet(livewalk,
- X statlist[nhbris(livewalk,nhbrid)].streetnum,-1);
- X break;
- X }
- X }
- X/* fprintf(stderr,"\n"); */
- X return;
- X}
- END_OF_FILE
- if test 1589 -ne `wc -c <'finishalleys.c'`; then
- echo shar: \"'finishalleys.c'\" unpacked with wrong size!
- fi
- # end of 'finishalleys.c'
- fi
- if test -f 'freespace.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'freespace.c'\"
- else
- echo shar: Extracting \"'freespace.c'\" \(980 characters\)
- sed "s/^X//" >'freespace.c' <<'END_OF_FILE'
- X/*
- X** freespace.c Copyright 1991 Kent Paul Dolan,
- X** Mountain View, CA, USA 94039-0755
- X**
- X** Written to satisfy an inquiry on USENet's rec.games.programmer newsgroup.
- X** May be freely used or modified in any non-commercial work. Copyrighted
- X** only to prevent patenting by someone else.
- X*/
- X
- X#include <stdio.h>
- X#include "townmaze.h"
- X#include "townproto.h"
- X
- X#ifdef __STDC__
- Xvoid freespace()
- X#else
- Xint freespace()
- X#endif
- X{
- X int i;
- X
- X#ifdef __STDC__
- X for (i = 0; i < mazeheight; i++)
- X if (free(cmaze[i]) == -1)
- X {
- X fprintf(stderr,"error freeing cmaze row; quitting freespace early\n");
- X exit(1);
- X }
- X if (free(cmaze) == -1)
- X {
- X fprintf(stderr,"error freeing cmaze body; quitting freespace early\n");
- X exit(1);
- X }
- X if (free(statlist) == -1)
- X {
- X fprintf(stderr,"error freeing statlist; quitting freespace early\n");
- X exit(1);
- X }
- X#else
- X for (i = 0; i < mazeheight; i++) free(cmaze[i]);
- X free(cmaze);
- X free(statlist);
- X#endif
- X return;
- X}
- END_OF_FILE
- if test 980 -ne `wc -c <'freespace.c'`; then
- echo shar: \"'freespace.c'\" unpacked with wrong size!
- fi
- # end of 'freespace.c'
- fi
- if test -f 'interiorcell.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'interiorcell.c'\"
- else
- echo shar: Extracting \"'interiorcell.c'\" \(577 characters\)
- sed "s/^X//" >'interiorcell.c' <<'END_OF_FILE'
- X/*
- X** interiorcell.c Copyright 1991 Kent Paul Dolan,
- X** Mountain View, CA, USA 94039-0755
- X**
- X** Written to satisfy an inquiry on USENet's rec.games.programmer newsgroup.
- X** May be freely used or modified in any non-commercial work. Copyrighted
- X** only to prevent patenting by someone else.
- X*/
- X
- X#include <stdio.h>
- X#include "townmaze.h"
- X#include "townproto.h"
- X
- X#ifdef __STDC__
- Xint interiorcell(int cellid)
- X#else
- Xint interiorcell(cellid)
- X int cellid;
- X#endif
- X{
- X int i;
- X for (i = 0; i < 4; i++)
- X if (!nhbrexists(cellid,i)) return (1==0);
- X return (1==1);
- X}
- END_OF_FILE
- if test 577 -ne `wc -c <'interiorcell.c'`; then
- echo shar: \"'interiorcell.c'\" unpacked with wrong size!
- fi
- # end of 'interiorcell.c'
- fi
- if test -f 'makecourts.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'makecourts.c'\"
- else
- echo shar: Extracting \"'makecourts.c'\" \(1742 characters\)
- sed "s/^X//" >'makecourts.c' <<'END_OF_FILE'
- X/*
- X** makecourts.c Copyright 1991 Kent Paul Dolan,
- X** Mountain View, CA, USA 94039-0755
- X**
- X** Written to satisfy an inquiry on USENet's rec.games.programmer newsgroup.
- X** May be freely used or modified in any non-commercial work. Copyrighted
- X** only to prevent patenting by someone else.
- X*/
- X
- X#include <stdio.h>
- X#include "townmaze.h"
- X#include "townproto.h"
- X
- X#ifdef __STDC__
- Xvoid makecourts()
- X#else
- Xint makecourts()
- X#endif
- X{
- X
- X int totalcells;
- X int chosencell;
- X int tries;
- X int i;
- X
- X/*
- X** Pepper courts around the city interior; keep them apart for algorithmic
- X** robustness reasons.
- X*/
- X
- X#if PROGRESS
- X fprintf(stderr,"Courts ");
- X#endif
- X
- X totalcells = ((mazeheight-1)/2 * (mazewidth-1)/2);
- X
- X for (i = 0; i < mazecourts; i++)
- X {
- X
- X/* fprintf(stderr,"Court %d\n",i); */
- X
- X/*
- X** Set up to prevent infinite loop from unforseen geometry problems.
- X*/
- X
- X tries = 0;
- X
- X/*
- X** Keep looking until a candidate cell is found for this ith court.
- X*/
- X do
- X {
- X /* not perfectly fair, but good enough for moderate sized mazes. */
- X chosencell = RANDOM()%totalcells;
- X
- X/* fprintf(stderr," chosencell %d\n",chosencell); */
- X
- X tries++;
- X
- X } while ( (tries <= MAXTRIES)
- X && (
- X (interiorcell(chosencell) != (1==1))
- X || (statlist[chosencell].status != ISOLATED)
- X || (statlist[nhbris(chosencell,0)].status != ISOLATED)
- X || (statlist[nhbris(chosencell,1)].status != ISOLATED)
- X || (statlist[nhbris(chosencell,2)].status != ISOLATED)
- X || (statlist[nhbris(chosencell,3)].status != ISOLATED)
- X )
- X );
- X
- X if (tries <= MAXTRIES) makestreet(chosencell,streetnumct++,RANDOM()%4);
- X }
- X return;
- X}
- END_OF_FILE
- if test 1742 -ne `wc -c <'makecourts.c'`; then
- echo shar: \"'makecourts.c'\" unpacked with wrong size!
- fi
- # end of 'makecourts.c'
- fi
- if test -f 'makegates.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'makegates.c'\"
- else
- echo shar: Extracting \"'makegates.c'\" \(2929 characters\)
- sed "s/^X//" >'makegates.c' <<'END_OF_FILE'
- X/*
- X** makegates.c Copyright 1991 Kent Paul Dolan,
- X** Mountain View, CA, USA 94039-0755
- X**
- X** Written to satisfy an inquiry on USENet's rec.games.programmer newsgroup.
- X** May be freely used or modified in any non-commercial work. Copyrighted
- X** only to prevent patenting by someone else.
- X*/
- X
- X#include <stdio.h>
- X#include "townmaze.h"
- X#include "townproto.h"
- X
- X#ifdef __STDC__
- Xvoid makegates()
- X#else
- Xint makegates()
- X#endif
- X{
- X
- X int gatewalls;
- X int chosenwall;
- X int chosencell;
- X int stdir;
- X int tries;
- X int i;
- X
- X/*
- X** Pepper gates around the outer wall; avoid gates at corners for
- X** esthetic reasons.
- X*/
- X
- X#if PROGRESS
- X fprintf(stderr,"Gates ");
- X#endif
- X
- X gatewalls = 2 * (mazeheight/2 + mazewidth/2);
- X
- X for (i = 0; i < mazegates; i++)
- X {
- X
- X/* fprintf(stderr,"Gate %d\n",i); */
- X
- X/*
- X** Protect against infinite looping.
- X*/
- X tries = 0;
- X/*
- X** Keep looking until a candidate cell is found for this ith gate.
- X*/
- X do
- X {
- X /* not perfectly fair, but good enough for moderate sized mazes. */
- X chosenwall = RANDOM()%gatewalls;
- X
- X/* fprintf(stderr," chosenwall %d\n",chosenwall); */
- X if (chosenwall < (mazewidth/2))
- X {
- X chosencell = chosenwall;
- X stdir = 2;
- X/* fprintf(stderr," top chosencell %d\n",chosencell); */
- X }
- X else
- X if (chosenwall < ((mazewidth/2) + (mazeheight/2)))
- X {
- X chosencell = ((chosenwall - (mazewidth/2) + 1)
- X * (mazewidth/2) - 1);
- X stdir = 3;
- X/* fprintf(stderr," right chosencell %d\n",chosencell); */
- X }
- X else
- X if (chosenwall < (mazewidth - 1 + (mazeheight/2)))
- X {
- X chosencell = (listsize - chosenwall + (mazewidth/2)
- X + (mazeheight/2) - 1);
- X stdir = 0;
- X/* fprintf(stderr," bottom chosencell %d\n",chosencell); */
- X }
- X else
- X {
- X chosencell = (mazewidth - 1 + mazeheight - 1 - chosenwall - 1)
- X * (mazewidth/2);
- X stdir = 1;
- X/* fprintf(stderr," left chosencell %d\n",chosencell); */
- X
- X }
- X tries++;
- X } while ( (tries <= MAXTRIES)
- X && ( (statlist[chosencell].status != ISOLATED)
- X || ( nhbrexists(chosencell,0)
- X && (statlist[nhbris(chosencell,0)].status != ISOLATED) )
- X || ( nhbrexists(chosencell,1)
- X && (statlist[nhbris(chosencell,1)].status != ISOLATED) )
- X || ( nhbrexists(chosencell,2)
- X && (statlist[nhbris(chosencell,2)].status != ISOLATED) )
- X || ( nhbrexists(chosencell,3)
- X && (statlist[nhbris(chosencell,3)].status != ISOLATED) )
- X )
- X );
- X
- X if (tries <= MAXTRIES) makestreet(chosencell,streetnumct++,stdir);
- X }
- X return;
- X}
- END_OF_FILE
- if test 2929 -ne `wc -c <'makegates.c'`; then
- echo shar: \"'makegates.c'\" unpacked with wrong size!
- fi
- # end of 'makegates.c'
- fi
- if test -f 'makespace.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'makespace.c'\"
- else
- echo shar: Extracting \"'makespace.c'\" \(1750 characters\)
- sed "s/^X//" >'makespace.c' <<'END_OF_FILE'
- X/*
- X** makespace.c Copyright 1991 Kent Paul Dolan,
- X** Mountain View, CA, USA 94039-0755
- X**
- X** Written to satisfy an inquiry on USENet's rec.games.programmer newsgroup.
- X** May be freely used or modified in any non-commercial work. Copyrighted
- X** only to prevent patenting by someone else.
- X*/
- X
- X#include <stdio.h>
- X#include "townmaze.h"
- X#include "townproto.h"
- X
- X#ifdef __STDC__
- Xvoid makespace()
- X#else
- Xint makespace()
- X#endif
- X{
- X int i,j;
- X
- X if ((statlist = (DLENODE *)malloc(listsize * sizeof(DLENODE))) == NULL)
- X {
- X fprintf(stderr,
- X "Unable to allocate space for cell list for that size maze\n");
- X exit(1);
- X }
- X
- X if ((cmaze = (char **)malloc(mazeheight * sizeof(char *))) == NULL)
- X {
- X fprintf(stderr,"%s%s",
- X "Unable to allocate space for maze display pointer list for that",
- X " size maze\n");
- X#ifdef __STDC__
- X if (free(statlist) == -1)
- X fprintf(stderr,"unable to free(statlist) on bailout\n");
- X#else
- X free(statlist);
- X#endif
- X
- X exit(1);
- X }
- X
- X for (i = 0; i < mazewidth; i++)
- X {
- X if ((cmaze[i] = (char *)malloc(mazewidth * sizeof(char))) == NULL)
- X {
- X fprintf(stderr,
- X "Unable to allocate space for maze char array for that size maze\n");
- X#ifdef __STDC__
- X for (j = 0; j < i; j++)
- X {
- X if (free(cmaze[j]) == -1)
- X {
- X fprintf(stderr,"unable to free(cmaze[%d]) on bailout\n",j);
- X break;
- X }
- X }
- X if (free(cmaze) == -1)
- X fprintf(stderr,"unable to free(cmaze) on bailout\n");
- X else
- X if (free(statlist) == -1)
- X fprintf(stderr,"unable to free(statlist) on bailout\n");
- X#else
- X for (j = 0; j < i; j++) free(cmaze[j]);
- X free(cmaze);
- X free(statlist);
- X#endif
- X exit(1);
- X }
- X }
- X
- X return;
- X}
- END_OF_FILE
- if test 1750 -ne `wc -c <'makespace.c'`; then
- echo shar: \"'makespace.c'\" unpacked with wrong size!
- fi
- # end of 'makespace.c'
- fi
- if test -f 'movefromto.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'movefromto.c'\"
- else
- echo shar: Extracting \"'movefromto.c'\" \(1495 characters\)
- sed "s/^X//" >'movefromto.c' <<'END_OF_FILE'
- X/*
- X** movefromto.c Copyright 1991 Kent Paul Dolan,
- X** Mountain View, CA, USA 94039-0755
- X**
- X** Written to satisfy an inquiry on USENet's rec.games.programmer newsgroup.
- X** May be freely used or modified in any non-commercial work. Copyrighted
- X** only to prevent patenting by someone else.
- X*/
- X
- X#include <stdio.h>
- X#include "townmaze.h"
- X#include "townproto.h"
- X
- X#ifdef __STDC__
- Xvoid movefromto(int *fromlist,int *fromcount,int *tolist,int *tocount,
- X int newstat,int cellnum)
- X#else
- Xint movefromto(fromlist,fromcount,tolist,tocount,newstat,cellnum)
- X int *fromlist;
- X int *fromcount;
- X int *tolist;
- X int *tocount;
- X int newstat;
- X int cellnum;
- X#endif
- X{
- X
- X int oldnext;
- X int oldprev;
- X
- X/*
- X** Save vital existing links.
- X*/
- X
- X oldnext = statlist[cellnum].next;
- X oldprev = statlist[cellnum].prev;
- X
- X/*
- X** Unlink cell from old position somewhere in fromlist.
- X*/
- X
- X if (statlist[cellnum].next != NOPOINTER)
- X statlist[oldnext].prev = statlist[cellnum].prev;
- X
- X if (statlist[cellnum].prev != NOPOINTER)
- X statlist[oldprev].next = statlist[cellnum].next;
- X else *fromlist = statlist[cellnum].next;
- X
- X/*
- X** Link cell into new position at head of tolist.
- X*/
- X
- X statlist[cellnum].next = *tolist;
- X
- X statlist[cellnum].prev = NOPOINTER;
- X
- X if (*tolist != NOPOINTER)
- X statlist[*tolist].prev = cellnum;
- X
- X *tolist = cellnum;
- X
- X/*
- X** Update list length counts.
- X*/
- X
- X (*fromcount)--;
- X (*tocount)++;
- X
- X/*
- X** update cell status
- X*/
- X
- X statlist[cellnum].status = newstat;
- X
- X return;
- X}
- END_OF_FILE
- if test 1495 -ne `wc -c <'movefromto.c'`; then
- echo shar: \"'movefromto.c'\" unpacked with wrong size!
- fi
- # end of 'movefromto.c'
- fi
- if test -f 'nhbrexists.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'nhbrexists.c'\"
- else
- echo shar: Extracting \"'nhbrexists.c'\" \(1175 characters\)
- sed "s/^X//" >'nhbrexists.c' <<'END_OF_FILE'
- X/*
- X** nhbrexists.c Copyright 1991 Kent Paul Dolan,
- X** Mountain View, CA, USA 94039-0755
- X**
- X** Written to satisfy an inquiry on USENet's rec.games.programmer newsgroup.
- X** May be freely used or modified in any non-commercial work. Copyrighted
- X** only to prevent patenting by someone else.
- X*/
- X
- X#include <stdio.h>
- X#include "townmaze.h"
- X#include "townproto.h"
- X
- X#ifdef __STDC__
- Xint nhbrexists(int cellid,int nhbrid)
- X#else
- Xint nhbrexists(cellid,nhbrid)
- X int cellid, nhbrid;
- X#endif
- X{
- X int celli, cellj;
- X
- X celli = cellid / (mazewidth/2);
- X cellj = cellid % (mazewidth/2);
- X
- X switch (nhbrid)
- X {
- X case 0: /* too far north? */
- X return (((celli - 1) < 0) ? (1==0) : (1==1));
- X break;
- X
- X case 1: /* too far east? */
- X return (((cellj + 1) >= (mazewidth/2)) ? (1==0) : (1==1));
- X break;
- X
- X case 2: /* too far south? */
- X return (((celli + 1) >= (mazeheight/2)) ? (1==0) : (1==1));
- X break;
- X
- X case 3:/* too far west? */
- X return (((cellj - 1) < 0) ? (1==0) : (1==1));
- X break;
- X
- X default:
- X fprintf(stderr,"bad neighbor id value to nhbrexists %d\n",nhbrid);
- X showdebugmaze();
- X freespace();
- X exit(1);
- X }
- X}
- END_OF_FILE
- if test 1175 -ne `wc -c <'nhbrexists.c'`; then
- echo shar: \"'nhbrexists.c'\" unpacked with wrong size!
- fi
- # end of 'nhbrexists.c'
- fi
- if test -f 'nhbris.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'nhbris.c'\"
- else
- echo shar: Extracting \"'nhbris.c'\" \(1127 characters\)
- sed "s/^X//" >'nhbris.c' <<'END_OF_FILE'
- X/*
- X** nhbris.c Copyright 1991 Kent Paul Dolan,
- X** Mountain View, CA, USA 94039-0755
- X**
- X** Written to satisfy an inquiry on USENet's rec.games.programmer newsgroup.
- X** May be freely used or modified in any non-commercial work. Copyrighted
- X** only to prevent patenting by someone else.
- X*/
- X
- X#include <stdio.h>
- X#include "townmaze.h"
- X#include "townproto.h"
- X
- X#ifdef __STDC__
- Xint nhbris(int cellid,int nhbrid)
- X#else
- Xint nhbris(cellid,nhbrid)
- X int cellid, nhbrid;
- X#endif
- X{
- X int celli, cellj;
- X
- X celli = cellid / (mazewidth/2);
- X cellj = cellid % (mazewidth/2);
- X
- X switch (nhbrid)
- X {
- X case 0:
- X return ( ( (celli - 1) * (mazewidth/2) ) + cellj ); /* north nhbr */
- X break;
- X case 1:
- X return ( ( celli * (mazewidth/2) ) + cellj + 1); /* east nhbr */
- X break;
- X case 2:
- X return ( ( (celli + 1) * (mazewidth/2) ) + cellj ); /* south nhbr */
- X break;
- X case 3:
- X return ( ( celli * (mazewidth/2) ) + cellj - 1); /* west nhbr */
- X break;
- X default:
- X fprintf(stderr,"bad neighbor id value to nhbris %d\n",nhbrid);
- X showdebugmaze();
- X freespace();
- X exit(1);
- X }
- X}
- END_OF_FILE
- if test 1127 -ne `wc -c <'nhbris.c'`; then
- echo shar: \"'nhbris.c'\" unpacked with wrong size!
- fi
- # end of 'nhbris.c'
- fi
- if test -f 'showdbmaze.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'showdbmaze.c'\"
- else
- echo shar: Extracting \"'showdbmaze.c'\" \(1837 characters\)
- sed "s/^X//" >'showdbmaze.c' <<'END_OF_FILE'
- X/*
- X** showdbmaze.c Copyright 1991 Kent Paul Dolan,
- X** Mountain View, CA, USA 94039-0755
- X**
- X** Written to satisfy an inquiry on USENet's rec.games.programmer newsgroup.
- X** May be freely used or modified in any non-commercial work. Copyrighted
- X** only to prevent patenting by someone else.
- X*/
- X
- X#include <stdio.h>
- X#include "townmaze.h"
- X#include "townproto.h"
- X
- X#ifdef __STDC__
- Xvoid showdebugmaze()
- X#else
- Xint showdebugmaze()
- X#endif
- X{
- X int i, j, cellid;
- X
- X/*
- X** Draw the character version of the maze to stdout.
- X*/
- X
- X fprintf(stdout,"\n");
- X for (i = 0; i < mazeheight; i++)
- X {
- X for (j = 0; j < mazewidth; j++)
- X if (((i%2)==1)&&((j%2)==1))
- X {
- X cellid = (i/2)*(mazewidth/2)+(j/2);
- X switch (statlist[cellid].status)
- X {
- X case ISOLATED:
- X fprintf(stdout,"%c",'I');
- X break;
- X case LIVE:
- X fprintf(stdout,"%c",'L');
- X break;
- X case DEAD:
- X fprintf(stdout,"%c",'D');
- X break;
- X case STREET:
- X switch (statlist[cellid].streetdir)
- X {
- X case -1:
- X fprintf(stdout,"%c",BLANK);
- X break;
- X case 0:
- X fprintf(stdout,"%c",'^');
- X break;
- X case 1:
- X fprintf(stdout,"%c",'>');
- X break;
- X case 2:
- X fprintf(stdout,"%c",'v');
- X break;
- X case 3:
- X fprintf(stdout,"%c",'<');
- X break;
- X default:
- X fprintf(stdout,"%c",'X');
- X }
- X break;
- X case UNUSED:
- X fprintf(stdout,"%c",'U');
- X break;
- X default:
- X fprintf(stdout,"%c",'?');
- X }
- X }
- X else
- X fprintf(stdout,"%c",cmaze[i][j]);
- X fprintf(stdout,"\n");
- X }
- X return;
- X}
- END_OF_FILE
- if test 1837 -ne `wc -c <'showdbmaze.c'`; then
- echo shar: \"'showdbmaze.c'\" unpacked with wrong size!
- fi
- # end of 'showdbmaze.c'
- fi
- if test -f 'showlistdet.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'showlistdet.c'\"
- else
- echo shar: Extracting \"'showlistdet.c'\" \(1206 characters\)
- sed "s/^X//" >'showlistdet.c' <<'END_OF_FILE'
- X/*
- X** showlistdet.c Copyright 1991 Kent Paul Dolan,
- X** Mountain View, CA, USA 94039-0755
- X**
- X** Written to satisfy an inquiry on USENet's rec.games.programmer newsgroup.
- X** May be freely used or modified in any non-commercial work. Copyrighted
- X** only to prevent patenting by someone else.
- X*/
- X
- X#include <stdio.h>
- X#include "townmaze.h"
- X#include "townproto.h"
- X
- X#ifdef __STDC__
- Xvoid showlistdetail()
- X#else
- Xint showlistdetail()
- X#endif
- X{
- X
- X int i, j;
- X
- X for (i = 0; i < (mazeheight/2); i++)
- X {
- X for (j = 0; j < (mazewidth/2); j++)
- X fprintf(stderr,"%4d ",statlist[j + ((mazewidth/2)*i)].prev);
- X fprintf(stderr,"\n");
- X
- X for (j = 0; j < (mazewidth/2); j++)
- X fprintf(stderr,"%4d ",statlist[j + ((mazewidth/2)*i)].next);
- X fprintf(stderr,"\n");
- X
- X for (j = 0; j < (mazewidth/2); j++)
- X fprintf(stderr,"%4d ",statlist[j + ((mazewidth/2)*i)].status);
- X fprintf(stderr,"\n");
- X
- X for (j = 0; j < (mazewidth/2); j++)
- X fprintf(stderr,"%4d ",statlist[j + ((mazewidth/2)*i)].streetnum);
- X fprintf(stderr,"\n");
- X
- X for (j = 0; j < (mazewidth/2); j++)
- X fprintf(stderr,"%4d ",statlist[j + ((mazewidth/2)*i)].streetdir);
- X fprintf(stderr,"\n\n");
- X
- X }
- X return;
- X}
- END_OF_FILE
- if test 1206 -ne `wc -c <'showlistdet.c'`; then
- echo shar: \"'showlistdet.c'\" unpacked with wrong size!
- fi
- # end of 'showlistdet.c'
- fi
- if test -f 'showlistsum.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'showlistsum.c'\"
- else
- echo shar: Extracting \"'showlistsum.c'\" \(1017 characters\)
- sed "s/^X//" >'showlistsum.c' <<'END_OF_FILE'
- X/*
- X** showlistsum.c Copyright 1991 Kent Paul Dolan,
- X** Mountain View, CA, USA 94039-0755
- X**
- X** Written to satisfy an inquiry on USENet's rec.games.programmer newsgroup.
- X** May be freely used or modified in any non-commercial work. Copyrighted
- X** only to prevent patenting by someone else.
- X*/
- X
- X#include <stdio.h>
- X#include "townmaze.h"
- X#include "townproto.h"
- X
- X#ifdef __STDC__
- Xvoid showlistsummary()
- X#else
- Xint showlistsummary()
- X#endif
- X{
- X fprintf(stderr,"ISOLATED = %5d isolated = %5d isolatedct = %5d\n",
- X ISOLATED,isolated,isolatedct);
- X fprintf(stderr,"LIVE = %5d live = %5d livect = %5d\n",
- X LIVE,live,livect);
- X fprintf(stderr,"DEAD = %5d dead = %5d deadct = %5d\n",
- X DEAD,dead,deadct);
- X fprintf(stderr,
- X "STREET = %5d street = %5d streetct = %5d streetnumct %5d\n",
- X STREET,street,streetct,streetnumct);
- X fprintf(stderr,"UNUSED = %5d unused = %5d unusedct = %5d\n",
- X UNUSED,unused,unusedct);
- X return;
- X}
- X
- END_OF_FILE
- if test 1017 -ne `wc -c <'showlistsum.c'`; then
- echo shar: \"'showlistsum.c'\" unpacked with wrong size!
- fi
- # end of 'showlistsum.c'
- fi
- if test -f 'showmaze.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'showmaze.c'\"
- else
- echo shar: Extracting \"'showmaze.c'\" \(706 characters\)
- sed "s/^X//" >'showmaze.c' <<'END_OF_FILE'
- X/*
- X** showmaze.c Copyright 1991 Kent Paul Dolan,
- X** Mountain View, CA, USA 94039-0755
- X**
- X** Written to satisfy an inquiry on USENet's rec.games.programmer newsgroup.
- X** May be freely used or modified in any non-commercial work. Copyrighted
- X** only to prevent patenting by someone else.
- X*/
- X
- X#include <stdio.h>
- X#include "townmaze.h"
- X#include "townproto.h"
- X
- X#ifdef __STDC__
- Xvoid showmaze()
- X#else
- Xint showmaze()
- X#endif
- X{
- X int i, j;
- X
- X/*
- X** Draw the character version of the maze to stdout.
- X*/
- X
- X#if PROGRESS
- X fprintf(stdout,"\n");
- X#endif
- X
- X for (i = 0; i < mazeheight; i++)
- X {
- X for (j = 0; j < mazewidth; j++)
- X fprintf(stdout,"%c",cmaze[i][j]);
- X fprintf(stdout,"\n");
- X }
- X return;
- X}
- END_OF_FILE
- if test 706 -ne `wc -c <'showmaze.c'`; then
- echo shar: \"'showmaze.c'\" unpacked with wrong size!
- fi
- # end of 'showmaze.c'
- fi
- if test -f 'townmain.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'townmain.c'\"
- else
- echo shar: Extracting \"'townmain.c'\" \(996 characters\)
- sed "s/^X//" >'townmain.c' <<'END_OF_FILE'
- X/*
- X** townmain.c Copyright 1991 Kent Paul Dolan,
- X** Mountain View, CA, USA 94039-0755
- X**
- X** Written to satisfy an inquiry on USENet's rec.games.programmer newsgroup.
- X** May be freely used or modified in any non-commercial work. Copyrighted
- X** only to prevent patenting by someone else.
- X*/
- X
- X#include <stdio.h>
- X#define MAINLINE 1
- X#include "townmaze.h"
- X#include "townproto.h"
- X
- X#ifdef __STDC__
- Xvoid main(int argc,char *argv[])
- X#else
- Xint main(argc,argv)
- X int argc;
- X char *argv[];
- X#endif
- X{
- X
- X SEEDRANDOM(randomseed = time(0));
- X getargs(argc,argv);
- X makespace();
- X fillmaze();
- X filllist();
- X makeunused();
- X makegates();
- X makecourts();
- X#if SHOWSTART
- X showdebugmaze();
- X#endif
- X connectstreets();
- X finishalleys();
- X closedoors();
- X closegates();
- X cleanupmap();
- X/*
- X#if PROGRESS
- X fprintf(stderr,"\n");
- X#endif
- X showlistsummary();
- X showlistdetail();
- X*/
- X#if SHOWEND
- X#if PROGRESS
- X fprintf(stderr,"\n");
- X#endif
- X showdebugmaze();
- X#endif
- X showmaze();
- X freespace();
- X/*
- X*/
- X exit(0);
- X}
- END_OF_FILE
- if test 996 -ne `wc -c <'townmain.c'`; then
- echo shar: \"'townmain.c'\" unpacked with wrong size!
- fi
- # end of 'townmain.c'
- fi
- if test -f 'townmaze.with' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'townmaze.with'\"
- else
- echo shar: Extracting \"'townmaze.with'\" \(360 characters\)
- sed "s/^X//" >'townmaze.with' <<'END_OF_FILE'
- Xfrom
- Xlib:c.o
- Xcleanupmap.o
- Xclosedoors.o
- Xclosegates.o
- Xconnectst.o
- Xfilllist.o
- Xfillmaze.o
- Xfinishalleys.o
- Xfreespace.o
- Xgetargs.o
- Xinteriorcell.o
- Xmakegates.o
- Xmakecourts.o
- Xmakespace.o
- Xmakestreet.o
- Xmakeunused.o
- Xmovefromto.o
- Xnhbrexists.o
- Xnhbris.o
- Xshowdbmaze.o
- Xshowlistdet.o
- Xshowlistsum.o
- Xshowmaze.o
- Xtownmain.o
- Xusage.o
- Xlib
- Xlib:lcm.lib
- Xlib:lc.lib
- Xlib:amiga.lib
- Xto
- Xtownmaze
- END_OF_FILE
- if test 360 -ne `wc -c <'townmaze.with'`; then
- echo shar: \"'townmaze.with'\" unpacked with wrong size!
- fi
- # end of 'townmaze.with'
- fi
- if test -f 'usage.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'usage.c'\"
- else
- echo shar: Extracting \"'usage.c'\" \(2052 characters\)
- sed "s/^X//" >'usage.c' <<'END_OF_FILE'
- X/*
- X** usage.c Copyright 1991 Kent Paul Dolan,
- X** Mountain View, CA, USA 94039-0755
- X**
- X** Written to satisfy an inquiry on USENet's rec.games.programmer newsgroup.
- X** May be freely used or modified in any non-commercial work. Copyrighted
- X** only to prevent patenting by someone else.
- X*/
- X
- X#include <stdio.h>
- X#include "townmaze.h"
- X#include "townproto.h"
- X
- X#ifdef __STDC__
- Xvoid usage()
- X#else
- Xint usage()
- X#endif
- X{
- X/*
- X** Sorry about the format here; beats breaking the lines in unnatural places.
- X*/
- X fprintf(stderr,"%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
- X"Usage: townmaze [-h #] [-w #] [-g #] [-l #] [-c #] [-u #] [-s #] [-r #]\n",
- X"Where: -h = height of maze in characters; minimum is 11, must be odd;\n",
- X" -w = width of maze in characters; minimum is 11, must be odd;\n",
- X" -g = gates in maze; how many streets start at city wall,\n",
- X" maximum is 2 * (height - 6)/7 + 2 (width - 6)/7;\n",
- X" lots of gates get rid of outer prominade;\n",
- X" -l = leave # gates openable; rest are made back into walls at\n",
- X" end of maze design processing, range is 0 to g;\n",
- X" -c = courts in maze; how many streets start inside the city;\n",
- X" maximum is (((height - 5)/6)*((width - 5)/6));\n",
- X" courts make more complex mazes at the expense of density;\n",
- X" -u = unused cells in maze; adds interesting shapes; maximum of\n",
- X" (((height-1)/14)*((width-1)/14)) is allowed, to preserve\n",
- X" connectivity of streets by leaving three cells between\n",
- X" unused cells so that streets can get past them;\n",
- X" -s = straightness of streets, range 0 to 998; straighter streets\n",
- X" make for more buildings, denser maze.\n",
- X" -r = force this random number routine seed to get the same maze\n",
- X" as the last time this seed was used.\n",
- X"There must be at least one gate or court; Copyright 1991,\n",
- X"Spaces between flags and values are mandatory!! Kent Paul Dolan.\n");
- X return;
- X}
- END_OF_FILE
- if test 2052 -ne `wc -c <'usage.c'`; then
- echo shar: \"'usage.c'\" unpacked with wrong size!
- fi
- # end of 'usage.c'
- fi
- echo shar: End of archive 1 \(of 4\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 2 3 4 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 4 archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-