What's new
  • Visit Rebornbuddy
  • Visit Resources
  • Visit API Documentation
  • Visit Downloads
  • Visit Portal
  • Visit Panda Profiles
  • Visit LLamamMagic

Make explorearea prefer closer unexplored area?

Lcyorr

New Member
Joined
Nov 26, 2012
Messages
67
Reaction score
1
Is there a way to make explorearea prefer exploring areas that are closer rather than far away? I often see my bot running halfways across the map to explore then running all the way back to finish exploring the side it was on, and it causes a large amount of backtracking.
You can see this happen in just about any profile for a randomized dungeon, especially keeps 2.
 
Last edited:
From what I can tell.. it attempts to continue on perpendicular path from where it is facing and moving towards.. and will only backtrack (do a 180) if it runs out of unexplored nodes on its current path.

But it is possible to write your own dungeon exploring tag.. but I can't help much here (I know it starts with GridSegmentation to get the Dungeon Nodes..). but after that I'm not sure. Maybe someone could enlighten us with examples?
 
Well I took another look at my old attempt, and well I finally got a working example... although it is nothing close to being complete, there is no checks, and backtracking.. well its just an example for others to get started with. :)

This example I cannot go in depth at this moment but simply put it uses Dungeon Explorer to navigate.. once it runs into a movement result that fails.. then it will update the route again, so basically it will explore the whole place.. non-stop?

Code:
  [XmlElement("ExploreDungeonFunk")]
    public class ExploreDungeonFunkTag : ProfileBehavior
    {
        private bool m_IsDone = false;
        public override bool IsDone
        {
            get { return m_IsDone; }
        }

        private Zeta.CommonBot.Dungeons.DungeonExplorer DE;
        private MoveResult lastMoveResult = MoveResult.PathGenerating;
        private bool InitDone = false;
        private void Init()
        {
            Zeta.CommonBot.Dungeons.GridSegmentation.BoxSize = 18;
            Zeta.CommonBot.Dungeons.GridSegmentation.BoxTolerance = 0.18f;
            Zeta.CommonBot.Dungeons.GridSegmentation.Update();
            Zeta.CommonBot.Logic.BrainBehavior.DungeonExplorer.Reset();
            Zeta.CommonBot.Logic.BrainBehavior.DungeonExplorer.Update();

            DE= Zeta.CommonBot.Logic.BrainBehavior.DungeonExplorer;
            Logging.Write("DE CR: " + DE.CurrentRoute.Count());
            Logging.Write("DE BR: " + DE.GetBestRoute().Count());
            InitDone = true;
        }


        private Zeta.Pathfinding.PathFindResult PR = new Zeta.Pathfinding.PathFindResult();
        private void UpdateRoute()
        {
            DE.Update();
            lastMoveResult = MoveResult.PathGenerated;
        }

        private void MoveToNextNode()
        {
            DungeonNode NextNode = DE.CurrentRoute.Peek();
            float Distance = ZetaDia.Me.Position.Distance(NextNode.NavigableCenter);
            Vector3 NextTargetV3 = MathEx.CalculatePointFrom(ZetaDia.Me.Position, NextNode.NavigableCenter, Distance);

            Logging.Write("Moving to " + NextNode.NavigableCenter.ToString());
            lastMoveResult = Zeta.Navigation.Navigator.MoveTo(NextNode.NavigableCenter);

            switch (lastMoveResult)
            {

                case MoveResult.ReachedDestination:
                    break;
                case MoveResult.Moved:
                    Logging.Write("Movement return is successful.");
                    break;
                case MoveResult.PathGenerated:
                case MoveResult.PathGenerating:
                    break;
                case MoveResult.Failed:
                case MoveResult.PathGenerationFailed:
                    Logging.Write("Movement return is failure!");
                    break;
            }

        }

        private static Vector3 PlayerPOS = Vector3.Zero;
        private static DateTime lastUpdatedPOS = DateTime.MinValue;
        private static void PlayerPOSUpdate()
        {
            lastUpdatedPOS = DateTime.Now;
            try
            {
                PlayerPOS = ZetaDia.Me.Position;
            }
            catch { PlayerPOS = Vector3.Zero; }
        }

        protected override Composite CreateBehavior()
        {
            return
              
            new Zeta.TreeSharp.Sequence(
                    new Zeta.TreeSharp.Action(ret => PlayerPOSUpdate()
                    ),

                new Zeta.TreeSharp.PrioritySelector(
                    new Zeta.TreeSharp.Decorator(ret => !InitDone,
                        new Zeta.TreeSharp.Action(ret => Init())
                    ),
                     new Zeta.TreeSharp.Decorator(ret => DE.CurrentRoute.Count == 0,
                        new Zeta.TreeSharp.Action(ret => DE.Update())
                    ),
                    new Zeta.TreeSharp.Decorator(ret => DateTime.Now.Subtract(lastUpdatedPOS).TotalSeconds >= 2,
                        new Zeta.TreeSharp.Action(ret => PlayerPOSUpdate())
                    ),
                    new Zeta.TreeSharp.Decorator(ret => lastMoveResult != MoveResult.Moved && (lastMoveResult == MoveResult.Failed || lastMoveResult == MoveResult.PathGenerationFailed),
                       new Zeta.TreeSharp.Action(ret => UpdateRoute())
                    ),
                    new Zeta.TreeSharp.Decorator(ret => DE.CurrentNode.NavigableCenter.Distance(PlayerPOS) <= 10f || lastMoveResult == MoveResult.ReachedDestination,
                        new Zeta.TreeSharp.Action(ret => DE.CurrentRoute.Dequeue())
                    ),
                    new Zeta.TreeSharp.Decorator(ret => !ZetaDia.Me.Movement.IsMoving,
                        new Zeta.TreeSharp.Action(ret => MoveToNextNode())
                    )));

        }
    }

Anyways.. this is a start to a custom dungeon exploring tag... just filter out potential backtracking, add in checks for when to quit, and I don't know.. whatever you feel is necessary. :)
 
Back
Top