diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..6131751955d8869f1da98624a047f94ce2655eb2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.svg \ No newline at end of file diff --git a/Acht-Damen.py b/Acht-Damen.py index 2fa708495c37521db703c1b9d29f1f3033dfa3d3..844eabbb16b78d38ad7b5299335e851a4b79f8d5 100644 --- a/Acht-Damen.py +++ b/Acht-Damen.py @@ -1,6 +1,9 @@ import numpy as np from copy import deepcopy - +import chess +import chess.svg +from IPython.display import Image +from IPython.display import SVG class Board: blocked = 0 @@ -71,10 +74,36 @@ class Board: return True else: return False + + def display_chess_board(self) -> None: + string = "" + for row in range(self.dimY): + spaces = 0 + for column in range(self.dimX): + if self.board[column, row] == self.queen: + if spaces > 0: + string += str(spaces) + string += "q" + spaces = 0 + else: + spaces += 1 + if spaces > 0: + string += str(spaces) + if row < self.dimY-1: + string += "/" + + board = chess.Board(string) + boardsvg = chess.svg.board(board, size=350) + outputfile = open('temp.svg', "w") + outputfile.write(boardsvg) + outputfile.close() + display(SVG("temp.svg")) if __name__ == "__main__": board = Board(8, 8) + num_queens = 8 + solutions = [] saved_boards = [] iters = 0 @@ -85,3 +114,15 @@ if __name__ == "__main__": board.toConsole() saved_boards.append(board.copy()) print("Queens: " + str(iters)) + board.display_chess_board() + + + def recurse(board: Board, branch: int, depth: int) -> None: + # Anker: + + + oldBoard = board + workboard = board.copy() + # traversiere links + + \ No newline at end of file