def calculate_layout(self, pos: Tuple[int, int], tatami_index: int, tmpRoom: Room, half_used: bool) -> None: """ Recursively calculates the layout for a given room, filling the solutions member array with all possible solutions. It doesn't check whether the solutions themselves are rotation or reflection invariant. """ #print(tmpRoom) #room.print_corners() #print(pos) #stop condition: if tmpRoom.is_full() and self.is_solution(tmpRoom): if room not in self.solutions: self.solutions.append(deepcopy(tmpRoom)) #try horizontal: if tmpRoom.can_place_tatami(pos, (Orientation.west, tatami_index)): tmpRoom.place_tatami(pos, (Orientation.west, tatami_index)) self.calculate_layout(self.next_position(pos, tmpRoom), tatami_index + 1, tmpRoom, half_used) tmpRoom.remove_tatami(pos) #try vertical: if tmpRoom.can_place_tatami(pos, (Orientation.south, tatami_index)): tmpRoom.place_tatami(pos, (Orientation.south, tatami_index)) self.calculate_layout(self.next_position(pos, tmpRoom), tatami_index + 1, tmpRoom, half_used) tmpRoom.remove_tatami(pos) #try half: if not half_used and tmpRoom.can_place_tatami( pos, (Orientation.half, tatami_index)): half_used = True tmpRoom.place_tatami(pos, (Orientation.half, tatami_index)) self.calculate_layout(self.next_position(pos, tmpRoom), tatami_index + 1, tmpRoom, half_used) tmpRoom.remove_tatami(pos) half_used = False