Skip to content

Commit

Permalink
Skip balancer sizes that are too small to fit required splitters
Browse files Browse the repository at this point in the history
  • Loading branch information
R-O-C-K-E-T committed Aug 25, 2024
1 parent d26eea6 commit 4b3dd78
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion factorio_sat/calculate_optimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ def next_size(self, store: NetworkSolutionStore, underground_length: int) -> Opt
if existence:
return None

if existence is None:
interior_area = (width - 2) * height
if interior_area >= len(store.network) * 2 and existence is None:
return size
width += 1

Expand All @@ -151,6 +152,10 @@ def next_size(self, store: NetworkSolutionStore, underground_length: int) -> Opt
if height < min_height or height > 2 * min_height:
continue

interior_area = width * height
if interior_area < len(store.network) * 2:
continue

size = underground_length, width + 2, height
existence = store.does_balancer_exist(size)
if existence:
Expand Down
4 changes: 2 additions & 2 deletions test/test_end_to_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def tokenise(lines: List[str]) -> List[Token]:
for row, line in line_iter:
if not line.startswith(TEST_EDGE_START):
if len(line) > 0 and line[0] in TEST_EDGES:
raise RuntimeError(f'Invalid line start character "{line[0]}" at line {row+1}')
raise RuntimeError(f'Invalid line start character "{line[0]}" at line {row + 1}')

match = block_start.match(line)
if match is not None:
Expand All @@ -143,7 +143,7 @@ def tokenise(lines: List[str]) -> List[Token]:
if not line.startswith(TEST_EDGE_MIDDLE):
break
if not line.startswith(TEST_EDGE_STOP):
raise RuntimeError(f'Invalid test instance format at line {row+1}')
raise RuntimeError(f'Invalid test instance format at line {row + 1}')
tokenised.append(Token('test', row + 1, stringifier.decode(test_case)))
return tokenised

Expand Down

0 comments on commit 4b3dd78

Please sign in to comment.