bool ProofUtil::ShrinkProof(bitset_t& proof, const StoneBoard& board, 
                            HexColor loser, const ICEngine& ice)
{
    StoneBoard brd(board.Width(), board.Height());
    PatternState pastate(brd);
    Groups groups;

    // Give loser all cells outside proof
    bitset_t cells_outside_proof = (~proof & brd.Const().GetCells());
    brd.AddColor(loser, cells_outside_proof);

    // Give winner only his stones inside proof; 
    HexColor winner = !loser;
    brd.AddColor(winner, board.GetPlayed(winner) & proof);
    pastate.Update();
    GroupBuilder::Build(brd, groups);

    // Compute fillin and remove captured cells from the proof
    InferiorCells inf;
    ice.ComputeFillin(loser, groups, pastate, inf, 
                      HexColorSetUtil::Only(loser));
    HexAssert(inf.Captured(winner).none());

    bitset_t filled = inf.Dead() | inf.Captured(loser);
    bitset_t shrunk_proof = proof - filled;
    bool shrunkTheProof = shrunk_proof.count() < proof.count();
    proof = shrunk_proof;
    return shrunkTheProof;
}
Beispiel #2
0
void YSgUtil::SetPositionInNode(SgNode* node, const StoneBoard& brd, 
                                  HexColor color)
{
    int height = brd.Height();
    SgVector<SgPoint> blist = YSgUtil::BitsetToSgVector(brd.GetBlack() 
                                       & brd.Const().GetCells(), height);
    SgVector<SgPoint> wlist = YSgUtil::BitsetToSgVector(brd.GetWhite()
                                       & brd.Const().GetCells(), height);
    SgVector<SgPoint> elist = YSgUtil::BitsetToSgVector(brd.GetEmpty()
                                       & brd.Const().GetCells(), height);
    SgPropPlayer* pprop = new SgPropPlayer(SG_PROP_PLAYER);
    SgPropAddStone* bprop = new SgPropAddStone(SG_PROP_ADD_BLACK);
    SgPropAddStone* wprop = new SgPropAddStone(SG_PROP_ADD_WHITE);
    SgPropAddStone* eprop = new SgPropAddStone(SG_PROP_ADD_EMPTY);
    pprop->SetValue(YSgUtil::HexColorToSgColor(color));    
    bprop->SetValue(blist);
    wprop->SetValue(wlist);
    eprop->SetValue(elist);
    node->Add(pprop);
    node->Add(bprop);
    node->Add(wprop);
    node->Add(eprop);
}