2018-09-07 23:46:58 +02:00
|
|
|
class grid_cell:
|
2016-11-17 00:02:07 +01:00
|
|
|
"""
|
|
|
|
|
A single cell that can be occupied in a given layer, blocked,
|
|
|
|
|
visited, etc.
|
|
|
|
|
"""
|
|
|
|
|
def __init__(self):
|
2016-11-17 01:47:31 +01:00
|
|
|
self.path = False
|
2016-11-17 00:02:07 +01:00
|
|
|
self.blocked = False
|
2016-11-17 01:47:31 +01:00
|
|
|
self.source = False
|
|
|
|
|
self.target = False
|
2017-04-24 19:27:04 +02:00
|
|
|
# -1 means it isn't visited yet
|
|
|
|
|
self.min_cost = -1
|
2016-11-17 00:02:07 +01:00
|
|
|
|
2017-04-24 20:28:36 +02:00
|
|
|
def reset(self):
|
|
|
|
|
"""
|
|
|
|
|
Reset the dynamic info about routing. The pins/blockages are not reset so
|
|
|
|
|
that they can be reused.
|
|
|
|
|
"""
|
|
|
|
|
self.min_cost=-1
|
|
|
|
|
self.min_path=None
|
2017-06-05 23:42:56 +02:00
|
|
|
self.blocked=False
|
|
|
|
|
self.source=False
|
|
|
|
|
self.target=False
|
|
|
|
|
|
2017-04-24 20:28:36 +02:00
|
|
|
|
2017-04-24 19:27:04 +02:00
|
|
|
def get_type(self):
|
2016-11-17 00:02:07 +01:00
|
|
|
if self.blocked:
|
2017-04-24 19:27:04 +02:00
|
|
|
return "X"
|
|
|
|
|
|
|
|
|
|
if self.source:
|
|
|
|
|
return "S"
|
2016-11-17 20:24:17 +01:00
|
|
|
|
2017-04-24 19:27:04 +02:00
|
|
|
if self.target:
|
|
|
|
|
return "T"
|
2016-11-17 00:02:07 +01:00
|
|
|
|
2016-11-17 01:47:31 +01:00
|
|
|
if self.path:
|
2017-04-24 19:27:04 +02:00
|
|
|
return "P"
|
2016-11-17 20:24:17 +01:00
|
|
|
|
2017-04-24 19:27:04 +02:00
|
|
|
# We can display the cost of the frontier
|
|
|
|
|
if self.min_cost > 0:
|
2017-05-25 23:18:12 +02:00
|
|
|
return self.min_cost
|
2017-04-24 19:27:04 +02:00
|
|
|
|
2017-05-31 22:59:49 +02:00
|
|
|
return None
|