AStar¶
-
class
vindinium.ai.
AStar
(map)[source]¶ Bases:
object
A* algorithm specialized for vindinium.
The A* algorithm receives an instance of
vindinium.models.Map`
and compute the best path when necessary.-
cost_avoid
¶ float
cost to walk over an avoidable tile (consult the avoid_tiles attribute). Defaults to 4.
-
cost_move
¶ float
cost to walk over an empty tile. Defaults to 1.
-
obstacle_tiles
¶ list
a list of obstacles tile VALUES.
-
avoid_tiles
¶ list
a list of avoidable tile VALUES.
-
__init__
(map)[source]¶ Constructor.
Parameters: map (vindinium.models.Map) – the map instance.
-
find
(x0, y0, x1, y1)[source]¶ Find a path between (x0, y0) and (x1, y1).
Parameters: - x0 (int) – initial position in X.
- y0 (int) – initial position in Y.
- x1 (int) – goal position in X.
- y1 (int) – goal position in Y.
Returns: - (list) if the path has been found, e.g.
[(0, 1), (0, 2), ...]
. Notice that, it does not include the initial position, but include the goal.
(None) otherwise.
-