一个简单的探路工具,一个*
astar-python的Python项目详细描述
#Python之星
>使用:
>
-从Python之星导入Python
>建立你的体重图:
``Python
=[
mat=[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,00,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0],
]
`````
````python
astar=astar(mat)
`````
``python
``python
result=astar.run([0,0,[10,10,9])
```````````
result=astar.run([0,0,[10,10,9])
````````python
``````````````python
astar astar astar=astar(mat)
/>--
[[0,0],[1,1],[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 9]]
```
If no way to the end, A* return None
give:
```python
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1]
```
# Weights
A weight on the matrix is the cost to cross the point.
Cost can be:
* positive: more it is positive, 越区越难越难
*负:就像助推器一样,你可以定制自己的方式
*0:一个正常点
*无:不可跨越
例如:数字“1”是所采取的方式,其他的是重量
`` python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,0,0,0,0,0,0,0,1]
工具 the to run none is result astar mat
>使用:
>
-从Python之星导入Python
>建立你的体重图:
``Python
=[
mat=[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,00,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0],
]
`````
````python
astar=astar(mat)
`````
``python
``python
result=astar.run([0,0,[10,10,9])
```````````
result=astar.run([0,0,[10,10,9])
````````python
``````````````python
astar astar astar=astar(mat)
/>--
[[0,0],[1,1],[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 9]]
```
If no way to the end, A* return None
give:
```python
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1]
```
# Weights
A weight on the matrix is the cost to cross the point.
Cost can be:
* positive: more it is positive, 越区越难越难
*负:就像助推器一样,你可以定制自己的方式
*0:一个正常点
*无:不可跨越
例如:数字“1”是所采取的方式,其他的是重量
`` python
`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