Esempio n. 1
0
        private double NeighborPenalty(IBoard board)
        {
            double penalty = 0.0;

            foreach (Position current in board.AllSlots())
            {
                foreach (Position neighbor in board.Neighbors(current))
                {
                    int diff = board.GetNumber(neighbor) - board.GetNumber(current);
                    penalty += diff * diff;
                }
            }
            return(penalty);
        }