コード例 #1
0
ファイル: Go.cs プロジェクト: thenotandy/Aricie.PortalKeeper
        public static float GetCellPosition(GoCell lCell)
        {
            float toReturn = 0.5F;

            if (lCell.Color.IsBlack)
            {
                toReturn = 1F;
            }
            else if (lCell.Color.IsWhite)
            {
                toReturn = 0F;
            }
            return(toReturn);
        }
コード例 #2
0
ファイル: Go.cs プロジェクト: thenotandy/Aricie.PortalKeeper
        public static float GetCellStatus(GoBoard lGoBoard, GoCell lCell, GnuGoStatus objGnugoStatus)
        {
            float        toReturn      = 0.5F;
            SafetyStatus lSafetyStatus = lGoBoard.GetSafetyStatus(lCell.Index);

            if (!lSafetyStatus.IsUndecided)
            {
                if (lSafetyStatus.IsBlack)
                {
                    toReturn = 1;
                }
                else if (lSafetyStatus.IsWhite)
                {
                    toReturn = 0;
                }
                if (lSafetyStatus.IsDead)
                {
                    toReturn = 1 - toReturn;
                }
            }
            else
            {
                if (lCell.Color == Color.Black)
                {
                    //if (lGoBoard.GetBlockLibertyCount(lCell.Index) > 1)
                    if (objGnugoStatus.CellsByStatus[SafetyFlag.Dead].Contains(lCell.Index))
                    {
                        toReturn = 0;
                    }
                    else
                    {
                        toReturn = 1;
                    }
                }
                else if (lCell.Color == Color.White)
                {
                    //if (lGoBoard.GetBlockLibertyCount(lCell.Index) > 1)
                    if (objGnugoStatus.CellsByStatus[SafetyFlag.Dead].Contains(lCell.Index))
                    {
                        toReturn = 1;
                    }
                    else
                    {
                        toReturn = 0;
                    }
                }
                else
                {
                    if (objGnugoStatus.CellsByStatus[GnuGoStatus.BlackTerritory].Contains(lCell.Index))
                    {
                        toReturn = 1;
                    }
                    else if (objGnugoStatus.CellsByStatus[GnuGoStatus.WhiteTerritory].Contains(lCell.Index))
                    {
                        toReturn = 0;
                    }
                    else
                    {
                        foreach (int cellIdx in ((GoEmptyBlock)(lCell.Block)).MemberList)
                        {
                            if (objGnugoStatus.CellsByStatus[GnuGoStatus.BlackTerritory].Contains(cellIdx))
                            {
                                toReturn = 1;
                                break;
                            }
                            else if (objGnugoStatus.CellsByStatus[GnuGoStatus.WhiteTerritory].Contains(cellIdx))
                            {
                                toReturn = 0;
                                break;
                            }
                        }
                    }
                }
            }

            return(toReturn);
        }