Esempio n. 1
0
        public static List <float> GetStatusFeature(GoBoard board, string gtpStatus)
        {
            var inputList      = new List <float>();
            var objGnugoStatus = new GnuGoStatus(board, gtpStatus);

            foreach (GoCell lCell in board.Cells)
            {
                var cellColor = GetCellStatus(board, lCell, objGnugoStatus);
                inputList.Add(cellColor);
            }

            return(inputList);
        }
Esempio n. 2
0
        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);
        }