Skip to content

Commit

Permalink
Return None and print message when cannot covered whole area
Browse files Browse the repository at this point in the history
  • Loading branch information
kstanisz committed Jun 4, 2016
1 parent e81ffe3 commit 5005f7e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions a_star.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def expand(self):

def aStar(cameras):
root = node()
if not geometry.isGalleryCovered(root.camerasState):
return None
root.expand()
nodesQueueByFScore = PriorityQueue()
nodesQueueByFScore.put(root,-root.fScore*1000 - root.stepCost)
Expand Down
6 changes: 6 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ def read_data_from_file():
def print_results(cameras,node,a_star_time):
print("LISTA WSZYSTKICH DOSTĘPNYCH KAMER: ")
print_cameras_coordinates(cameras)
if node is None:
print("NIE DA SIĘ POKRYĆ WSZYSTKIMI KAMERAMI CAŁEGO OBSZARU!")
return
print("\nKAMERY, KTÓRE NALEŻY WŁĄCZYĆ: ")
print_cameras_to_turn_on(node)
print()
Expand All @@ -31,6 +34,9 @@ def print_cameras_to_turn_on(node):

def print_experiment_results(a_star_time,cameras,node):
amountOfTurnOnCameras = 0
if node is None:
print("{}\t{}\t{}\t{}\t{}".format(float(sys.argv[2]), float(sys.argv[3]), a_star_time, geometry.Gallery.camerasAmount,"-"))
return
for (i,camera) in enumerate(node.camerasState):
if node.camerasState[i] == True:
amountOfTurnOnCameras +=1
Expand Down

0 comments on commit 5005f7e

Please sign in to comment.