Пример #1
0
        static int ScoreDiferentBettwenPieces(Game game, Tile color)
        {
            var mePieces    = game.GetPositions(Helper.GetTileColors(color));
            var otherPieces = game.GetPositions(Helper.GetTileColors(Helper.ChangeColor(color)));

            var diferentBettwenPieces = mePieces.Count() - otherPieces.Count();

            return(diferentBettwenPieces);
        }
Пример #2
0
        static int ScoreQueens(Game game, Tile color)
        {
            var mePieces    = game.GetPositions(Helper.GetTileColors(color));
            var otherPieces = game.GetPositions(Helper.GetTileColors(Helper.ChangeColor(color)));

            var meQueens              = mePieces.Select(x => game.GetTile(x)).Count(x => (int)x > 5);
            var otherQueens           = otherPieces.Select(x => game.GetTile(x)).Count(x => (int)x > 5);
            var diferentBetwwenQueens = (meQueens - otherQueens);

            return(diferentBetwwenQueens);
        }
Пример #3
0
        public static int Score(Game game, Tile color)
        {
            var tiles = game.GetPositions(Helper.GetTileColors(color)).Count() + game.GetPositions(Helper.GetTileColors(Helper.ChangeColor(color))).Count();
            var stage = tiles / 10 + 1;

            return
                ((stage * 50) * ScoreDiferentBettwenPieces(game, color) +
                 ((5 - stage) * 50) * ScoreQueens(game, color) +
                 ((5 - stage)) * ScoreDefenceLinePosition(game, color) +
                 ((5 - stage)) * ScoreCenterAdvantage(game, color) +
                 ((5 - stage)) * ScoreMoveAmount(game, color));
        }
Пример #4
0
        static int ScoreCenterAdvantage(Game game, Tile color)
        {
            var mePieces  = game.GetPositions(Helper.GetTileColors(color));
            var goodTiles = new[] { 14, 18, 15, 19 };
            var amount    = mePieces.Select(x => goodTiles.Contains(x.Number)).Count();

            return(amount);
        }
Пример #5
0
        static int ScoreDefenceLinePosition(Game game, Tile color)
        {
            var mePieces = game.GetPositions(Helper.GetTileColors(color));

            var defencePositionRow = color == Tile.White ? 0 : 7;
            var amountDefending    = mePieces.Where(x => x.Row == defencePositionRow).Count();

            return(amountDefending);
        }
Пример #6
0
        public static IEnumerable <Move> Moves(Game game, Tile color)
        {
            List <Move> moves = new List <Move>();

            foreach (var position in game.GetPositions(Helper.GetTileColors(color)))
            {
                var tileMoves = Helper.CalculateMoves(game, position);
                moves.AddRange(tileMoves);
            }
            return(moves);
        }
Пример #7
0
        public static Move NextBestMove(Game game, Tile color, int depth)
        {
            List <MoveResult> bestMoves = new List <MoveResult>();


            foreach (var position in game.GetPositions(Helper.GetTileColors(color)))
            {
                var move = NextBestMove(game, color, position, depth);
                if (move != null)
                {
                    bestMoves.Add(move);
                }
            }

            //Eat is obligatory
            var eatMoves = bestMoves.Where(x => x.Move is Eat);

            if (eatMoves.Any())
            {
                return(eatMoves.OrderByDescending(x => x.Weight).First().Move);
            }
            return(bestMoves.OrderByDescending(x => x.Weight).FirstOrDefault()?.Move ?? null);
        }