Change priority method in AutomaticMovement.py
Now priority method calculates pr for given node
This commit is contained in:
parent
2e6f2db543
commit
e01dfeb85a
@ -2,8 +2,11 @@ from copy import copy
|
|||||||
|
|
||||||
from src.entities.Entity import Entity
|
from src.entities.Entity import Entity
|
||||||
from src.entities.Player import Movement, Rotations
|
from src.entities.Player import Movement, Rotations
|
||||||
|
from src.AI.AStarNode import AStarNode
|
||||||
from queue import PriorityQueue
|
from queue import PriorityQueue
|
||||||
|
|
||||||
|
from src.game.TerrainTile import TerrainTile
|
||||||
|
|
||||||
|
|
||||||
class AutomaticMovement:
|
class AutomaticMovement:
|
||||||
|
|
||||||
@ -81,22 +84,21 @@ class AutomaticMovement:
|
|||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def approximateDistanceFromTarget(self, nextTileX, nextTileY):
|
def approximateDistanceFromTarget(self, tileX, tileY):
|
||||||
return abs(nextTileX - self.actualTarget.x) + abs(nextTileY - self.actualTarget.y)
|
return abs(tileX - self.actualTarget.x) + abs(tileY - self.actualTarget.y)
|
||||||
|
|
||||||
def stepCost(self, destinationTile):
|
def stepCost(self, terrainTile: TerrainTile):
|
||||||
# TODO : w oparciu o koszt danej kratki
|
return terrainTile.cost
|
||||||
return 1
|
|
||||||
|
|
||||||
def priority(self, apprDist, stepCost):
|
|
||||||
return apprDist + stepCost
|
|
||||||
|
|
||||||
|
def priority(self, elem: AStarNode):
|
||||||
|
return self.approximateDistanceFromTarget(elem.state[0], elem.state[1]) + self.stepCost(self.map.getTileOnCoord(elem.state))
|
||||||
|
|
||||||
'''
|
'''
|
||||||
state[0] - x
|
state[0] - x
|
||||||
state[1] - y
|
state[1] - y
|
||||||
state[2] - rotation
|
state[2] - rotation
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def newStateAfterAction(self, state, action: Movement):
|
def newStateAfterAction(self, state, action: Movement):
|
||||||
newState = copy(state)
|
newState = copy(state)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user