コード例 #1
0
ファイル: Astar.java プロジェクト: mkote/d505e15-p5-impl
 public static void cleanNodes(Map<Long, Node> nodes) {
   for (Node node : nodes.values()) {
     node.g_scores = 0.0;
     node.h_scores = 0.0;
     node.cameFrom = null;
     node.visited = false;
     node.cost = null;
   }
 }
コード例 #2
0
ファイル: Astar.java プロジェクト: mkote/d505e15-p5-impl
 private ArrayList<FakeNode> getNeighbours(long id) {
   ArrayList<FakeNode> retNodes = new ArrayList<>();
   ArrayList<Segment> neighbours =
       this.segments
           .stream()
           .filter(
               (Segment s) -> {
                 return s.mOrigin == id;
               })
           .collect(Collectors.toCollection(ArrayList<Segment>::new));
   neighbours.addAll(
       this.fakeSegments
           .stream()
           .filter(
               (Segment s) -> {
                 return s.mOrigin == id;
               })
           .collect(Collectors.toCollection(ArrayList<Segment>::new)));
   FakeNode node;
   for (Segment s : neighbours) {
     if (fakeNodes.containsKey(s.mDestination)) {
       node = fakeNodes.get(s.mDestination);
     } else {
       node = new FakeNode(nodes.get(s.mDestination));
       fakeNodes.put(s.mDestination, node);
     }
     ArrayList<CostFunction> functions =
         costs
             .stream()
             .filter(
                 (CostFunction c) -> {
                   return c.getSegmentId() == s.mId;
                 })
             .collect(Collectors.toCollection(ArrayList<CostFunction>::new));
     functions.addAll(
         fakeCosts
             .stream()
             .filter(
                 (CostFunction c) -> {
                   return c.getSegmentId() == s.mId;
                 })
             .collect(Collectors.toCollection(ArrayList<CostFunction>::new)));
     node.node.cost = functions.get(0);
     retNodes.add(fakeNodes.get(s.mDestination));
   }
   return retNodes;
 }