Пример #1
0
 public TopologyGraph(HexagonalMap map)
 {
     _map      = map;
     _hexes    = new HexaAdjacentList[_map.mapWidth, _map.mapHeight];
     _edgeList = new List <HexaGridEdge>();
     Init();
 }
Пример #2
0
 public ExhaustiveDFSPathPlanner(HexagonalMap map, Robot agent)
     : base(map, agent)
 {
     _maxPath    = null;
     _maxScore   = 0.0;
     _pathNumCnt = 0;
 }
Пример #3
0
        public Agent(HexagonalMap map)
        {
            _map = map;
            path = new HexaPath();

            confidenceFactor = _defaultConfidenceFactor;
        }
Пример #4
0
 public MapStateManager(MapStateManager baseMgr)
 {
     _map         = baseMgr._map;
     _width       = baseMgr._width;
     _height      = baseMgr._height;
     _probability = (double[, ])baseMgr._probability.Clone();
     _entropy     = (double[, ])baseMgr._entropy.Clone();
 }
Пример #5
0
        public VisibilityGraph(HexagonalMap map)
        {
            _map    = map;
            _width  = _map.mapWidth;
            _height = _map.mapHeight;

            _visibilityGraph = new HexagonalMap(_width, _height, _map.mapSide / 2, _map.mapOrientation);
        }
Пример #6
0
 public MapStateManager(HexagonalMap map)
 {
     _map         = map;
     _width       = _map.mapWidth;
     _height      = _map.mapHeight;
     _probability = new double[_width, _height];
     _entropy     = new double[_width, _height];
     Init();
 }
Пример #7
0
 public TreeExpandingWithIterativeTrackingPathPlanner(HexagonalMap map, Robot agent)
     : base(map, agent)
 {
     scoreAtFirstRun   = 0.0;
     exploredSize      = 0;
     problemSize       = 0;
     totalRunTime      = 0;
     hitOptimalRunTime = 0;
     finalMaxScore     = 0.0;
 }
Пример #8
0
 public PlanningForm(PathPlanningGraph graph, HexagonalMap map, Agent agent, HexaPos startPos, HexagonalMapDrawer mapDrawer, HexaPath humanPath = null)
 {
     _graph      = graph;
     _map        = map;
     _mapDrawer  = mapDrawer;
     _agent      = agent;
     _startPos   = startPos;
     _humanPath  = humanPath;
     _planMethod = planMethod.UNKNOWN;
     InitializeComponent();
 }
Пример #9
0
        public SimTestForm(ParameterManager paramMgr)
        {
            _paramMgr   = paramMgr;
            _map        = new HexagonalMap(paramMgr.simTestWidth, paramMgr.simTestHeight, paramMgr.simTestSize, Hexagonal.HexOrientation.Pointy);
            _mapDrawer  = new HexagonalMapDrawer(_map, 5, 5);
            _human      = new Human(_map);
            _robot      = new Robot(_map);
            _planMethod = PlanningForm.planMethod.UNKNOWN;

            InitializeComponent();
        }
Пример #10
0
        public TopologyGraph(HexagonalMap map)
        {
            _map      = map;
            _hexes    = new HexaAdjacentList[_map.mapWidth, _map.mapHeight];
            _edgeList = new List <HexaGridEdge>();
            _mG       = new UndirectedGraph <string, QuickGraph.Edge <string> >();

            Init();

            InitGraph();
        }
Пример #11
0
        private void MapForm_Closing(object sender, FormClosingEventArgs e)
        {
            if (_mapDrawer != null)
            {
                _mapDrawer = null;
            }

            if (_map != null)
            {
                _map = null;
            }
        }
        public GeneticAlgorithmPathPlanner(HexagonalMap map, Robot agent)
            : base(map, agent)
        {
            punishFactor  = 20.0;
            chromeNum     = 200;
            bestChromeNum = 60;
            crossoverNum  = 40;
            runTimes      = 500;

            scores     = new double[chromeNum];
            chromes    = new int[chromeNum][];
            newChromes = new int[chromeNum][];
        }
Пример #13
0
        public MapViewForm()
        {
            infoMgr  = new MapInfoManager();
            paramMgr = new ParamMgr();
            appMode  = AppMode.PLANNING;
            planMode = PathPlanMode.MIN_DIST;
            InitializeComponent();
            currentPath = null;
            pathMgr     = null;
            map         = null;

            workingPath  = null;
            mapFilepath  = null;
            dataFilepath = null;
        }
