Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Apoorva Appadoo Srinivas committed Feb 16, 2024
2 parents cc2e88d + 1461409 commit e9b1393
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 56 deletions.
47 changes: 0 additions & 47 deletions get_true_pieces/main.py

This file was deleted.

1 change: 0 additions & 1 deletion gui/eternitylib/board.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def read_csv(self, csv: str):
set(pattern for line in csv.split("\n") if line.strip() for pattern in line.split(","))
)


for i, line in enumerate(csv.split("\n")):
if line.strip() == "":
continue
Expand Down
5 changes: 0 additions & 5 deletions gui/eternitylib/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,3 @@ def shuffle_board(board):
piece.append(piece.pop(0))
np.random.shuffle(board)
return board


board = create_board(size, number_of_symbols)
print(print_board(board))
print(format_board(shuffle_board(board)))
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,10 @@ def generate_board(size: int, pattern_count: int) -> (str, Path, Path):
if __name__ == "__main__":
solver = Solver()
solver.link_solver()

board = Board()
board.generate(10, 22)

print(solver.solve(board))

# interface.launch(share=True)
6 changes: 6 additions & 0 deletions gui/solverlib/execution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Execution:
def __init__(self, logs: str):
self.logs = logs

def parse_logs(self):
pass
13 changes: 10 additions & 3 deletions gui/solverlib/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,19 @@ def __init__(self):
# exe is in the same dir as this file
self.exe_path = Path(__file__).parent / "e2solver"

def link_solver(self, exe_path: Path = Path(__file__).parent.parent.parent / "cmake-build-debug/solver/Solver"):
subprocess.run(["ln", "-s", str(exe_path), str(self.exe_path)])
def link_solver(self, path: Path = Path(__file__).parent.parent.parent / "cmake-build-debug/solver/Solver"):
# If file does not exist, raise an error
if not path.exists():
raise FileNotFoundError(f"Solver executable not found at {path}")

if self.exe_path.exists():
self.exe_path.unlink()

self.exe_path.symlink_to(path)

def solve(self, board: Board, timeout: int = 60) -> str:
# Write the board to a file
board_path = Path(__file__).parent / f"board.{board.hash()}.txt"
board_path = Path(__file__).parent.parent / f"tmp/board.{board.hash()}.txt"
board_path.write_text(board.to_csv())

# Run the solver
Expand Down

0 comments on commit e9b1393

Please sign in to comment.