Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AI Progamming Exercises
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michael Mutote
AI Progamming Exercises
Commits
bd5691ee
Commit
bd5691ee
authored
1 year ago
by
Michael Mutote
Browse files
Options
Downloads
Patches
Plain Diff
22202956
refactored
parent
e1a7a4a5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Search_Algorithms/Search_Algorithms.py
+1
-1
1 addition, 1 deletion
Search_Algorithms/Search_Algorithms.py
Search_Algorithms/solution testing.py
+20
-16
20 additions, 16 deletions
Search_Algorithms/solution testing.py
with
21 additions
and
17 deletions
Search_Algorithms/Search_Algorithms.py
+
1
−
1
View file @
bd5691ee
...
...
@@ -25,7 +25,7 @@ def DepthFirstSearch(state, successor, isgoal):
toDo
=
deque
()
toDo
.
append
([
state
])
explored
=
{
state
}
while
not
toDo
:
while
toDo
:
path
=
toDo
.
pop
()
current
=
path
[
-
1
]
if
isgoal
(
current
):
...
...
This diff is collapsed.
Click to expand it.
Search_Algorithms/solution testing.py
+
20
−
16
View file @
bd5691ee
...
...
@@ -4,20 +4,22 @@ import is_goal
# Maze Problem, note, the maze if fixed in the allowed state.
print
(
breadth_first_search
.
BreadthFirstSearch
((
4
,
0
),
Sucessors
.
maze_successor
,
is_goal
.
is_goal_maze
))
#
print(
Search_Algorithms
.BreadthFirstSearch((4, 0), Sucessors.maze_successor, is_goal.is_goal_maze))
# Sudoku
grid
=
((
5
,
3
,
0
,
0
,
7
,
0
,
0
,
0
,
0
),
(
6
,
0
,
0
,
1
,
9
,
5
,
0
,
0
,
0
),
(
0
,
9
,
8
,
0
,
0
,
0
,
0
,
6
,
0
),
(
8
,
0
,
0
,
0
,
6
,
0
,
0
,
0
,
3
),
(
4
,
0
,
0
,
8
,
0
,
3
,
0
,
0
,
1
),
(
7
,
0
,
0
,
0
,
2
,
0
,
0
,
0
,
6
),
(
0
,
6
,
0
,
0
,
0
,
0
,
2
,
8
,
0
),
(
0
,
0
,
0
,
4
,
1
,
9
,
0
,
0
,
5
),
grid
=
((
1
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
),
(
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
),
(
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
),
(
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
),
(
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
),
(
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
),
(
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
),
(
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
),
(
0
,
0
,
0
,
0
,
8
,
0
,
0
,
0
,
0
))
sln
=
(
breadth_first_search
.
BreadthFirstSearch
(
grid
,
Sucessors
.
sudoku_successor
,
is_goal
.
is_goal_sudoku
)[
-
1
])
# sln = (Search_Algorithms.BreadthFirstSearch(grid, Sucessors.sudoku_successor, is_goal.is_goal_sudoku)[-1])
sln
=
(
Search_Algorithms
.
DepthFirstSearch
(
grid
,
Sucessors
.
sudoku_successor
,
is_goal
.
is_goal_sudoku
)[
-
1
])
for
rows
in
sln
:
print
(
rows
)
...
...
@@ -34,14 +36,16 @@ board = ((False, False, False, False, False, False, False, False, False),
(
False
,
False
,
False
,
False
,
False
,
False
,
False
,
False
,
False
))
sln
=
(
breadth_first_search
.
BreadthFirstSearch
(
board
,
Sucessors
.
queens_successor
,
is_goal
.
is_goal_queens
)[
-
1
])
# sln = (Search_Algorithms.BreadthFirstSearch(board, Sucessors.queens_successor, is_goal.is_goal_queens)[-1])
sln
=
(
Search_Algorithms
.
DepthFirstSearch
(
board
,
Sucessors
.
queens_successor
,
is_goal
.
is_goal_queens
)[
-
1
])
output_tuple
=
tuple
(
tuple
(
"
Q
"
if
value
else
"
.
"
for
value
in
sln
)
for
sln
in
sln
)
for
rows
in
output_tuple
:
print
(
rows
)
puzzle
=
()
print
(
breadth_first_search
.
BreadthFirstSearch
(
puzzle
,
Sucessors
.
puzzle_successor
,
is_goal
.
is_goal_puzzle
)[
-
1
])
#
#
puzzle = ()
#
#
#
print(
Search_Algorithms
.BreadthFirstSearch(puzzle, Sucessors.puzzle_successor, is_goal.is_goal_puzzle)[-1])
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment