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
7aecb9a2
Commit
7aecb9a2
authored
1 year ago
by
Michael Mutote
Browse files
Options
Downloads
Patches
Plain Diff
22211572
parent
f5140860
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
-0
1 addition, 0 deletions
Search_Algorithms/Search_Algorithms.py
Search_Algorithms/solution testing.py
+23
-14
23 additions, 14 deletions
Search_Algorithms/solution testing.py
with
24 additions
and
14 deletions
Search_Algorithms/Search_Algorithms.py
+
1
−
0
View file @
7aecb9a2
...
...
@@ -34,6 +34,7 @@ def DepthFirstSearch(state, successor, isgoal):
if
next_state
not
in
explored
:
explored
.
add
(
next_state
)
path2
=
path
+
[
next_state
]
print
(
path2
)
toDo
.
append
(
path2
)
return
"
Error Path not found
"
This diff is collapsed.
Click to expand it.
Search_Algorithms/solution testing.py
+
23
−
14
View file @
7aecb9a2
...
...
@@ -19,11 +19,11 @@ grid = ((1, 0, 0, 0, 0, 0, 0, 0, 0),
# 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
)
#
sln = (Search_Algorithms.DepthFirstSearch(
#
grid, Sucessors.sudoku_successor, is_goal.is_goal_sudoku)[-1])
#
#
for rows in sln:
#
print(rows)
# N Queens
board
=
((
False
,
False
,
False
,
False
,
False
,
False
,
False
,
False
,
False
),
...
...
@@ -38,14 +38,14 @@ board = ((False, False, False, False, False, False, False, False, False),
# 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
)
#
#
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)
# Sliding Puzzle
...
...
@@ -55,8 +55,17 @@ initial_puzzle = (
(
5
,
0
,
6
),
(
8
,
3
,
1
)
)
#
# sln = (Search_Algorithms.BreadthFirstSearch(initial_puzzle, Sucessors.puzzle_successor, is_goal.is_goal_puzzle)[-1])
#
# if sln:
# for rows in sln:
# print(rows)
# else:
# print("No solution found")
sln
=
(
Search_Algorithms
.
Bread
thFirstSearch
(
initial_puzzle
,
Sucessors
.
puzzle_successor
,
is_goal
.
is_goal_puzzle
)[
-
1
])
sln
=
(
Search_Algorithms
.
Dep
thFirstSearch
(
initial_puzzle
,
Sucessors
.
puzzle_successor
,
is_goal
.
is_goal_puzzle
)[
-
1
])
if
sln
:
for
rows
in
sln
:
...
...
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