Пример #14
0
        public HexaPath ConvertToPath(AgentMotionSequence sequence, HexaPos currentPos)
        {
            HexagonalMap map  = GetMap();
            HexaPath     path = new HexaPath();

            path.AddPos(currentPos);

            List <HexagonalMap.Direction> .Enumerator e = sequence.mMotions.GetEnumerator();

            while (e.MoveNext())
            {
                HexagonalMap.Direction step = e.Current;
                currentPos = map.GetNext(currentPos, step);
                path.AddPos(currentPos);
            }

            return(path);
        }
Пример #15
0
        public double GetEstimation(Agent agent, double[,] entropy, HexaPos pos, HexagonalMap map)
        {
            double         estimation = entropy[pos.X, pos.Y];
            List <HexaPos> neighbors  = map.GetHexes(pos.X, pos.Y, agent.GetObservationRange());

            List <HexaPos> .Enumerator e = neighbors.GetEnumerator();
            while (e.MoveNext())
            {
                estimation += agent.confidenceFactor * entropy[e.Current.X, e.Current.Y];
            }
            return(estimation);

            /*
             * double[,] localEntropy = (double[,])entropy.Clone();
             * HexaPath localPath = new HexaPath();
             * localPath.AddPos(pos);
             * return agent.Score(localPath, localEntropy);
             */
        }
Пример #16
0
        public MapForm(HexagonalMap map, ParameterManager paramMgr)
        {
            _map       = map;
            _mapDrawer = new HexagonalMapDrawer(_map, 20, 20);
            _paramMgr  = paramMgr;

            _formState = FormState.IDLE;

            _human = new Human(_map);
            _robot = new Robot(_map);

            InitializeComponent();

            transitTimer       = new Timer();
            transitTimer.Tick += new EventHandler(this.ShowSearchSpace);

            transitCurrentCnt = 0;
            _visGraphForm     = new VisibilityGraphForm(_map);
        }
Пример #17
0
        public double[,] CalcVal(HexagonalMap map)
        {
            double[,] newEntropy = (double[, ])map.GetMapStateMgr().GetEntropy().Clone();

            //how to caculate a point?
            // check GMM one by one , take the max

            for (int i = 0; i < map.Height; i++)
            {
                for (int j = 0; j < map.Width; j++)
                {
                    Hex hex = map.GetHex(i, j);

                    double maxVal = 0.0;
                    List <Gaussian> .Enumerator e = gaussianList.GetEnumerator();
                    while (e.MoveNext())
                    {
                        double gVal     = 0;
                        int    pointNum = hex.Points.Length;
                        double centerX  = 0.0;
                        double centerY  = 0.0;
                        for (int k = 0; k < pointNum; k++)
                        {
                            centerX += hex.Points[k].X;
                            centerY += hex.Points[k].Y;
                        }

                        centerX = centerX / (double)pointNum;
                        centerY = centerY / (double)pointNum;
                        gVal    = CalcGaussian(e.Current, centerX, centerY);

                        if (maxVal < gVal)
                        {
                            maxVal = gVal;
                        }
                    }
                    newEntropy[i, j] = maxVal;
                }
            }

            return(newEntropy);
        }
Пример #18
0
    private void Start()
    {
        Map = GetComponent <HexagonalMap>();
        Map.GetCircle(0)[0].GetComponent <Sprites>().ReplaceSprite(0, Standard);

        var amount  = (int)(Map.Count * 0.05f);
        var exclude = new HashSet <Vector2>(new Vector2[] { Vector2.zero });

        var a = Map.GetRandomLocations(amount, exclude);

        exclude.UnionWith(a);

        var b = Map.GetRandomLocations(amount, exclude);

        exclude.UnionWith(b);

        foreach (var tile in Map.GetTiles())
        {
            var sprites = tile.gameObject.GetComponent <Sprites>();
            sprites.AppendSprite(Standard);

            if (a.Contains(tile.Circle))
            {
                sprites.InsertSprite(1, A);
                sprites.InsertSprite(2, B);
            }
            else if (b.Contains(tile.Circle))
            {
                sprites.InsertSprite(1, B);
                sprites.InsertSprite(2, A);
            }
            else
            {
                sprites.AppendSprite(A);
                sprites.AppendSprite(B);
            }
        }
    }
