Skip to content

Commit

Permalink
Final Brain Cell SIFT
Browse files Browse the repository at this point in the history
  • Loading branch information
v-h-gn committed Mar 25, 2023
1 parent 0a2f694 commit 6662989
Show file tree
Hide file tree
Showing 10 changed files with 189 additions and 48 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ __pycache__/
*.zip
build/
dist/
*.spec
*.spec
*OUTBOUND.txt
*TEMP.txt
18 changes: 9 additions & 9 deletions case3OUTBOUND.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
[01, 10], {00000}, UNUSED
[01, 09], {00000}, UNUSED
[01, 08], {00000}, UNUSED
[01, 07], {00000}, UNUSED
[01, 07], {10001}, Ewe
[01, 06], {00000}, UNUSED
[01, 05], {00000}, UNUSED
[01, 04], {00100}, Rat
[01, 03], {00600}, Dog
[01, 02], {00000}, UNUSED
[01, 01], {10001}, Ewe
[01, 02], {00500}, Cow
[01, 01], {00000}, UNUSED
[02, 12], {00000}, UNUSED
[02, 11], {00000}, UNUSED
[02, 10], {00000}, UNUSED
Expand All @@ -20,8 +20,8 @@
[02, 05], {00000}, UNUSED
[02, 04], {00000}, UNUSED
[02, 03], {00000}, UNUSED
[02, 02], {00000}, UNUSED
[02, 01], {09041}, Cat
[02, 02], {00010}, Doe
[02, 01], {00000}, UNUSED
[03, 12], {00000}, UNUSED
[03, 11], {00000}, UNUSED
[03, 10], {00000}, UNUSED
Expand All @@ -32,8 +32,8 @@
[03, 05], {00000}, UNUSED
[03, 04], {00000}, UNUSED
[03, 03], {00000}, UNUSED
[03, 02], {00000}, UNUSED
[03, 01], {00010}, Doe
[03, 02], {09041}, Cat
[03, 01], {00000}, UNUSED
[04, 12], {00000}, UNUSED
[04, 11], {00000}, UNUSED
[04, 10], {00000}, UNUSED
Expand All @@ -45,7 +45,7 @@
[04, 04], {00000}, UNUSED
[04, 03], {00000}, UNUSED
[04, 02], {00000}, UNUSED
[04, 01], {00333}, Bat
[04, 01], {00000}, UNUSED
[05, 12], {00000}, UNUSED
[05, 11], {00000}, UNUSED
[05, 10], {00000}, UNUSED
Expand All @@ -57,7 +57,7 @@
[05, 04], {00000}, UNUSED
[05, 03], {00000}, UNUSED
[05, 02], {00000}, UNUSED
[05, 01], {00333}, Rat
[05, 01], {00000}, UNUSED
[06, 12], {00000}, UNUSED
[06, 11], {00000}, UNUSED
[06, 10], {00000}, UNUSED
Expand Down
8 changes: 4 additions & 4 deletions case3TEMP.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
[04, 11], {00000}, UNUSED
[04, 12], {00000}, UNUSED
[03, 01], {00000}, UNUSED
[03, 02], {00000}, UNUSED
[03, 02], {09041}, Cat
[03, 03], {00000}, UNUSED
[03, 04], {00000}, UNUSED
[03, 05], {00000}, UNUSED
Expand All @@ -71,8 +71,8 @@
[03, 11], {00000}, UNUSED
[03, 12], {00000}, UNUSED
[02, 01], {00000}, UNUSED
[02, 02], {09041}, Cat
[02, 03], {00010}, Doe
[02, 02], {00010}, Doe
[02, 03], {00000}, UNUSED
[02, 04], {00000}, UNUSED
[02, 05], {00000}, UNUSED
[02, 06], {00000}, UNUSED
Expand All @@ -83,7 +83,7 @@
[02, 11], {00000}, UNUSED
[02, 12], {00000}, UNUSED
[01, 01], {00000}, UNUSED
[01, 02], {00334}, Bat
[01, 02], {00500}, Cow
[01, 03], {00600}, Dog
[01, 04], {00100}, Rat
[01, 05], {00000}, UNUSED
Expand Down
96 changes: 96 additions & 0 deletions case4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
[01,01], {00000}, NAN
[01,02], {00000}, NAN
[01,03], {00000}, NAN
[01,04], {00000}, NAN
[01,05], {00000}, NAN
[01,06], {00000}, NAN
[01,07], {00000}, NAN
[01,08], {00000}, NAN
[01,09], {00000}, NAN
[01,10], {00000}, NAN
[01,11], {00000}, NAN
[01,12], {00000}, NAN
[02,01], {00000}, NAN
[02,02], {00000}, UNUSED
[02,03], {00000}, UNUSED
[02,04], {00000}, UNUSED
[02,05], {02000}, Cat
[02,06], {00000}, UNUSED
[02,07], {00000}, UNUSED
[02,08], {00000}, UNUSED
[02,09], {00000}, UNUSED
[02,10], {00000}, UNUSED
[02,11], {00000}, UNUSED
[02,12], {00000}, NAN
[03,01], {00000}, UNUSED
[03,02], {00000}, UNUSED
[03,03], {00000}, UNUSED
[03,04], {00000}, UNUSED
[03,05], {02007}, Dog
[03,06], {00000}, UNUSED
[03,07], {00000}, UNUSED
[03,08], {00000}, UNUSED
[03,09], {00000}, UNUSED
[03,10], {00000}, UNUSED
[03,11], {00000}, UNUSED
[03,12], {00000}, UNUSED
[04,01], {00000}, UNUSED
[04,02], {00000}, UNUSED
[04,03], {00000}, UNUSED
[04,04], {00000}, UNUSED
[04,05], {02011}, Cow
[04,06], {00000}, UNUSED
[04,07], {00000}, UNUSED
[04,08], {00000}, UNUSED
[04,09], {00000}, UNUSED
[04,10], {00000}, UNUSED
[04,11], {00000}, UNUSED
[04,12], {00000}, UNUSED
[05,01], {00000}, UNUSED
[05,02], {00000}, UNUSED
[05,03], {00000}, UNUSED
[05,04], {00000}, UNUSED
[05,05], {10000}, Ewe
[05,06], {00000}, UNUSED
[05,07], {00000}, UNUSED
[05,08], {00000}, UNUSED
[05,09], {00000}, UNUSED
[05,10], {00000}, UNUSED
[05,11], {00000}, UNUSED
[05,12], {00000}, UNUSED
[06,01], {00000}, UNUSED
[06,02], {00000}, UNUSED
[06,03], {00000}, UNUSED
[06,04], {00000}, UNUSED
[06,05], {02020}, Owl
[06,06], {00000}, UNUSED
[06,07], {00000}, UNUSED
[06,08], {00000}, UNUSED
[06,09], {00000}, UNUSED
[06,10], {00000}, UNUSED
[06,11], {00000}, UNUSED
[06,12], {00000}, UNUSED
[07,01], {00000}, UNUSED
[07,02], {00000}, UNUSED
[07,03], {00000}, UNUSED
[07,04], {00000}, UNUSED
[07,05], {01100}, Doe
[07,06], {00000}, UNUSED
[07,07], {00000}, UNUSED
[07,08], {00000}, UNUSED
[07,09], {00000}, UNUSED
[07,10], {00000}, UNUSED
[07,11], {00000}, UNUSED
[07,12], {00000}, UNUSED
[08,01], {00000}, UNUSED
[08,02], {00000}, UNUSED
[08,03], {00000}, UNUSED
[08,04], {00000}, UNUSED
[08,05], {03044}, Pig
[08,06], {00000}, UNUSED
[08,07], {00000}, UNUSED
[08,08], {00000}, UNUSED
[08,09], {00000}, UNUSED
[08,10], {00000}, UNUSED
[08,11], {00000}, UNUSED
[08,12], {00000}, UNUSED
4 changes: 2 additions & 2 deletions case5.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[01,01], {00000}, NAN
[01,02], {00008}, Cat
[01,03], {00096}, Dog
[01,02], {00096}, Cat
[01,03], {00008}, Dog
[01,04], {00004}, Pig
[01,05], {00004}, Hen
[01,06], {00001}, Rat
Expand Down
2 changes: 1 addition & 1 deletion grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def convert_grid_to_stack(self):
stack = Stack.Stack(j, self.rows)
for i in range(self.rows - 1, -1, -1):
cont = self.grid[i][j]
if cont is not None and cont.get_description() != " NAN":
if cont is not None:
stack.push(cont)
self.stacks.append(stack)

