Exemplo n.º 1
0
bool fit_word( word_search_t *ws, wchar_t *word )
{
	int fit, best_fit;
	int length;
	position_t position, best_position;

	length = wcslen(word);

	// Start at a random location looking for places to fit the word
	position_create_random( ws, &position);

	best_fit = -1;
	do {
		fit = fit_word_score( ws, word, &position );
		if( fit > best_fit ) {
			if( best_fit >= 0 ) {
				position_free( &best_position );
			}
			best_fit = fit;
			position_copy( &best_position, &position );
			if( best_fit == length ) {
				break;
			}
		}
	} while(position_iterate( &position ) );

	if( best_fit >= 0 ) {
		insert_word( ws, word, &best_position );
		position_free( &best_position );
	}
	
	position_free( &position );

	return best_fit >= 0;
}
Exemplo n.º 2
0
int nc_poisons_list_add(NC_PoisonsList *nc_pl, Poison *p, Position *pos)
{
    int index = poisons_list_add(&(nc_pl->pl), p);

    if (index==-1) return -1;

    position_copy(&(nc_pl->positions[index]), pos);
    return index;
}
Exemplo n.º 3
0
void nc_poisons_list_print(NC_PoisonsList *nc_pl)
{
    int i;
    int size = (nc_pl->pl).list_size;
    Position pos;
    Poison* p;

    for (i=0; i<size; i++) {
        p = &(nc_pl->pl.poisons[i]);
        position_copy(&pos, &(nc_pl->positions[i]));
        if (nc_pl->pl.active[i]) {
            mvaddch(pos.y, pos.x, p->character);
        } else {
            mvaddch(pos.y, pos.x, ' ');
        }
    }
}