Пример #19
0
        static void Main()
        {
            string       logFilename = "Log-" + DateTime.Now.Ticks + ".txt";
            StreamWriter sw          = new StreamWriter(logFilename);

            Console.SetOut(sw);
            sw.AutoFlush = true;


            ParameterManager mgr = new ParameterManager();

            mgr.Load();

            HexagonalMap map = new HexagonalMap(mgr.hexagonalWidthNum, mgr.hexagonalHeightNum, mgr.hexagonalSize, Hexagonal.HexOrientation.Pointy);

            map.GetState().BackgroundColor      = Color.White;
            map.GetState().GridPenWidth         = 2;
            map.GetState().ActiveHexBorderColor = Color.Red;
            map.GetState().ActiveHexBorderWidth = 2;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            MapForm form = new MapForm(map, mgr);

            //form.Width = mgr.winFormWidth;
            //form.Height = mgr.winFormHeight;

            Application.Run(form);

            //Generate human path here



            sw.Flush();
            sw.Close();
        }
Пример #20
0
 public IterativeBacktrackPathPlanner(HexagonalMap map, Robot agent)
     : base(map, agent)
 {
 }
Пример #21
0
 public BackPropPathPlanner(HexagonalMap map, Robot agent)
     : base(map, agent)
 {
 }
Пример #22
0
 public Robot(HexagonalMap map)
     : base(map)
 {
 }
Пример #23
0
 public Human(HexagonalMap map) : base(map)
 {
     motion = new AgentMotionSequence();
     _wingmanToleranceRange = new int();
 }
Пример #24
0
 public PathPlanner(HexagonalMap map, Robot agent)
 {
     _map          = map;
     _agent        = agent;
     _localEntropy = _map.GetMapStateMgr().CopyEntropy();
 }
Пример #25
0
 public IterativeBacktrackWithBeamSearchPathPlanner(HexagonalMap map, Robot agent)
     : base(map, agent)
 {
     beamPaths  = new HexaPath[beamNum * 2];
     beamScores = new double[beamNum * 2];
 }
Пример #26
0
 public PathManager(HexagonalMap map, string map_filename)
 {
     _map         = map;
     _mapFilename = map_filename;
 }
Пример #27
0
        ExpandingNode NodeSpanning(ExpandingTree tree, ExpandingNode node, HexaPath path, double[,] entropy, PathPlanningGraph graph, HexagonalMap map)
        {
            PlanningNode         planNode     = node.planningNode;
            List <ExpandingNode> newGenerated = new List <ExpandingNode>();
            // find all child nodes
            int curLevel = path.Length - 1;

            if (curLevel < graph.planningLength - 1)
            {
                List <PlanningEdge>             nextEdges = graph[curLevel].GetEdges(planNode);
                List <PlanningEdge> .Enumerator enumEd    = nextEdges.GetEnumerator();
                while (enumEd.MoveNext())
                {
                    ExpandingNode newNode = new ExpandingNode(enumEd.Current.to);
                    tree.AddToParent(newNode, node);
                    newGenerated.Add(newNode);

                    // if new node is already end level,
                    // set it as EXPANDED
                    if (curLevel == graph.planningLength - 2)
                    {
                        newNode.state = ExpandingNode.STATE.EXPANDED;
                    }
                }
            }

            // set node to EXPANDED
            node.state = ExpandingNode.STATE.EXPANDED;

            //update the new generated node
            List <ExpandingNode> .Enumerator e2 = newGenerated.GetEnumerator();
            while (e2.MoveNext())
            {
                HexaPath tempPath = tree.GetPath(e2.Current);
                double[,] tempEntropy = (double[, ])entropy.Clone();
                UpdateNodeReward(e2.Current, tempPath, tempEntropy, graph);
            }

            //find max node
            double        maxNodeVal = 0.0;
            ExpandingNode maxNode    = null;

            List <ExpandingNode> .Enumerator e3 = newGenerated.GetEnumerator();
            while (e3.MoveNext())
            {
                if (e3.Current.maxVal > maxNodeVal)
                {
                    maxNode    = e3.Current;
                    maxNodeVal = e3.Current.maxVal;
                }
                else
                {
                    if (maxNode == null)
                    {
                        maxNode = e3.Current;
                    }
                }
            }

            return(maxNode);
        }
Пример #28
0
 public InfoMaxPathPlanner(HexagonalMap map, Robot agent)
     : base(map, agent)
 {
 }
Пример #29
0
 public SimpleGreedyPathPlanner(HexagonalMap map, Robot agent)
     : base(map, agent)
 {
 }
Пример #30
0
 public VisibilityGraphForm(HexagonalMap map)
 {
     _visibilityGraph = new VisibilityGraph(map);
     _graphDrawer     = new HexagonalMapDrawer(_visibilityGraph.VisGraph);
     InitializeComponent();
 }