Esempio n. 1
0
void GoGame::Init(SgNode* root)
{
    m_root->DeleteTree();
    m_root = root;
    int size = GoNodeUtil::GetBoardSize(m_root);
    ForceInRange(SG_MIN_SIZE, &size, SG_MAX_SIZE);
    const GoRules& rules = m_board.Rules();
    m_board.Init(size, GoRules(rules.Handicap(), rules.Komi()));

    // Add root property: Go game identifier.
    const int GAME_ID = 1;
    SgPropInt* gameId = new SgPropInt(SG_PROP_GAME, GAME_ID);
    m_root->Add(gameId);

    // Go to the root node.
    GoToNode(m_root);
}
Esempio n. 2
0
void GoGame::Init(SgNode* root)
{
    m_root->DeleteTree();
    m_root = root;
    int size = GO_DEFAULT_SIZE;
    SgPropInt* boardSizeProp =
        static_cast<SgPropInt*>(m_root->Get(SG_PROP_SIZE));
    if (boardSizeProp)
    {
        size = boardSizeProp->Value();
        ForceInRange(SG_MIN_SIZE, &size, SG_MAX_SIZE);
    }
    const GoRules& rules = m_board.Rules();
    m_board.Init(size, GoRules(rules.Handicap(), rules.Komi()));

    // Add root property: Go game identifier.
    const int GAME_ID = 1;
    SgPropInt* gameId = new SgPropInt(SG_PROP_GAME, GAME_ID);
    m_root->Add(gameId);

    // Go to the root node.
    GoToNode(m_root);
}