Source code to Aslan Name Generator

By Raven ·

TML message #2421From bundle 199

	What with all the recent posting of binary name generators, and my
recent postings of the C source code to various generic name generators, I
decided to see if I could adopt one of them to the traveller name tables system.
	So far I've made it for Aslan and Vargr, but since if I recal a binary
was posted for Vargr (not sure here) , though only ussable for PC's, I'll
start off with the C code for the Aslan one (yes, I speak with run on sentances
that too... :-) ) . With a little modification anybody with a C compiler should
be able to get this to work, and modifying it for the other name tables used
in Traveller should be simple.

		---Raven
- - -----------------------CUT-----HERE---------------------------------------------
#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 MAXNAME 80

/* If you decide to use the tables in Alien module
 * you should use make SYLLABLES 6 instead of 3, but personally I find
 * that anything over 3-4 syllables comes out unpronouncable, the alien
 * modules probably used 1d6 only because Traveller sticks to d6 so
 * strongly */

#define SYLLABLES 3
#define rnd(n) (unsigned)(random() % (n))

/*
 * By [email removed]
 *	AKA Raven B.
 *
 * This version generates Aslan syllables, then put those
 * syllables together into a word.
 * The tables below were made from the Aslan sound frequency table in Alien
 * module 1.
 * Which is of course, copyrighted material, etc,etc...
 */

char           *vowels[] =
{
	"a",
	"a",
	"a",
	"a",
	"a",
	"a",
	"a",
	"a",
	"a",
	"ai",
	"ai",
	"ai",
	"ao",
	"ao",
	"au",
	"e",
	"e",
	"e",
	"e",
	"e",
	"e",
	"ea",
	"ea",
	"ea",
	"ea",
	"ea",
	"ea",
	"ei",
	"ei",
	"i",
	"i",
	"i",
	"i",
	"iy",
	"iy",
	"iy",
	"o",
	"o",
	"oa",
	"oi",
	"oi",
	"ou",
	"u",
	"ua",
	"ui",
	"ya",
	"yu",
	"a",
/*	"'",*/
	0
};
/* initail consonants */
char	       *incons[] =
{
	"f",
	"f",
	"f",
	"f",
	"f",
	"f",
	"ft",
	"ft",
	"ft",
	"ft",
	"h",
	"h",
	"h",
	"h",
	"h",
	"h",
	"h",
	"hf",
	"hf",
	"hk",
	"hk",
	"hk",
	"hk",
	"hk",
	"hl",
	"hl",
	"hl",
	"hr",
	"hr",
	"hr",
	"ht",
	"ht",
	"ht",
	"ht",
	"ht",
	"hw",
	"hw",
	"k",
	"k",
	"k",
	"k",
	"k",
	"k",
	"k",
	"kh",
	"kh",
	"kh",
	"kh",
	"kh",
	"kh",
	"kht",
	"kht",
	"kht",
	"kht",
	"kt",
	"kt",
	"kt",
	"kt",
	"l",
	"l",
	"r",
	"r",
	"r",
	"s",
	"s",
	"s",
	"s",
	"st",
	"st",
	"st",
	"t",
	"t",
	"t",
	"t",
	"t",
	"t",
	"t",
	"t",
	"tl",
	"tl",
	"tr",
	"tr",
	"w",
	"w",
	"w",
	"w",
	"w",
	"w",
	0
};
/* final consonants */
char           *cons[] =
{
	"h",
	"h",
	"h",
	"h",
	"h",
	"h",
	"h",
	"h",
	"h",
	"h",
	"kh",
	"kh",
	"kh",
	"kh",
	"l",
	"l",
	"l",
	"l",
	"l",
	"l",
	"l",
	"lr",
	"lr",
	"lr",
	"r",
	"r",
	"r",
	"r",
	"r",
	"rl",
	"rl",
	"rl",
	"rl",
	"s",
	"s",
	"s",
	"s",
	"s",
	"w",
	"w",
	"w",
	"w",
	"w",
	"w",
	"'",
	"'",
	"'",
	0
};

int	lengthof(ar)
char	**ar;
{
	int	n = 0;

	while (*ar)
	{
		n++;
		ar++;
	}
	return (n);
}

main(argc, argv)
int	argc;
char	*argv[];
{
	int	n;
	int	letters;
	int	vowel;
	int	numvowels;
	int	numcons;
	int	numincons;
	int 	maybe;
	int	scount;
	int	wordlen;
	char	name[MAXNAME];

	numvowels = lengthof(vowels);
	numcons = lengthof(cons);
	numincons = lengthof(incons);

	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';
			maybe = (rnd(3));
			/* choose whether first character is a vowel */
	 	   for (wordlen = rnd(SYLLABLES)+1;
			wordlen > 0; wordlen--)
		/* for wordlen times, construct the following syllables */
		   {
				if(maybe == 1) {
				    strcat(name, incons[rnd(numincons)]);
				     maybe = 0; }
				else if(maybe == 2) {
				    strcat(name, incons[rnd(numincons)]);
				     maybe = 0;
				} else {
				    strcat(name, vowels[rnd(numvowels)]);
				     maybe = (rnd(2)+1); }


			/* complete rest of letters */
			/* incons is only used for first consonant */
			/* cons is only used for second, if any, consonant */
			for (scount = rnd(2)+1; scount > 0; scount--)
			{
				/* alternate vowels and consonants */

				/* get next character */
				if (!maybe) {
					strcat(name, vowels[rnd(numvowels)]);
				         maybe = (rnd(2)+1); }
				else if(maybe == 1) {
					strcat(name, cons[rnd(numcons)]);
				          maybe = 0;
					  scount--; }
				else {
				    strcat(name, cons[rnd(numcons)]);
				     maybe = 0;
				     scount--; }

			}
		   }
			/* upper case first letter */
			name[0] = toupper(name[0]);
			printf("%s\n", name);
		}
	}
	else
		printf("Usage: name number-of-names\n");
}
- - --------------------------CUT----HERE-------------------------------------------