Esempio n. 1
0
        private void CalculateNextStepBoardPoints()
        {
            if (!BoardPoints.Any())
            {
                return;
            }


            var maxPossibility       = BoardPoints.Max(x => x.ChopperPossibility);
            var maxPossibilityPoints = BoardPoints.Where(x => x.ChopperPossibility == maxPossibility).ToList();

            var possibility = maxPossibilityPoints.Count > 1 ? 30 : 50;

            foreach (var maxPossibilityPoint in maxPossibilityPoints)
            {
                var nextStepPoint = maxPossibilityPoint.GetNearPoint(maxPossibilityPoint.ChopperMovePosition);

                var boardPoint = new BoardPoint(nextStepPoint)
                {
                    ChopperPossibility   = possibility,
                    ChopperMoveDirection = maxPossibilityPoint.ChopperMoveDirection,
                    ChopperMovePosition  = maxPossibilityPoint.ChopperMovePosition
                };

                BoardPoints.Add(boardPoint);
            }
        }
Esempio n. 2
0
        public void InitBoardPoints()
        {
            BoardPoints.Clear();

            var coefficients = new List <Tuple <int, int, MoveDirection> >();
            var result       = new List <BoardPoint>();

            if (IsUnknownPossibleDirection)
            {
                for (var i = 0; i < _nextTickPoints.Count; i++)
                {
                    var point = _nextTickPoints[i];

                    if (Global.Board.IsAnyOfAt(point.Item2, CanNotMoveThrought))
                    {
                        continue;
                    }

                    coefficients.Add(new Tuple <int, int, MoveDirection>(i, _nextTickMaxPossibility, _nextTickMoveDirectionMap[i]));
                }
            }
            else
            {
                for (int i = 0; i < _nextTickPoints.Count; i++)
                {
                    var point = _nextTickPoints[i];

                    if (Global.Board.IsAnyOfAt(point.Item2, CanNotMoveThrought))
                    {
                        continue;
                    }

                    var coefficient = _nextTickPointMovePossibilities[_nextTickMoveDirectionMap[i]];
                    coefficients.Add(new Tuple <int, int, MoveDirection>(i, coefficient, _nextTickMoveDirectionMap[i]));
                }
            }

            var coefficientsSum = coefficients.Select(x => x.Item2).Sum();

            foreach (var coefficient in coefficients)
            {
                var point = _nextTickPoints[coefficient.Item1];

                var boardPoint = new BoardPoint(point.Item2)
                {
                    ChopperPossibility   = coefficient.Item2 * 100 / coefficientsSum,
                    ChopperMoveDirection = coefficient.Item3,
                    ChopperMovePosition  = point.Item1
                };

                result.Add(boardPoint);
            }

            BoardPoints.AddRange(result);

            CalculateNextStepBoardPoints();

            //Console.WriteLine(string.Join(" | ", BoardPoints.Select(x => x.Point + " " + x.ChopperPossibility)));
            //return result;
        }
Esempio n. 3
0
        public int GetPossibility(Point point)
        {
            var boardPoint = BoardPoints.FirstOrDefault(x => x.Point.Equals(point));

            return(boardPoint?.ChopperPossibility ?? 0);
        }