/* create a new generator */
namegen_t * namegen_generator_new (void) {
    namegen_t * data = malloc(sizeof(namegen_t));
    data->name = NULL;
    /* assign the rng */
	data->random = TCOD_random_get_instance();
	/* create the lists */
    data->vocals = TCOD_list_new();
    data->consonants = TCOD_list_new();
    data->syllables_pre = TCOD_list_new();
    data->syllables_start = TCOD_list_new();
    data->syllables_middle = TCOD_list_new();
    data->syllables_end = TCOD_list_new();
    data->syllables_post = TCOD_list_new();
    data->illegal_strings = TCOD_list_new();
    data->rules = TCOD_list_new();
    return (TCOD_namegen_t)data;
}
Example #2
0
void TCOD_bsp_split_recursive(TCOD_bsp_t *node, TCOD_random_t randomizer, int nb, 
	int minHSize, int minVSize, float maxHRatio, float maxVRatio) {
	bool horiz;
	int position;
	if ( nb == 0 || (node->w < 2*minHSize && node->h < 2*minVSize ) ) return;
	if (! randomizer ) randomizer=TCOD_random_get_instance();
	/* promote square rooms */
	if ( node->h < 2*minVSize || node->w > node->h * maxHRatio ) horiz = false;
	else if ( node->w < 2*minHSize || node->h > node->w * maxVRatio) horiz = true;
	else horiz = (TCOD_random_get_int(randomizer,0,1) == 0);
	if ( horiz ) {
		position = TCOD_random_get_int(randomizer,node->y+minVSize,node->y+node->h-minVSize);
	} else {
		position = TCOD_random_get_int(randomizer,node->x+minHSize,node->x+node->w-minHSize);
	}
	TCOD_bsp_split_once(node,horiz,position);
	TCOD_bsp_split_recursive(TCOD_bsp_left(node),randomizer,nb-1,minHSize,minVSize,maxHRatio,maxVRatio);
	TCOD_bsp_split_recursive(TCOD_bsp_right(node),randomizer,nb-1,minHSize,minVSize,maxHRatio,maxVRatio);
}