Angband
Macros | Typedefs | Functions | Variables
randname.c File Reference

Random name generation. More...

#include "angband.h"
#include "randname.h"

Macros

#define S_WORD   26
#define E_WORD   S_WORD
#define TOTAL   27

Typedefs

typedef unsigned short name_probs [S_WORD+1][S_WORD+1][TOTAL+1]

Functions

static void build_prob (name_probs probs, const char **learn)
 This function builds probability tables from a list of purely alphabetical lower-case words, and puts them into the supplied name_probs object.
size_t randname_make (randname_type name_type, size_t min, size_t max, char *word_buf, size_t buflen, const char ***sections)
 Use W.

Variables

const char *** name_sections
 Array[RANDNAME_NUM_TYPES][num_names] of random names.

Detailed Description

Random name generation.

Copyright (c) 2007 Antony Sidwell, Sheldon Simms

This work is free software; you can redistribute it and/or modify it under the terms of either:

a) the GNU General Public License as published by the Free Software Foundation, version 2, or

b) the "Angband licence": This software may be copied and distributed for educational, research, and not for profit purposes provided that this copyright and statement are included in all such copies. Other copyrights may also apply.

Macro Definition Documentation

#define E_WORD   S_WORD

Referenced by build_prob(), and randname_make().

#define S_WORD   26

Referenced by build_prob(), and randname_make().

#define TOTAL   27

Referenced by build_prob(), and randname_make().

Typedef Documentation

typedef unsigned short name_probs[S_WORD+1][S_WORD+1][TOTAL+1]

Function Documentation

static void build_prob ( name_probs  probs,
const char **  learn 
)
static

This function builds probability tables from a list of purely alphabetical lower-case words, and puts them into the supplied name_probs object.

The array of names should have a NULL entry at the end of the list. It relies on the ASCII character set (through use of A2I).

References A2I, E_WORD, i, S_WORD, and TOTAL.

Referenced by randname_make().

size_t randname_make ( randname_type  name_type,
size_t  min,
size_t  max,
char *  word_buf,
size_t  buflen,
const char ***  sections 
)

Use W.

Make a random name.

Sheldon Simms' random name generator algorithm (Markov Chain stylee).

Generate a random word using the probability tables we built earlier. Relies on the A2I and I2A macros (and so the ASCII character set) and is_a_vowel (so the basic 5 English vowels).

References build_prob(), E_WORD, FALSE, I2A, is_a_vowel(), randint0, RANDNAME_NUM_TYPES, S_WORD, TOTAL, TRUE, and void().

Referenced by artifact_gen_name(), flavor_init(), and get_name_keypress().

Variable Documentation

const char*** name_sections

Array[RANDNAME_NUM_TYPES][num_names] of random names.

Referenced by cleanup_names(), finish_parse_names(), flavor_init(), get_name_keypress(), and init_names().