Beispiel #1
0
        private List <Point> FilterCellsCore(IEnumerable <Point> source, EstimateFunction estimator)
        {
            List <Point> result       = new List <Point>();
            IComparable  bestEstimate = null;

            foreach (Point point in source)
            {
                if (Field[point].State == CellState.Empty)
                {
                    IComparable estimate = estimator(point);

                    int compareResult = estimate.CompareTo(bestEstimate);

                    if (!(compareResult < 0))
                    {
                        if (compareResult > 0)
                        {
                            result.Clear();
                            bestEstimate = estimate;
                        }
                        result.Add(point);
                    }
                }
            }

            return(result);
        }
Beispiel #2
0
    List <Point> FilterCellsCore(IEnumerable <Point> source, EstimateFunction estimator, CellState color)
    {
        var         result       = new List <Point>();
        IComparable bestEstimate = null;

        foreach (Point location in source)
        {
            if (gameBoard.getBlock(location) != CellState.None)
            {
                continue;
            }
            var estimate = estimator(location, color);

            int compareResult = estimate.CompareTo(bestEstimate);
            if (compareResult < 0)
            {
                continue;
            }
            if (compareResult > 0)
            {
                result.Clear();
                bestEstimate = estimate;
            }
            result.Add(location);
        }

        return(result);
    }
Beispiel #3
0
        List<Point> FilterCellsCore(IEnumerable<Point> source, EstimateFunction estimator, CellState color)
        {
            var result = new List<Point>();
            IComparable bestEstimate = null;

            foreach(Point location in source) {
                if(Board.GetStone(location) != CellState.None)
                    continue;
                var estimate = estimator(location, color);

                int compareResult = estimate.CompareTo(bestEstimate);
                if(compareResult < 0)
                    continue;
                if(compareResult > 0) {
                    result.Clear();
                    bestEstimate = estimate;
                }
                result.Add(location);
            }

            return result;
        }