https://vidkidz.tistory.com/2452 https://vidkidz.tistory.com/2452
아케인 시즌 1-밀러의 사유지 에피소드 3(Arcane:Online Mystery Serial-The Miller Estate Episode 3)국내에서는 탐정 아ー캉이라고도 불리며, 정식 명칭은 아케인-온라인 미스터리 연속 드라마(Arcane-Online Mystery Serial)의 첫 챕터 밀러의 사유지(The Miller Estate)의 에피소드 3편에서 SARBAKAN과 워너 브러더스가 함께 제작한 미스터리 공포 장르의 플래시 게임입니다조작 방법 마우스 작성자정보 작성자SARBAKAN워너 브러더스 출처 vidkidz.tistory.com아 케인 시즌 1-밀러의 사유지 에피소드 3(Arcane:Online Mystery Serial-The Miller Estate Episode 3)국내에서는 탐정 아ー캉이라고도 불리며, 정식 명칭은 아케인-온라인 미스터리 연속 드라마(Arcane-Online Mystery Serial)의 첫 챕터 밀러의 사유지(The Miller Estate)의 에피소드 3편에서 SARBAKAN과 워너 브러더스가 함께 제작한 미스터리 공포 장르의 플래시 게임입니다조작 방법 마우스 작성자정보 작성자SARBAKAN워너 브러더스 출처 vidkidz.tistory.com

해당 플래시 게임 초반에 스토리북을 읽으려면 퍼즐을 풀어야 한다. 해당 플래시 게임 초반에 스토리북을 읽으려면 퍼즐을 풀어야 한다.
퍼즐의 룰은 다음과 같다.가운데”ㅗ”자형의 막대기를 돌릴 수 있고 클릭하면 해당 막대가 있는 부분의 홈(악마의 앞니와 같은 형태)이 들어간다.목표는 8방향 모두 홈을 넣기.알고리즘에서 풀리지 않을까 도전했다.문제를 컴퓨터로 녹듯 바꾸면 다음과 같다.8개의 골의 상태를 각 0과 1에 둔다.들어 있으면 0, 나오고 있으면 1로 설정한다.12시 방향부터 시계 방향으로 각 홈을 0~7번에 설정한다.이를 리스트로 표현하면,[1,1,1,1,1,1,1,1]이며, 이 명단은 cyclic form이다.막대기 state도 모두 8개 있고 각 막대가 있는 위치를 표현하면[0,2,4],[1,3,5],…,[7,1,3]represent이다.그리고 버튼을 누르면, 그 틈은 0부터 1에, 혹은 1에서 0으로 바뀌어서 1-‘current_state’이다.BFS알고리즘에서 이를 풀것이다.설명은 다음에 나온다.https://en.wikipedia.org/wiki/Breadth-first_search퍼즐의 룰은 다음과 같다.가운데”ㅗ”자형의 막대기를 돌릴 수 있고 클릭하면 해당 막대가 있는 부분의 홈(악마의 앞니와 같은 형태)이 들어간다.목표는 8방향 모두 홈을 넣기.알고리즘에서 풀리지 않을까 도전했다.문제를 컴퓨터로 녹듯 바꾸면 다음과 같다.8개의 골의 상태를 각 0과 1에 둔다.들어 있으면 0, 나오고 있으면 1로 설정한다.12시 방향부터 시계 방향으로 각 홈을 0~7번에 설정한다.이를 리스트로 표현하면,[1,1,1,1,1,1,1,1]이며, 이 명단은 cyclic form이다.막대기 state도 모두 8개 있고 각 막대가 있는 위치를 표현하면[0,2,4],[1,3,5],…,[7,1,3]represent이다.그리고 버튼을 누르면, 그 틈은 0부터 1에, 혹은 1에서 0으로 바뀌어서 1-‘current_state’이다.BFS알고리즘에서 이를 풀것이다.설명은 다음에 나온다.https://en.wikipedia.org/wiki/Breadth-first_search

