Beispiel #1
0
 private bool Kamikadze(Board board)
 {
     if ((board.IsAt(currentPoint.ShiftRight(), Element.WALL) || board.IsAt(currentPoint.ShiftRight(), Element.DESTROYABLE_WALL)) &&
         (board.IsAt(currentPoint.ShiftLeft(), Element.WALL) || board.IsAt(currentPoint.ShiftLeft(), Element.DESTROYABLE_WALL)) &&
         (board.IsAt(currentPoint.ShiftTop(), Element.WALL) || board.IsAt(currentPoint.ShiftTop(), Element.DESTROYABLE_WALL)) &&
         (board.IsAt(currentPoint.ShiftBottom(), Element.WALL) || board.IsAt(currentPoint.ShiftBottom(), Element.DESTROYABLE_WALL)))
     {
         return(true);
     }
     return(false);
 }
Beispiel #2
0
        //    if ((board.IsAt(currentPoint.ShiftRight(), Element.WALL) || board.IsAt(currentPoint.ShiftRight(), Element.DESTROYABLE_WALL))
        //    && (board.IsAt(currentPoint.ShiftLeft(), Element.WALL) || board.IsAt(currentPoint.ShiftLeft(), Element.DESTROYABLE_WALL))
        //    && (board.IsAt(currentPoint.ShiftTop(), Element.WALL) || board.IsAt(currentPoint.ShiftTop(), Element.DESTROYABLE_WALL))
        //    && (board.IsAt(currentPoint.ShiftBottom(), Element.WALL) || board.IsAt(currentPoint.ShiftBottom(), Element.DESTROYABLE_WALL)))
        //{
        //}

        private bool IsCloseTo(Point sub, Point main)
        {
            if (
                main.Equals(sub)
                ||
                main.ShiftLeft().Equals(sub)
                ||
                main.ShiftRight().Equals(sub)
                ||
                main.ShiftTop().Equals(sub)
                ||
                main.ShiftBottom().Equals(sub)
                ||
                main.ShiftLeft().ShiftTop().Equals(sub)
                ||
                main.ShiftLeft().ShiftBottom().Equals(sub)
                ||
                main.ShiftRight().ShiftTop().Equals(sub)
                ||
                main.ShiftRight().ShiftBottom().Equals(sub)
                )
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Calls each move to make decision what to do (next move)
        /// </summary>
        protected override string Get(Board board)
        {
            Board = board;
            var action = string.Empty;

            if (!board.isMyBombermanDead)
            {
                FoundWayToBomberman = true;



                recurcive = 0;

                Barriers = Board.GetBarrier();

                try
                {
                    PlayerPoint = Board.GetBomberman();
                }
                catch (Exception)
                {
                    return(string.Empty);
                }

                FutureBlastsPoint   = Board.GetFutureBlasts();
                PredictChopperPoint = predictChopper(Board.Get(Element.MEAT_CHOPPER), Board.Get(Element.DeadMeatChopper));
                Barriers.AddRange(PredictChopperPoint);
                Barriers.AddRange(Board.Get(Element.BOMB_REMOTE_CONTROL));
                //Barriers.AddRange(Board.GetMeatChoppers());
                Barriers.AddRange(Board.GetBombs());
                DangerPoints = FutureBlastsPoint;
                DangerPoints.AddRange(PredictChopperPoint);

                if (DangerPoints.Contains(PlayerPoint))
                {
                    if (Board.IsNear(PlayerPoint, Element.OTHER_BOMBERMAN) || Board.IsNear(PlayerPoint, Element.OTHER_BOMB_BOMBERMAN))
                    {
                        FutureBlastsPoint = Board.GetFutureBlasts(PlayerPoint);
                        DangerPoints      = FutureBlastsPoint;
                        action            = Direction.Act.ToString() + findNearElements(Element.Space);
                    }
                    else
                    {
                        //if stuck need run

                        action = findNearElements(Element.Space).ToString();
                    }
                }
                else
                {
                    var dir = Direction.Act;
                    if (FoundWayToBomberman)
                    {
                        dir = findNearElements(Element.OTHER_BOMBERMAN);
                    }
                    else
                    {
                        dir = findNearElements(Element.MEAT_CHOPPER);
                    }


                    switch (dir)
                    {
                    case Direction.Left:
                        nextPoint = PlayerPoint.ShiftLeft();
                        break;

                    case Direction.Right:
                        nextPoint = PlayerPoint.ShiftRight();
                        break;

                    case Direction.Up:
                        nextPoint = PlayerPoint.ShiftTop();
                        break;

                    case Direction.Down:
                        nextPoint = PlayerPoint.ShiftBottom();
                        break;

                    case Direction.Act:
                        break;

                    case Direction.Stop:
                        break;

                    default:
                        break;
                    }
                    if (DangerPoints.Contains(nextPoint) && !DangerPoints.Contains(PlayerPoint))
                    {
                        dir = Direction.Stop;
                    }
                    if (dir != null)
                    {
                        if ((target != Element.OTHER_BOMBERMAN || (trueWay.Count() > 5 && target == Element.OTHER_BOMBERMAN)) && Board.IsDestroyableNear(PlayerPoint))
                        {
                            action = /* Direction.Act.ToString() + */ dir.ToString();
                        }
                        else
                        {
                            action = dir.ToString();
                        }
                    }
                }
            }
            else
            {
                FutureBlastsPoint = new List <Point>();

                PredictChopperPoint = new List <Point>();
                DangerPoints        = new List <Point>();
                Barriers            = new List <Point>();
            }
            if (action == Direction.Act.ToString())
            {
                FutureBlastsPoint = Board.GetFutureBlasts(PlayerPoint);
                //Barriers.AddRange(Board.GetBombs(PlayerPoint));
                DangerPoints = FutureBlastsPoint;
                action       = Direction.Act.ToString() + findNearElements(Element.Space);
            }
            else
            {
                if (Board.IsDestroyableNear(PlayerPoint) && trueWay.Count() > 4)
                {
                    action = Direction.Act.ToString() + action;
                }
            }

            var act = action.Replace(Direction.Act.ToString(), string.Empty);

            if (!string.IsNullOrEmpty(act))
            {
                var dirLast = (Direction)Enum.Parse(typeof(Direction), act);
                switch (dirLast)
                {
                case Direction.Left:
                    nextPoint = PlayerPoint.ShiftLeft();
                    break;

                case Direction.Right:
                    nextPoint = PlayerPoint.ShiftRight();
                    break;

                case Direction.Up:
                    nextPoint = PlayerPoint.ShiftTop();
                    break;

                case Direction.Down:
                    nextPoint = PlayerPoint.ShiftBottom();
                    break;

                case Direction.Act:
                    break;

                case Direction.Stop:
                    break;

                default:
                    break;
                }
                if (DangerPoints.Contains(nextPoint) && !DangerPoints.Contains(PlayerPoint))
                {
                    action = Direction.Stop.ToString();
                }
            }
            LastChopperPoint = Board.GetMeatChoppers();
            Console.WriteLine(Environment.NewLine + "Target: " + target.ToString());
            return(action);
        }