Expand Down
33 changes: 28 additions & 5 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,24 @@ def load_manifest(self):
fileName = os.path.basename(filePath)
self.currManifestFileDisplay.config(text=fileName)
self.manifest = filePath
self.task = None
self.offloadList = []
self.onloadList = []
self.bufferList = []
self.current_step = 0
self.total_steps = 999
self.ship_bay = Grid.ShipBay()
self.buffer = Grid.Buffer()
self.optimizer = optimizer.Optimizer()
self.animation = None
self.time_estimate = 0
self.time_total = 999
self.onloadSelected = False
self.offloadSelected = False
self.task_complete = False
self.bayListMain = []
self.bayListOffload = []
self.currTaskDisplay.config(text="")
self.write_to_log("Manifest %s has been selected." % (self.manifest))
self.read_manifest()
self.write_to_log("Parsing manifest %s is complete." % (self.manifest))
Expand Down Expand Up @@ -240,11 +258,16 @@ def progress_animation(self):
self.offloadSelected = False
self.offloadList = []
self.onloadList = []

def update_time_estimate(self):
hours = int(self.time_estimate / 60)
minutes = int(self.time_estimate % 60)
self.currTimeEstimateDisplay.config(text="%2dH %2dM" % (hours, minutes))
self.update_time_estimate(clear=True)
self.display_move("")

