Пример #1
0
        private IEnumerable <Chain <Point> > GetChains(StrategyBoard board)
        {
            var numberPoints         = EnumerableUtil.Rectangle(board.Size).Where(t => board.Grids[t.X, t.Y].IsNumber());
            var surroundingRawPoints = numberPoints.Select(numberPoint =>
            {
                var surroundingPoints = numberPoint.Surrounding().Where(t => board.Size.Contains(t));
                return(surroundingPoints.Where(t => board.Grids[t.X, t.Y] == Grid.Raw).ToChain());
            });

            return(MergeChains(surroundingRawPoints).Distinct());
        }
Пример #2
0
        private IEnumerable <GuessValue[]> GetCombinations(Chain <Point> chain, StrategyBoard board)
        {
            var possibleValues = chain.Select(t => new[] { GuessValue.Empty, GuessValue.Bomb }).ToArray();
            var combinations   = EnumerableUtil.Combinations(possibleValues);

            return(combinations.Where(combination =>
            {
                var pointValues = chain.ToDictionary((t, i) => t, (t, i) => combination[i]);

                var surroundingPoints = chain.SelectMany(point => point.Surrounding()).Where(t => board.Size.Contains(t)).Distinct();
                var surroundingNumberPoints = surroundingPoints.Where(t => board.Grids[t.X, t.Y].IsWithin(Grid.Empty, Grid.Number8));

                return surroundingNumberPoints.All(t => MatchValue(t, pointValues));
            }));
        }
Пример #3
0
 public CountStrategy(StrategyBoard board)
 {
     this.board = board;
 }
Пример #4
0
 public RandomStrategy(StrategyBoard board)
 {
     this.board = board;
 }
Пример #5
0
 public BruteForceStrategy(StrategyBoard board, int chainLength)
 {
     this.board       = board;
     this.chainLength = chainLength;
 }