void Game_private::usergo(int x, int y) { if (mp_chess->getData(x, y) != 0) return; mp_chess->setOneData(x, y, 1); mp_area->setCanUserclick(false); int judge_ans = mp_chess->judge(); if (judge_ans == 1) { gameWin(); return; } if (judge_ans == 2) { gameOver(); return; } Glib::Threads::Thread::create( sigc::mem_fun(*this, &Game_private::runAI) ); }
void Game_private::runAI() { printf("Thread AI run\n"); mp_AI->RunAI(mp_chess); if (mp_AI->get_ans_tx()) { printf("电脑投降了\n"); gameWin(); return; } mp_chess->setOneData(mp_AI->get_ans_x(), mp_AI->get_ans_y(), 2); int judge_ans = mp_chess->judge(); if (judge_ans == 1) { gameWin(); return; } if (judge_ans == 2) { gameOver(); return; } mp_area->queue_draw(); mp_area->setCanUserclick(true); }