/** Finds inferior cells, builds vcs. Sets moves to consider to all empty cells. If fillin causes terminal state, sets m_fillinCausedWin to true and recomputes fillin/vcs with ice temporarily turned off (so it can pass the players a non-empty consider set). */ HexPoint BenzenePlayer::InitSearch(HexBoard& brd, HexColor color, bitset_t& consider, double& score) { // Resign if the game is already over Groups groups; GroupBuilder::Build(brd.GetPosition(), groups); if (groups.IsGameOver()) { score = IMMEDIATE_LOSS; return RESIGN; } StoneBoard original(brd.GetPosition()); brd.ComputeAll(color); m_fillinCausedWin = false; m_fillinWinner = EMPTY; if (brd.GetGroups().IsGameOver()) { // Fillin caused win, remove and re-compute without ice. m_fillinCausedWin = true; m_fillinWinner = brd.GetGroups().GetWinner(); LogInfo() << "Captured cells caused win! Removing...\n"; brd.GetPosition().SetPosition(original); bool oldUseIce = brd.UseICE(); brd.SetUseICE(false); brd.ComputeAll(color); brd.SetUseICE(oldUseIce); BenzeneAssert(!brd.GetGroups().IsGameOver()); } consider = brd.GetPosition().GetEmpty(); score = 0; return INVALID_POINT; }
bool GameUtil::IsGameOver(const Game& game) { Groups groups; GroupBuilder::Build(game.Board(), groups); return groups.IsGameOver(); }