Preface
The A* algorithm was first proposed in 1964 in the paper "A Formal Basis for the Heuristic Determination of Minimum Cost Paths" in IEEE Transactions on Systems Science and Cybernetics.
It is a classic heuristic search method. The so-called heuristic search means that when the current search node goes down to select the next node, it can be selected through a heuristic function, and the node with the least cost is selected as the next search node. node and jump to it.
In traditional algorithms, Depth First Search (DFS) and Breadth First Search (BFS) are blind searches when expanding child nodes. That is to say, they will not choose which node is better in the next search and jump to it. Go to this node for the next step of search.
In the case of bad luck, the entire solution set space needs to be explored. Obviously, it can only be applied to search problems with a small problem size.
What is different from DFS and BFS is that a carefully designed heuristic function can often obtain the optimal solution to a search problem in a very short time.
Code
Python
import os
import sys
import math
import heapq
import matplotlib.pyplot as plt
class AStar:
"""AStar set the cost + heuristics as the priority
"""
def __init__(self, s_start, s_goal, heuristic_type,xI, xG):
self.s_start = s_start
self.s_goal = s_goal
self.heuristic_type = heuristic_type