Here is the source code for the Vargr word generator. I kinda rushed this out,
and jotted down a short doc file for it, so if you have any problems, send mail
to me or the list. This file has been shar'ed (with HP-UX shar), and you need
to save this file, cut out the heading and unshar it due to the directions
below...
Hope ya like it... It's freeware!
Dave
#---------------------------------- 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".
#
# Wrapped by Dave (Unix Hero) [email removed] on Mon Jun 10 16:07:26 1991
#
# This archive contains:
# vargr.c vargr.doc vcon1.c vcon2.c
# vmain.c vvow.c
#
LANG=""; export LANG
PATH=/bin:/usr/bin:$PATH; export PATH
echo x - vargr.c
cat >vargr.c <<'@EOF'
/* Vargr word generator -- Copyright by David Boddie ([email removed]) */
/* Consent is granted to copy this code and change it however you wish, how */
/* ever, if you wish to sell it, you will have to write me.. */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include "vmain.c"
#include "vcon1.c"
#include "vvow.c"
#include "vcon2.c"
#define DIE 6
#define CONS 'C'
#define VOW 'V'
char *string[6], *wordstring;
char rc, *ptr;
int syllen;
int Random();
char *GetICons();
char *GetFCons();
char *GetVow();
main(argc,argv)
int argc;
char *argv[];
{
int red, white, i, j, count, maxsyl;
static int syllables;
if(argc >= 2) {
srand(time(0L));
for(count=0;count<atoi(argv[1]);count++) {
syllables = (int) Random(DIE);
if(argv[2] != NULL)
maxsyl = atoi(argv[2]);
if(maxsyl > 0 && maxsyl <= 6)
syllables = maxsyl;
for (i=0; i<syllables; i++) {
red = Random(DIE) - 1;
white = Random(DIE) - 1;
if(i != 0)
rc = *(string[i-1]+strlen(string[i-1])-1);
if(i==0 || rc == CONS) {
string[i] = basic[red][white];
}
else {
string[i] = alt[red][white];
}
} /* End of Loop */
string[i] = '\0';
wordstring = malloc((syllables * 9)+1);
*wordstring = '\0';
for(i=0;i<syllables;i++) {
syllen = strlen(string[i]);
for(j=0;j<syllen;j++) {
rc = *(string[i]+j);
if(j==0 && rc == CONS) {
red = Random(DIE);
ptr = GetICons(red);
strcat(wordstring,ptr);
}
else if(j != 0 && rc == CONS) {
red = Random(DIE);
ptr = GetFCons(red);
strcat(wordstring,ptr);
}
if(rc == VOW) {
red = Random(DIE);
ptr = GetVow(red);
strcat(wordstring,ptr);
}
}
}
printf("%s\n",wordstring);
*wordstring = '\0';
}
}
else {
printf("Usage: vargr number-of-names [maximum syllables]\n");
}
} /* End of Main */
int Random(max)
int max;
{
int die;
die = ((int)(rand()%max)+1);
return(die);
} /* End of Random */
char *GetICons(num)
int num;
{
int r, w;
char *grab;
r = Random(DIE) - 1;
w = Random(DIE) - 1;
switch(num) {
case 1: grab = init1[r][w];
break;
case 2: grab = init2[r][w];
break;
case 3: grab = init3[r][w];
break;
case 4: grab = init4[r][w];
break;
case 5: grab = init5[r][w];
break;
case 6: grab = init6[r][w];
break;
}
return(grab);
} /* End of GetICons */
char *GetFCons(num)
int num;
{
int r, w;
char *grab;
r = Random(DIE) - 1;
w = Random(DIE) - 1;
switch(num) {
case 1: grab = final1[r][w];
break;
case 2: grab = final2[r][w];
break;
case 3: grab = final3[r][w];
break;
case 4: grab = final4[r][w];
break;
case 5: grab = final5[r][w];
break;
case 6: grab = final6[r][w];
break;
}
return(grab);
} /* End of GetFCons */
char *GetVow(num)
int num;
{
int r, w;
char *grab;
r = Random(DIE) - 1;
w = Random(DIE) - 1;
switch(num) {
case 1: grab = vow1[r][w];
break;
case 2: grab = vow2[r][w];
break;
case 3: grab = vow3[r][w];
break;
case 4: grab = vow4[r][w];
break;
case 5: grab = vow5[r][w];
break;
case 6: grab = vow6[r][w];
break;
}
return(grab);
} /* End of GetVow */
@EOF
chmod 644 vargr.c
echo x - vargr.doc
cat >vargr.doc <<'@EOF'
^L The Vargr word generator was created to speed
up creating words and names in the Vargr lang-
uage using the tables found in Alien Module #3
for the Traveller Role Playing Game. This code
is copyright by me, David Courney Boddie on
May of 1991, and I give express concent to any
one who wishes to copy and/or change the code
at will, but if you wish to sell the code, I
would request that you contact me first. This is
my first batch of C code that actually works
that does more than prints "Hello World", and
I am pretty proud of it. This code is public
domain, but if you distribute it, keep all the
parts together.
Compiling this program is simple...There is no
makefile, and the only file that you need to
compile is VARGR.C, which will call all the
remaining C files. An example command to com-
pile for a Unix machine would be:
cc -o vargr vargr.c
For Turbo C, you can just type the following:
tcc vargr.c
which will create an executible with the same
name as the C program. You can also use the IDE
to generate an executible file. Any errors generated
by the code should be sent back to [email removed].
^L Once you have generated an executible, you can execute
the program with the following parameters (square brack-
ets [] represent optional parameters):
vargr number-of-words [maximum syllables]
The number of names (whether 1 or a million) must be
specified. I haven't updated the code yet to take any
number of arguements, so I had to stick this restriction
on it. Since this word/name generator can generate up to
6 syllables, and each syllable can have up to 10 char-
acters each...so that can be a lot. So I have entered a
parameter that allows you to set the maximum number of
syllables. Neither of these numbers can be 0 or negative.
Well, there you have it...If you have any questions about
the code or have patches, please submit them to me. I
would like to see what you can do with this if you want.
I believe this code is somewhat bug free, but I have
heard that the executibles may crash some PCs. This
program is simple, and you shouldn't have any problems
with it....but you still might...
Standard Disclaimer: Since this is my first written
piece of code, I will disclaim that I will not be res-
ponsible for any harmful effects of this code. If you
are a programmer of C, or can understand C somewhat,
you should inspect this code before installing it on
your machine. For those who aren't adept at C, all I
can give you is my word that this code is harmless.
========================Greetings from the Flux==========================
: Dave Boddie ___________ :
: Computer Operator I / Lab Consultant |+ |_ :
: University of Arkansas, Fayetteville | NorthWest / :
: Bitnet: [email removed] | Arkansas | :
: Internet: [email removed] |_ U of A / :
: |______| :
: "Strive for exellence, struggle for power, grieve for losing." :
=========================================================================
@EOF
chmod 644 vargr.doc
echo x - vcon1.c
cat >vcon1.c <<'@EOF'
/* this is the initial consonant table listing. */
extern char *init1[6][6] = {
{ "d","d","d","d","d","d" },
{ "d","d","d","dh","dh","dh" },
{ "dh","dh","dh","dh","dh","dh" },
{ "dz","dz","dz","dz","dz","f" },
{ "f","f","f","f","f","f" },
{ "g","g","g","g","g","g" },
};
extern char *init2[6][6] = {
{ "g","g","g","g","g","g" },
{ "g","g","g","g","g","g" },
{ "gh","gh","gh","gh","gh","gh" },
{ "gh","gh","gh","gh","gh","gn" },
{ "gn","gn","gv","gv","gv","gv" },
{ "gv","gv","gv","gz","gz","gz" },
};
extern char *init3[6][6] = {
{ "gz","k","k","k","k","k" },
{ "k","k","k","k","k","k" },
{ "k","k","k","k","k","k" },
{ "k","kf","kf","kf","kf","kf" },
{ "kh","kh","kh","kh","kh","kh" },
{ "kh","kh","kh","kh","kh","kn" },
};
extern char *init4[6][6] = {
{ "kn","kn","kn","kn","kn","ks" },
{ "ks","ks","ks","ks","ks","ks" },
{ "l","l","l","l","ll","ll" },
{ "ll","ll","ll","ll","ll","ll" },
{ "n","n","n","n","n","n" },
{ "n","ng","ng","ng","ng","ng" },
};
extern char *init5[6][6] = {
{ "r","r","r","r","r","r" },
{ "r","r","r","r","r","rr" },
{ "rr","rr","rr","rr","rr","rr" },
{ "rr","s","s","s","s","s" },
{ "s","s","s","s","s","s" },
{ "t","t","t","t","t","t" },
};
extern char *init6[6][6] = {
{ "t","th","th","th","th","th" },
{ "th","th","th","ts","ts","ts" },
{ "ts","ts","v","v","v","v" },
{ "v","v","v","v","v","v" },
{ "z","z","z","z","z","z" },
{ "z","z","z","z","z","z" },
};
/* end of initial consonant initialization */
@EOF
chmod 644 vcon1.c
echo x - vcon2.c
cat >vcon2.c <<'@EOF'
/* this file contains the final consonant letters for the random word */
/* generator. */
extern char *final1[6][6] = {
{ "dh","dh","dh","dh","dh","dz" },
{ "dz","dz","dz","dz","g","g" },
{ "g","g","g","g","g","g" },
{ "g","g","g","g","g","g" },
{ "g","gh","gh","gh","gh","gh" },
};
extern char *final2[6][6] = {
{ "ghz","ghz","ghz","ghz","gz","gz" },
{ "gz","gz","gz","k","k","k" },
{ "k","k","k","k","k","k" },
{ "k","kh","kh","kh","kh","kh" },
{ "kh","kh","kh","kh","kh","khs" },
{ "khs","khs","khs","khs","ks","ks" },
};
extern char *final3[6][6] = {
{ "ks","ks","ks","ks","l","l" },
{ "l","l","l","l","l","l" },
{ "l","l","ll","ll","ll","ll" },
{ "ll","n","n","n","n","n" },
{ "n","n","n","n","n","n" },
{ "n","n","n","n","n","n" },
};
extern char *final4[6][6] = {
{ "n","n","n","n","n","n" },
{ "n","n","ng","ng","ng","ng" },
{ "ng","ng","ng","ng","ng","ng" },
{ "ng","ng","ng","ng","ng","ng" },
{ "ng","ng","ng","ng","ng","ng" },
{ "ng","ng","ng","r","r","r" },
};
extern char *final5[6][6] = {
{ "r","r","r","r","r","r" },
{ "r","r","r","r","r","r" },
{ "rr","rr","rr","rr","rr","rr" },
{ "rr","rr","rr","rr","rr","rr" },
{ "rr","rr","rr","rrg","rrg","rrg" },
{ "rrg","rrg","rrgh","rrgh","rrgh","rrgh" },
};
extern char *final6[6][6] = {
{ "rrgh","rs","rs","rs","rs","rs" },
{ "rz","rz","rz","rz","rz","s" },
{ "s","s","s","s","th","th" },
{ "th","th","th","ts","ts","ts" },
{ "ts","ts","z","z","z","z" },
{ "z","z","z","z","z","z" },
};
/* end of final consonant initialization */
@EOF
chmod 644 vcon2.c
echo x - vmain.c
cat >vmain.c <<'@EOF'
/* The file TMAIN.C contains the basic and alternate tables for the */
/* random word generation program. These provide vowel (V) and cons */
/* onant (C) values for the syllable string. */
extern char *basic[6][6] = {
{ "V","V","V","V","VC","VC" },
{ "VC","VC","VC","VC","VC","VC" },
{ "VC","VC","VC","VC","VC","VC" },
{ "CV","CV","CV","CV","CVC","CVC" },
{ "CVC","CVC","CVC","CVC","CVC","CVC" },
{ "CVC","CVC","CVC","CVC","CVC","CVC" }
};
extern char *alt[6][6] = {
{ "CV","CV","CV","CV","CV","CV" },
{ "CV","CV","CV","CV","CV","CV" },
{ "CV","CV","CV","CV","CV","CV" },
{ "CVC","CVC","CVC","CVC","CVC","CVC" },
{ "CVC","CVC","CVC","CVC","CVC","CVC" },
{ "CVC","CVC","CVC","CVC","CVC","CVC" },
};
/* End of the Basic Tables */
@EOF
chmod 644 vmain.c
echo x - vvow.c
cat >vvow.c <<'@EOF'
/* this file contains all the vowel tables required with the random word */
/* generator. */
extern char *vow1[6][6] = {
{ "a","a","a","a","a","a" },
{ "a","a","a","a","a","a" },
{ "a","a","a","a","a","a" },
{ "a","a","a","a","a","a" },
{ "a","a","a","a","a","a" },
{ "a","a","a","a","a","a" },
};
extern char *vow2[6][6] = {
{ "a","a","a","a","a","a" },
{ "ae","ae","ae","ae","ae","ae" },
{ "ae","ae","ae","ae","ae","ae" },
{ "ae","ae","ae","ae","ae","ae" },
{ "ae","ae","ae","ae","ae","ae" },
{ "ae","ae","ae","ae","ae","ae" },
};
extern char *vow3[6][6] = {
{ "ae","ae","ae","ae","ae","ae" },
{ "e","e","e","e","e","e" },
{ "e","e","e","e","e","e" },
{ "e","e","i","i","i","i" },
{ "i","i","i","i","i","i" },
{ "o","o","o","o","o","o" },
};
extern char *vow4[6][6] = {
{ "o","o","o","o","o","o" },
{ "o","o","o","o","o","o" },
{ "o","o","o","o","o","o" },
{ "o","o","o","o","o","o" },
{ "o","o","o","o","oe","oe" },
{ "oe","oe","oe","oe","oe","oe" },
};
extern char *vow5[6][6] = {
{ "oe","oe","oe","oe","oe","oe" },
{ "oe","oe","ou","ou","ou","ou" },
{ "ou","ou","ou","ou","ou","ou" },
{ "ou","ou","ou","ou","ou","ou" },
{ "u","u","u","u","u","u" },
{ "u","u","u","u","u","u" },
};
extern char *vow6[6][6] = {
{ "u","u","u","u","u","u" },
{ "u","u","u","u","u","u" },
{ "ue","ue","ue","ue","ue","ue" },
{ "ue","ue","ue","ue","ue","ue" },
{ "ue","ue","ue","ue","ue","ue" },
{ "ue","ue","ue","ue","ue","ue" },
};
/* end of vowel initialization */
@EOF
chmod 644 vvow.c
exit 0