home *** CD-ROM | disk | FTP | other *** search
- From decwrl!ucbvax!tut.cis.ohio-state.edu!unmvax!pprg.unm.edu!hc!lll-winken!uunet!allbery Sat Mar 25 19:44:32 PST 1989
- Article 848 of comp.sources.misc:
- Path: decwrl!ucbvax!tut.cis.ohio-state.edu!unmvax!pprg.unm.edu!hc!lll-winken!uunet!allbery
- From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
- Newsgroups: comp.sources.misc
- Subject: v06i079: Random Name Generator for RPGs
- Message-ID: <51484@uunet.UU.NET>
- Date: 25 Mar 89 17:03:35 GMT
- Sender: allbery@uunet.UU.NET
- Reply-To: slocum@hi-csc.UUCP
- Lines: 231
- Approved: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
-
- Posting-number: Volume 6, Issue 79
- Submitted-by: slocum@hi-csc.UUCP
- Archive-name: rndname
-
- This program is a very simple random name generator for use
- with roleplaying games. It produces surprisingly good names
- for the very simple method used. The names tend to be exotic,
- since 'X' and 'Z' have the same chance of coming up as 'T' and
- 'N'. Many of the names have a Japanese or African flavor. Some
- of my favorites came in the first page generated: Zozaras, Lyxam,
- Rux, and Zelica.
-
- The program 'name.c' produces the names, and two scripts are
- included to formats them into pages: names.csh and names.sh,
- for C-shell and Bourne shell, respectively. Instructions for
- changing the distribution of letters are given in comments in
- name.c.
-
- These programs have been tested on an Apollo DN330 with both
- BSD4.2 and Sys V, and on BSD4.3. The makefile and names.csh
- script have Sys V versions commented out. The changes for
- MS-DOS similar to the ones used here have been tested, but
- the specific changes for MS-DOS in this program have not.
-
- Send any changes or updates to me:
-
- Brett Slocum UUCP: ...uunet!hi-csc!slocum
- Arpa: hi-csc!slocum@uunet.uu.net
- "My name is Inigo Montoya. You killed my father. Prepare to die."
-
- #--------------------------------CUT HERE-------------------------------------
-
- # This is a shell archive. Remove anything before this line, then
- # unpack it by saving it in a file and typing "sh file". (Files
- # unpacked will be owned by you and have default permissions.)
- #
- # This archive contains:
- # README Makefile name.c names.csh names.sh
-
- echo x - README
- cat > "README" << '//E*O*F README//'
- This program is a very simple random name generator for use
- with roleplaying games. It produces surprisingly good names
- for the very simple method used. The names tend to be exotic,
- since 'X' and 'Z' have the same chance of coming up as 'T' and
- 'N'. Many of the names have a Japanese or African flavor. Some
- of my favorites came in the first page generated: Zozaras, Lyxam,
- Rux, and Zelica.
-
- The program 'name.c' produces the names, and two scripts are
- included to formats them into pages: names.csh and names.sh,
- for C-shell and Bourne shell, respectively. Instructions for
- changing the distribution of letters are given in comments in
- name.c.
-
- These programs have been tested on an Apollo DN330 with both
- BSD4.2 and Sys V, and on BSD4.3. The makefile and names.csh
- script have Sys V versions commented out. The changes for
- MS-DOS similar to the ones used here have been tested, but
- the specific changes for MS-DOS in this program have not.
-
- Send any changes or updates to me:
-
- Brett Slocum UUCP: ...uunet!hi-csc!slocum
- Arpa: hi-csc!slocum@uunet.uu.net
- "My name is Inigo Montoya. You killed my father. Prepare to die."
-
- //E*O*F README//
-
- echo x - Makefile
- cat > "Makefile" << '//E*O*F Makefile//'
- # makefile for name.c
- #
- # Comment out the BSD line if you're on System V
- # Comment out the SYSV line if you're using Berkely Unix.
-
- # SYSTEM = -DSYSV
- SYSTEM = -DBSD
-
- CFLAGS = -O $(SYSTEM)
-
- name: name.c
- cc -o name $(CFLAGS) name.c
-
- //E*O*F Makefile//
-
- echo x - name.c
- cat > "name.c" << '//E*O*F name.c//'
- /**************************************************************************
- * name - prints random names *
- * Copyright 1988 by Brett Slocum. All rights reserved. *
- * Permission is granted to distribute, modify, or use portions of this *
- * code in other programs, as long as this notice remains intact. *
- * This program or its derivatives may not be sold for profit without *
- * permission. *
- * *
- * UNIX Version: Brett Slocum UUCP: ...uunet!hi-csc!slocum *
- * ARPA: slocum@hi-csc.honeywell.com *
- * Changes were suggested by Geoff Kimbrough <geoff@ism780c.isc.com> *
- * *
- * IBM Microsoft C v5.0 changes by Loyd Blankenship on 11-15-88 *
- * UUCP: ...rutgers.edu!cs.utexas.edu!nth!loyd *
- * *
- * Version 2 by Brett Slocum 3/22/89 : various cleanups, features, etc. *
- * *
- **************************************************************************/
-
- #ifdef SYSV
- #include <string.h>
- #define srandom srand48
- #define random lrand48
- #endif
-
- #ifdef BSD
- #include <strings.h>
- #endif
-
- #ifdef MSC
- #include <string.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #define srandom srand
- #define random rand
- #endif
-
- #include <ctype.h>
-
- #define YES 1
- #define NO 0
- #define MAXNAME 30
- #define MINLENGTH 3
- #define RANGE 6
- #define rnd(n) (unsigned)(random() % (n))
-
- /*
- Since "y" appears twice, once in each array, all other
- letters, except "'", are doubled to keep the distribution even.
- By adding or deleting the letters from these arrays, you
- can change the frequency of appearance of the letters,
- (i.e. by adding "e" and "t" and deleting "z" and "q",
- a distribution closer to English could be made.)
- An interesting idea would be to use as many repetitions
- of each letter as are found in a Scrabble (tm) game.
- */
-
- char vowels[] = "aaeeiioouuy'";
- char cons[] = "bbccddffgghhjjkkllmmnnppqqrrssttvvwwxxyzz'";
-
- main(argc, argv)
- int argc;
- char *argv[];
- {
- int n, letters, vowel;
- char name[MAXNAME];
-
- if (argc == 2) {
- /* initialize random number generator */
- srandom(time(0L));
-
- /* generate argv[1] names */
- for (n = atoi(argv[1]); n > 0; n--) {
- name[0] = '\0';
- /* choose whether first character is a vowel */
- vowel = (rnd(2) ? YES : NO);
- /* get initial character - not " ' " */
- if (vowel)
- strncat(name, &vowels[rnd(sizeof(vowels) - 2)], 1);
- else
- strncat(name, &cons[rnd(sizeof(cons) - 2)], 1);
- /* upper case first letter */
- name[0] = _toupper(name[0]);
- /* complete rest of letters */
- for (letters = rnd(RANGE) + MINLENGTH; letters > 0; letters--) {
- /* alternate vowels and consonants */
- vowel = ( vowel ? NO : YES );
- /* get next character */
- if (vowel)
- strncat(name, &vowels[rnd(sizeof(vowels)-1)], 1);
- else
- strncat(name, &cons[rnd(sizeof(cons)-1)], 1);
- }
- printf("%s\n", name);
- }
- }
- else
- printf("Usage: name number-of-names\n");
- }
-
- //E*O*F name.c//
-
- echo x - names.csh
- cat > "names.csh" << '//E*O*F names.csh//'
- #! /bin/csh
- # names - generate random names
- #
- # usage: names [pages]
-
- # bsd script -- uncomment these lines if bsd
-
- if ($#argv == 0) then
- name 336 | sort -u | pr -6 | expand
- else
- @ n = 336 * $1
- name $n | sort -u | pr -6 | expand
- endif
-
- # sysv script -- uncomment these lines if sysv
- # note: no tab expansion performed
-
- #if ($#argv == 0) then
- # name 336 | sort -u | pr -6
- #else
- # @ n = 336 * $1
- # name $n | sort -u | pr -6
- #endif
-
- //E*O*F names.csh//
-
- echo x - names.sh
- cat > "names.sh" << '//E*O*F names.sh//'
- if [ $# = 0 ]
- then
- name 336 | sort -u | pr -6
- else
- n=`expr 336 \* $1`
- name $n | sort -u | pr -6
- fi
- //E*O*F names.sh//
-
- exit 0
-
-
-