def update_time_estimate(self, clear=False):
if not clear:
hours = int(self.time_estimate / 60)
minutes = int(self.time_estimate % 60)
self.currTimeEstimateDisplay.config(text="%2dH %2dM" % (hours, minutes))
else:
self.currTimeEstimateDisplay.config(text="")

# task selection pop up
def choose_task(self):
Expand Down
11 changes: 5 additions & 6 deletions move.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def buffer_move_cost(self, container_pos, crane_end_in_buffer) -> int:
return base_cost + abs(cont_grab_row - crane_end_row) + abs(cont_col - crane_end_col) + 4

def column_move_cost(self, origin_column, dest_column, in_bay) -> int:

origin_stack = self.bay.get_stacks(origin_column) if in_bay else self.buffer.get_stacks(origin_column)
origin_height = origin_stack.get_height()

Expand All @@ -86,7 +85,7 @@ def column_move_cost(self, origin_column, dest_column, in_bay) -> int:
if dest_column == origin_column:
return 0
stacks = self.bay.get_stacks() if self.end_in_bay else self.buffer.get_stacks()

height = max(j.get_height() for j in stacks[min(dest_column, origin_column) : max(dest_column, origin_column)])
dX = abs(dest_column - origin_column)
dY = abs(height + 1 - origin_height) + abs(height + 1 - (dest_height + 1)) if origin_height <= height else abs(dest_height + 1 - origin_height)
Expand All @@ -98,18 +97,18 @@ def check_balanced(self):
for i in range(0, 8):
for j in range(0, 12):
cont = self.get_bay().get_container(i, j)
if cont is not None:
if int(j / 6) % 2 == 0:
if cont is not None and cont.get_description() != "NAN":
if j < 6:
left_mass += cont.get_weight()
else:
right_mass += cont.get_weight()
return (min(left_mass, right_mass) / max(left_mass, right_mass)) >= 0.9, left_mass, right_mass

def get_top_containers(self) -> list["container.Container"]:
if self.end_in_bay:
return [(i.peek(), i.get_column()) for i in self.bay.get_stacks() if i.get_height() > 0 and i.peek().get_description() != "NAN"]
return [(i.peek(), i.get_column()) for i in self.bay.get_stacks() if (i.get_height() > 0 and i.peek().get_description() != "NAN")]
else:
return [(i.peek(), i.get_column()) for i in self.buffer.get_stacks() if i.get_height() > 0 and i.peek().get_description() != "NAN"]
return [(i.peek(), i.get_column()) for i in self.buffer.get_stacks() if (i.get_height() > 0 and i.peek().get_description() != "NAN")]

def __eq__(self, __o: object) -> bool:
return isinstance(__o, Move) and self.bay == __o.bay and self.buffer == __o.buffer and self.init_pos == __o.init_pos and self.end_pos == __o.end_pos and self.end_in_bay == __o.end_in_bay
Expand Down
Loading

0 comments on commit 6662989

Please sign in to comment.