Search in sources :

Example 31 with Point2D

use of aima.core.util.math.geom.shapes.Point2D in project aima-java by aimacode.

the class OsmAgentBaseApp method simulate.

/** Starts the experiment. */
public void simulate() {
    List<MapNode> markers = map.getOsmMap().getMarkers();
    if (markers.size() < 2) {
        simPaneCtrl.setStatus("Error: Please set at least 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 = createEnvironment();
        env.addEnvironmentView(new TrackUpdater());
        env.addAgent(agent, locations.get(0));
        if (simPaneCtrl.getParam(PARAM_SEARCH).isPresent())
            env.notifyViews("Using " + simPaneCtrl.getParamValue(PARAM_SEARCH));
        while (!env.isDone() && !CancelableThread.currIsCanceled()) {
            env.step();
            simPaneCtrl.waitAfterStep();
        }
        envViewCtrl.notify("");
    // simPaneCtrl.setStatus(search.getMetrics().toString());
    }
}
Also used : MapAgent(aima.core.environment.map.MapAgent) Point2D(aima.core.util.math.geom.shapes.Point2D) ArrayList(java.util.ArrayList) MapNode(aimax.osm.data.entities.MapNode)

Example 32 with Point2D

use of aima.core.util.math.geom.shapes.Point2D 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

Point2D (aima.core.util.math.geom.shapes.Point2D)32 Map (aima.core.environment.map.Map)7 ArrayList (java.util.ArrayList)6 IGeometric2D (aima.core.util.math.geom.shapes.IGeometric2D)5 Before (org.junit.Before)5 Circle2D (aima.core.util.math.geom.shapes.Circle2D)4 Ellipse2D (aima.core.util.math.geom.shapes.Ellipse2D)4 Polyline2D (aima.core.util.math.geom.shapes.Polyline2D)4 Test (org.junit.Test)4 Line2D (aima.core.util.math.geom.shapes.Line2D)3 Ray2D (aima.core.util.math.geom.shapes.Ray2D)3 MapNode (aimax.osm.data.entities.MapNode)3 Agent (aima.core.agent.Agent)2 LRTAStarAgent (aima.core.search.online.LRTAStarAgent)2 Circle (javafx.scene.shape.Circle)2 Line (javafx.scene.shape.Line)2 Text (javafx.scene.text.Text)2 aima.core.environment.map (aima.core.environment.map)1 MapAgent (aima.core.environment.map.MapAgent)1 MapEnvironment (aima.core.environment.map.MapEnvironment)1