Breadth-first search – WikipediaThis article needs additional citations for verification . Please help improve this article by adding citations to reliable sources . Unsourced material may be challenged and removed. Find sources: “Breadth-first search” – news · newspapers · books · scholar · JSTOR ( April 2012 ) ( Learn how and …en.wikipedia。org Breadth-first search – WikipediaThis article needs additional citations for verification . Please help improve this article by adding citations to reliable sources . Unsourced material may be challenged and removed. Find sources: “Breadth-first search” – news · newspapers · books · scholar · JSTOR ( April 2012 ) ( Learn how and …en.wikipedia。org
이는 설명이 거창하지 않고 첫 state부터 시작해 가능한 모든 경우의 수를 tree 식으로 일일이 계산해 가장 빨리 나오는 솔루션을 채택하는 방식이다. 이것을 python 코드로 대체하면 다음과 같다. 이는 설명이 거창하지 않고 첫 state부터 시작해 가능한 모든 경우의 수를 tree 식으로 일일이 계산해 가장 빨리 나오는 솔루션을 채택하는 방식이다. 이것을 python 코드로 대체하면 다음과 같다.

from collections import deque#3개씩 모아서 누르고 변경할 수 있는 위치들 moves=[[0,2,4]#1,3,5번[1,3,5]#2,4,6번[2,4,6]#3,5,7번[3,5,7]#4,6,8번[4,6,0]#5,7,1번[5,7,1]#6,8,2번[6,0,2]#7,1,3번[7,1,3]#8,2,4번]#상태를 문자열로 변환하고 출력 def print_state(state):return”. join(map(str, state)#BFS알고리즘 def bfs(start_state):target_state=[0,0,0,0,0,0,0,0]queue=deque([(start_state[])])#(현재 상태,경로)visited=set()#방문한 상태를 기록하기 때문에, 사용 visited.add(tuple(start_state)while queue:current_state, path=queue.popleft()#목표 상태에 도달한 경우 if current_state==target_state:return path#각 가능한 이동에 대해서 탐색 for move in moves:new_state=current_state[:]for idx in move:new_state[idx]=1-new_state[idx]#0과 1을 뒤집어 new_state_tuple=tuple(new_state)if new_state_tuple not in visited:visited.add(new_state_tuple)queue.append(new_state, path+[move])#경로로 이동 추가 return None#목표 상태에 도달하지 못할 경우#초기 상태 start_state=[1,1,1,1,1,1,1,1]#최단 경로를 찾아 solution=bfs(start_state)if solution:print(“최단 경로:”)for move in solution:print(f” 누를 위치:{move}”)else:print(“해결할 수 없습니다.”)from collections import deque#3개씩 모아서 누르고 변경할 수 있는 위치들 moves=[[0,2,4]#1,3,5번[1,3,5]#2,4,6번[2,4,6]#3,5,7번[3,5,7]#4,6,8번[4,6,0]#5,7,1번[5,7,1]#6,8,2번[6,0,2]#7,1,3번[7,1,3]#8,2,4번]#상태를 문자열로 변환하고 출력 def print_state(state):return”. join(map(str, state)#BFS알고리즘 def bfs(start_state):target_state=[0,0,0,0,0,0,0,0]queue=deque([(start_state,[])])#(현재 상태, 경로)visited=set()#방문한 상태를 기록하기 때문에, 사용 visited.add(tuple(start_state)while queue:current_state, path=queue.popleft()#목표 상태에 도달한 경우 if current_state==target_state:return path#각 가능한 이동에 대해서 탐색 for move in moves:new_state=current_state[:]for idx in move:new_state[idx]=1-new_state[idx]#0과 1을 뒤집어 new_state_tuple=tuple(new_state)if new_state_tuple not in visited:visited.add(new_state_tuple)queue.append(new_state, path+[move])#경로로 이동 추가 return None#목표 상태에 도달하지 못할 경우#초기 상태 start_state=[1,1,1,1,1,1,1,1]#최단 경로를 찾아 solution=bfs(start_state)if solution:print(“최단 경로:”)for move in solution:print(f” 누를 위치:{move}”)else:print(“해결할 수 없습니다.”)
재미있게도, 이 알고리즘의 해답은 다음과 같이 나온다. 재미있게도, 이 알고리즘의 해답은 다음과 같이 나온다.

최단 경로 : [0, 2, 4] 눌러야 할 위치: [1, 3, 5] 눌러야 할 위치: [2, 4, 6] 눌러야 할 위치: [3, 5, 7] 눌러야 할 위치: [4,6,0] 눌러야 할 위치: [5,7,1] 눌러야 할 위치: [6,0,2] 눌러야 할 위치: [7,1,3] 최단 경로 : [0, 2, 4] 눌러야 할 위치: [1, 3, 5] 눌러야 할 위치: [2, 4, 6] 눌러야 할 위치: [3, 5, 7] 눌러야 할 위치: [4,6,0] 눌러야 할 위치: [5,7,1] 눌러야 할 위치: [6,0,2] 눌러야 할 위치: [7,1,3]
즉, 그냥 처음부터 한 번씩 이동하면서 클릭하면 퍼즐이 풀린다. #아케인 #플래시 게임 #알고리즘 즉, 그냥 처음부터 한 번씩 이동하면서 클릭하면 퍼즐이 풀린다. #아케인 #플래시 게임 #알고리즘