zoukankan      html  css  js  c++  java
  • A* pseudocode

    struct node {
        node *parent;
        int x, y;
        float f, g, h;
    }
     
    
    // A*
    initialize the open list
    initialize the closed list
    put the starting node on the open list (you can leave its f at zero)
    
    while the open list is not empty
        find the node with the least f on the open list, call it "q"
        pop q off the open list
        generate q's 8 successors and set their parents to q
        for each successor
            if successor is the goal, stop the search
            successor.g = q.g + distance between successor and q
            successor.h = distance from goal to successor
            successor.f = successor.g + successor.h
    
            if a node with the same position as successor is in the OPEN list 
                which has a lower f than successor, skip this successor
            if a node with the same position as successor is in the CLOSED list  
                which has a lower f than successor, skip this successor
            otherwise, add the node to the open list
        end
        push q on the closed list
    end
  • 相关阅读:
    二叉树中序遍历
    前序遍历
    配置免秘钥登录
    pip安装
    zookeeper C client API 和zkpython 的安装
    安装 Java
    json递归查询
    php 编译安装
    docker 中 安装配置 mysqlcluster(arm)
    glibc编译安装
  • 原文地址:https://www.cnblogs.com/yk00/p/3214622.html
Copyright © 2011-2022 走看看