├── AI_final_project.sln
├── AI_final_project
├── AI_final_project.cpp
├── AI_final_project.vcxproj
├── AI_final_project.vcxproj.filters
├── AI_final_project.vcxproj.user
└── Debug
│ ├── AI_final_project.log
│ ├── AI_final_project.obj
│ ├── AI_final_project.tlog
│ ├── AI_final_project.lastbuildstate
│ ├── CL.command.1.tlog
│ ├── CL.read.1.tlog
│ ├── CL.write.1.tlog
│ ├── link.command.1.tlog
│ ├── link.read.1.tlog
│ └── link.write.1.tlog
│ ├── vc142.idb
│ └── vc142.pdb
├── Báo_cáo_AI.docx
├── Debug
├── AI_final_project.exe
├── AI_final_project.ilk
└── AI_final_project.pdb
└── README.md
/AI_final_project.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29905.134
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AI_final_project", "AI_final_project\AI_final_project.vcxproj", "{DD435951-0F66-44C7-83DD-26BF8A305E2E}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {DD435951-0F66-44C7-83DD-26BF8A305E2E}.Debug|x64.ActiveCfg = Debug|x64
17 | {DD435951-0F66-44C7-83DD-26BF8A305E2E}.Debug|x64.Build.0 = Debug|x64
18 | {DD435951-0F66-44C7-83DD-26BF8A305E2E}.Debug|x86.ActiveCfg = Debug|Win32
19 | {DD435951-0F66-44C7-83DD-26BF8A305E2E}.Debug|x86.Build.0 = Debug|Win32
20 | {DD435951-0F66-44C7-83DD-26BF8A305E2E}.Release|x64.ActiveCfg = Release|x64
21 | {DD435951-0F66-44C7-83DD-26BF8A305E2E}.Release|x64.Build.0 = Release|x64
22 | {DD435951-0F66-44C7-83DD-26BF8A305E2E}.Release|x86.ActiveCfg = Release|Win32
23 | {DD435951-0F66-44C7-83DD-26BF8A305E2E}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {38AFC7C8-1287-42E7-AFC3-3FA7DDBD26F3}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/AI_final_project/AI_final_project.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambiengcode/8puzzle-bfs-dfs-cpp/cc9f5fb502ccb0071a8f53308ccf35d5618b157f/AI_final_project/AI_final_project.cpp
--------------------------------------------------------------------------------
/AI_final_project/AI_final_project.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | 16.0
23 | {DD435951-0F66-44C7-83DD-26BF8A305E2E}
24 | Win32Proj
25 | AIfinalproject
26 | 10.0
27 |
28 |
29 |
30 | Application
31 | true
32 | v142
33 | Unicode
34 |
35 |
36 | Application
37 | false
38 | v142
39 | true
40 | Unicode
41 |
42 |
43 | Application
44 | true
45 | v142
46 | Unicode
47 |
48 |
49 | Application
50 | false
51 | v142
52 | true
53 | Unicode
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | true
75 |
76 |
77 | true
78 |
79 |
80 | false
81 |
82 |
83 | false
84 |
85 |
86 |
87 |
88 |
89 | Level3
90 | true
91 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
92 | true
93 |
94 |
95 | Console
96 | true
97 |
98 |
99 |
100 |
101 |
102 |
103 | Level3
104 | true
105 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
106 | true
107 |
108 |
109 | Console
110 | true
111 |
112 |
113 |
114 |
115 |
116 |
117 | Level3
118 | true
119 | true
120 | true
121 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
122 | true
123 |
124 |
125 | Console
126 | true
127 | true
128 | true
129 |
130 |
131 |
132 |
133 |
134 |
135 | Level3
136 | true
137 | true
138 | true
139 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
140 | true
141 |
142 |
143 | Console
144 | true
145 | true
146 | true
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
--------------------------------------------------------------------------------
/AI_final_project/AI_final_project.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/AI_final_project/AI_final_project.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/AI_final_project/Debug/AI_final_project.log:
--------------------------------------------------------------------------------
1 | AI_final_project.cpp
2 | E:\proj\AI_final_project\AI_final_project\AI_final_project.cpp(177,20): warning C4018: '<': signed/unsigned mismatch
3 | E:\proj\AI_final_project\AI_final_project\AI_final_project.cpp(780,7): warning C4101: 'x': unreferenced local variable
4 | E:\proj\AI_final_project\AI_final_project\AI_final_project.cpp(867,13): warning C4244: 'argument': conversion from 'time_t' to 'unsigned int', possible loss of data
5 | E:\proj\AI_final_project\AI_final_project\AI_final_project.cpp(185): warning C4715: 'find0ofpath': not all control paths return a value
6 | E:\proj\AI_final_project\AI_final_project\AI_final_project.cpp(375): warning C4715: 'findPos0': not all control paths return a value
7 | E:\proj\AI_final_project\AI_final_project\AI_final_project.cpp(536): warning C4715: 'reverseAction': not all control paths return a value
8 | AI_final_project.vcxproj -> E:\proj\AI_final_project\Debug\AI_final_project.exe
9 |
--------------------------------------------------------------------------------
/AI_final_project/Debug/AI_final_project.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambiengcode/8puzzle-bfs-dfs-cpp/cc9f5fb502ccb0071a8f53308ccf35d5618b157f/AI_final_project/Debug/AI_final_project.obj
--------------------------------------------------------------------------------
/AI_final_project/Debug/AI_final_project.tlog/AI_final_project.lastbuildstate:
--------------------------------------------------------------------------------
1 | #TargetFrameworkVersion=v4.0:PlatformToolSet=v142:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0
2 | Debug|Win32|E:\proj\AI_final_project\|
3 |
--------------------------------------------------------------------------------
/AI_final_project/Debug/AI_final_project.tlog/CL.command.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambiengcode/8puzzle-bfs-dfs-cpp/cc9f5fb502ccb0071a8f53308ccf35d5618b157f/AI_final_project/Debug/AI_final_project.tlog/CL.command.1.tlog
--------------------------------------------------------------------------------
/AI_final_project/Debug/AI_final_project.tlog/CL.read.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambiengcode/8puzzle-bfs-dfs-cpp/cc9f5fb502ccb0071a8f53308ccf35d5618b157f/AI_final_project/Debug/AI_final_project.tlog/CL.read.1.tlog
--------------------------------------------------------------------------------
/AI_final_project/Debug/AI_final_project.tlog/CL.write.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambiengcode/8puzzle-bfs-dfs-cpp/cc9f5fb502ccb0071a8f53308ccf35d5618b157f/AI_final_project/Debug/AI_final_project.tlog/CL.write.1.tlog
--------------------------------------------------------------------------------
/AI_final_project/Debug/AI_final_project.tlog/link.command.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambiengcode/8puzzle-bfs-dfs-cpp/cc9f5fb502ccb0071a8f53308ccf35d5618b157f/AI_final_project/Debug/AI_final_project.tlog/link.command.1.tlog
--------------------------------------------------------------------------------
/AI_final_project/Debug/AI_final_project.tlog/link.read.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambiengcode/8puzzle-bfs-dfs-cpp/cc9f5fb502ccb0071a8f53308ccf35d5618b157f/AI_final_project/Debug/AI_final_project.tlog/link.read.1.tlog
--------------------------------------------------------------------------------
/AI_final_project/Debug/AI_final_project.tlog/link.write.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambiengcode/8puzzle-bfs-dfs-cpp/cc9f5fb502ccb0071a8f53308ccf35d5618b157f/AI_final_project/Debug/AI_final_project.tlog/link.write.1.tlog
--------------------------------------------------------------------------------
/AI_final_project/Debug/vc142.idb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambiengcode/8puzzle-bfs-dfs-cpp/cc9f5fb502ccb0071a8f53308ccf35d5618b157f/AI_final_project/Debug/vc142.idb
--------------------------------------------------------------------------------
/AI_final_project/Debug/vc142.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambiengcode/8puzzle-bfs-dfs-cpp/cc9f5fb502ccb0071a8f53308ccf35d5618b157f/AI_final_project/Debug/vc142.pdb
--------------------------------------------------------------------------------
/Báo_cáo_AI.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambiengcode/8puzzle-bfs-dfs-cpp/cc9f5fb502ccb0071a8f53308ccf35d5618b157f/Báo_cáo_AI.docx
--------------------------------------------------------------------------------
/Debug/AI_final_project.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambiengcode/8puzzle-bfs-dfs-cpp/cc9f5fb502ccb0071a8f53308ccf35d5618b157f/Debug/AI_final_project.exe
--------------------------------------------------------------------------------
/Debug/AI_final_project.ilk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambiengcode/8puzzle-bfs-dfs-cpp/cc9f5fb502ccb0071a8f53308ccf35d5618b157f/Debug/AI_final_project.ilk
--------------------------------------------------------------------------------
/Debug/AI_final_project.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambiengcode/8puzzle-bfs-dfs-cpp/cc9f5fb502ccb0071a8f53308ccf35d5618b157f/Debug/AI_final_project.pdb
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Solving 8 Puzzle Problem using BFS and DFS
2 |
3 | This project is a C++ implementation of solving the classic 8 puzzle problem using Breadth-First Search (BFS) and Depth-First Search (DFS) algorithms.
4 |
5 | ## Introduction
6 |
7 | The 8-puzzle problem is a well-known problem in the field of artificial intelligence that requires finding a sequence of moves that transform a scrambled 3x3 grid of numbered tiles into the correct order. The objective is to find the shortest sequence of moves that solves the puzzle.
8 |
9 | In this project, we implemented two search algorithms - BFS and DFS - to solve the 8-puzzle problem. The BFS algorithm searches the state space by exploring all the neighboring nodes first before moving to the next level, while the DFS algorithm explores as far as possible along each branch before backtracking.
10 |
11 | ## Implementation
12 |
13 | This project is implemented in C++, and the `AI_final_project.cpp` file contains the main code for solving the 8-puzzle problem. The Node class represents a node in the search tree, and the Puzzle class contains the logic for generating the initial state of the puzzle, as well as the functions for checking the goal state and generating the successor nodes.
14 |
15 | The BFS and DFS algorithms are implemented in the `AI_final_project.cpp` files, respectively. Both algorithms take a starting state of the puzzle as input and return a sequence of moves that solves the puzzle.
16 |
17 | ## Usage
18 |
19 | To run the program, simply execute the `AI_final_project.cpp` file in your C++ environment:
20 |
21 | ```bash
22 | g++ AI_final_project.cpp -o puzzle
23 | ./puzzle
24 | ```
25 | The program will generate a random initial state of the puzzle and print out the sequence of moves to solve it using both BFS and DFS algorithms. The output will show the number of moves taken and the time taken to solve the puzzle.
26 |
27 | ## Conclusion
28 |
29 | In conclusion, this project demonstrates how BFS and DFS algorithms can be used to solve the classic 8-puzzle problem in C++. The solution involves generating a search tree to explore the state space, and using these algorithms to search the tree for the shortest path to the goal state.
30 |
--------------------------------------------------------------------------------