Search in sources :

Example 31 with MapEnvironment

use of aima.core.environment.map.MapEnvironment in project aima-java by aimacode.

the class OsmLRTAStarAgentApp method simulate.

/** Starts the experiment. */
public void simulate() {
    List<MapNode> markers = map.getOsmMap().getMarkers();
    if (markers.size() < 2) {
        simPaneCtrl.setStatus("Error: Please set two markers with mouse-left.");
    } else {
        List<String> locations = new ArrayList<>(markers.size());
        for (MapNode node : markers) {
            Point2D pt = new Point2D(node.getLon(), node.getLat());
            locations.add(map.getNearestLocation(pt));
        }
        Agent agent = createAgent(locations);
        env = new MapEnvironment(map);
        env.addEnvironmentView(new TrackUpdater());
        env.addAgent(agent, locations.get(0));
        while (!env.isDone() && !CancelableThread.currIsCanceled()) {
            env.step();
            simPaneCtrl.waitAfterStep();
        }
    }
}
Also used : LRTAStarAgent(aima.core.search.online.LRTAStarAgent) Point2D(aima.core.util.math.geom.shapes.Point2D) ArrayList(java.util.ArrayList) MapEnvironment(aima.core.environment.map.MapEnvironment) MapNode(aimax.osm.data.entities.MapNode)

Aggregations

MapEnvironment (aima.core.environment.map.MapEnvironment)31 Test (org.junit.Test)25 SimpleMapAgent (aima.core.environment.map.SimpleMapAgent)19 ExtendableMap (aima.core.environment.map.ExtendableMap)17 MoveToAction (aima.core.environment.map.MoveToAction)8 GeneralProblem (aima.core.search.framework.problem.GeneralProblem)7 GoalTest (aima.core.search.framework.problem.GoalTest)7 LRTAStarAgent (aima.core.search.online.LRTAStarAgent)4 OnlineDFSAgent (aima.core.search.online.OnlineDFSAgent)4 UniformCostSearch (aima.core.search.uninformed.UniformCostSearch)2 ArrayList (java.util.ArrayList)2 Agent (aima.core.agent.Agent)1 Point2D (aima.core.util.math.geom.shapes.Point2D)1 MapNode (aimax.osm.data.entities.MapNode)1 Before (org.junit.Before)1