static void player_dialog_ok(GtkWidget *button, PlayerDialog *pd)
{
        int i, index;

        gtk_widget_hide(pd->window);
        index = gtk_combo_box_get_active(GTK_COMBO_BOX(pd->combo));

        /* Search options */
        pd->player->depth =
                   gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(pd->depth));
        pd->player->branch =
                  gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(pd->branch));
        pd->player->cache =
                     gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pd->cache));
        pd->player->tss =
                       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pd->tss));
        for (i = 0; i < SEARCHES; i++)
                if (gtk_toggle_button_get_active(
                                            GTK_TOGGLE_BUTTON(pd->search[i]))) {
                        pd->player->search = i;
                        break;
                }

        /* Marker player */
        if (pd->player == players) {
                AIMoves *moves;

                if (index == PLAYER_HUMAN) {
                        draw_marks(NULL, FALSE);
                        return;
                }
                pd->player->ai = index;
                stop_ai();
                moves = run_ai(players);
                if (opt_print_u)
                        g_debug("AI %s utility %d (0x%x)", ai(index)->s_desc,
                                moves->utility, moves->utility);
                setup_move();
                draw_marks(moves, TRUE);
                return;
        }

        /* White or black player changed */
        if (pd->player->ai != index) {
                pd->player->ai = index;
                stop_ai();
                setup_move();
        }
}
示例#2
0
int NPC::deactive_npc(void) {
	if (move_scene() == NULL || npc_id() == 0) {
		MSG_USER("ERROR_9:npc id:%ld fini time:%ld", npc_id(), fini_time_.sec());
		return -1;
	}

	stop_ai();

	return 0;
}
/* Clear the board and history for a new game */
void new_game(unsigned int size)
{
        tree_view_clear(1);
        clear_history(0);
        set_board_size(size);
        board = NULL;
        go_to_move(0);
        board->moves_left = start_q;
        board->turn = PIECE_BLACK;
        draw_board();
        stop_ai();
        setup_move();
}