Example #1
0
        public static int Evaluate(GameBoard board, PlayerColor player)
        {
            int blackScore = 0;
            int whiteScore = 0;

            for (int i = 0; i < GameBoard.BOARD_SIDE_SIZE; ++i)
            {
                blackScore += board.PieceCountOfPlayerAtLevel(PlayerColor.Black, i) * _blackPieceValuesPerLevel[i]; //cim blize transformaci na damu, tim lip
                whiteScore += board.PieceCountOfPlayerAtLevel(PlayerColor.White, i) * _whitePieceValuesPerLevel[i];
            }

            whiteScore += board.PieceCountOfPlayerByPieceType(PlayerColor.White, PieceType.Normal) * _normalPiecePrice;
            whiteScore += board.PieceCountOfPlayerByPieceType(PlayerColor.White, PieceType.King) * _kingPiecePrice;

            blackScore += board.PieceCountOfPlayerByPieceType(PlayerColor.Black, PieceType.Normal) * _normalPiecePrice;
            blackScore += board.PieceCountOfPlayerByPieceType(PlayerColor.Black, PieceType.King) * _kingPiecePrice;

            int score = (blackScore - whiteScore) * 200;
            score += _rand.Next(-_randomRange, _randomRange);

            return player == PlayerColor.Black ? score : -score;
        }