Skip to content

Commit f2337df

Browse files
committed
commit inicial
1 parent 3246ae2 commit f2337df

File tree

133 files changed

+1798
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+1798
-0
lines changed

test_cases/CONFIG

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
order: "q1 q2 q3 q4 q5 q6 q7 q8"

test_cases/q1/CONFIG

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
max_points: "3"
2+
class: "PassAllTestsQuestion"
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This is the solution file for test_cases/q1/graph_backtrack.test.
2+
# This solution is designed to support both right-to-left
3+
# and left-to-right implementations.
4+
solution: "1:A->C 0:C->G"
5+
expanded_states: "A D C"
6+
rev_solution: "1:A->C 0:C->G"
7+
rev_expanded_states: "A B C"

test_cases/q1/graph_backtrack.test

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
class: "GraphSearchTest"
2+
algorithm: "depthFirstSearch"
3+
4+
diagram: """
5+
B
6+
^
7+
|
8+
*A --> C --> G
9+
|
10+
V
11+
D
12+
13+
A is the start state, G is the goal. Arrows mark
14+
possible state transitions. This tests whether
15+
you extract the sequence of actions correctly even
16+
if your search backtracks. If you fail this, your
17+
nodes are not correctly tracking the sequences of
18+
actions required to reach them.
19+
"""
20+
# The following section specifies the search problem and the solution.
21+
# The graph is specified by first the set of start states, followed by
22+
# the set of goal states, and lastly by the state transitions which are
23+
# of the form:
24+
# <start state> <actions> <end state> <cost>
25+
graph: """
26+
start_state: A
27+
goal_states: G
28+
A 0:A->B B 1.0
29+
A 1:A->C C 2.0
30+
A 2:A->D D 4.0
31+
C 0:C->G G 8.0
32+
"""
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This is the solution file for test_cases/q1/graph_bfs_vs_dfs.test.
2+
# This solution is designed to support both right-to-left
3+
# and left-to-right implementations.
4+
solution: "2:A->D 0:D->G"
5+
expanded_states: "A D"
6+
rev_solution: "0:A->B 0:B->D 0:D->G"
7+
rev_expanded_states: "A B D"

test_cases/q1/graph_bfs_vs_dfs.test

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Graph where BFS finds the optimal solution but DFS does not
2+
class: "GraphSearchTest"
3+
algorithm: "depthFirstSearch"
4+
5+
diagram: """
6+
/-- B
7+
| ^
8+
| |
9+
| *A -->[G]
10+
| | ^
11+
| V |
12+
\-->D ----/
13+
14+
A is the start state, G is the goal. Arrows
15+
mark possible transitions
16+
"""
17+
# The following section specifies the search problem and the solution.
18+
# The graph is specified by first the set of start states, followed by
19+
# the set of goal states, and lastly by the state transitions which are
20+
# of the form:
21+
# <start state> <actions> <end state> <cost>
22+
graph: """
23+
start_state: A
24+
goal_states: G
25+
A 0:A->B B 1.0
26+
A 1:A->G G 2.0
27+
A 2:A->D D 4.0
28+
B 0:B->D D 8.0
29+
D 0:D->G G 16.0
30+
"""

test_cases/q1/graph_infinite.solution

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This is the solution file for test_cases/q1/graph_infinite.test.
2+
# This solution is designed to support both right-to-left
3+
# and left-to-right implementations.
4+
solution: "0:A->B 1:B->C 1:C->G"
5+
expanded_states: "A B C"
6+
rev_solution: "0:A->B 1:B->C 1:C->G"
7+
rev_expanded_states: "A B C"

test_cases/q1/graph_infinite.test

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Graph where natural action choice leads to an infinite loop
2+
class: "GraphSearchTest"
3+
algorithm: "depthFirstSearch"
4+
5+
diagram: """
6+
B <--> C
7+
^ /|
8+
| / |
9+
V / V
10+
*A<-/ [G]
11+
12+
A is the start state, G is the goal. Arrows mark
13+
possible state transitions.
14+
"""
15+
# The following section specifies the search problem and the solution.
16+
# The graph is specified by first the set of start states, followed by
17+
# the set of goal states, and lastly by the state transitions which are
18+
# of the form:
19+
# <start state> <actions> <end state> <cost>
20+
graph: """
21+
start_state: A
22+
goal_states: G
23+
A 0:A->B B 1.0
24+
B 0:B->A A 2.0
25+
B 1:B->C C 4.0
26+
C 0:C->A A 8.0
27+
C 1:C->G G 16.0
28+
C 2:C->B B 32.0
29+
"""
30+
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This is the solution file for test_cases/q1/graph_manypaths.test.
2+
# This solution is designed to support both right-to-left
3+
# and left-to-right implementations.
4+
solution: "2:A->B2 0:B2->C 0:C->D 2:D->E2 0:E2->F 0:F->G"
5+
expanded_states: "A B2 C D E2 F"
6+
rev_solution: "0:A->B1 0:B1->C 0:C->D 0:D->E1 0:E1->F 0:F->G"
7+
rev_expanded_states: "A B1 C D E1 F"

test_cases/q1/graph_manypaths.test

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
class: "GraphSearchTest"
2+
algorithm: "depthFirstSearch"
3+
4+
diagram: """
5+
B1 E1
6+
^ \ ^ \
7+
/ V / V
8+
*A --> C --> D --> F --> [G]
9+
\ ^ \ ^
10+
V / V /
11+
B2 E2
12+
13+
A is the start state, G is the goal. Arrows mark
14+
possible state transitions. This graph has multiple
15+
paths to the goal, where nodes with the same state
16+
are added to the fringe multiple times before they
17+
are expanded.
18+
"""
19+
# The following section specifies the search problem and the solution.
20+
# The graph is specified by first the set of start states, followed by
21+
# the set of goal states, and lastly by the state transitions which are
22+
# of the form:
23+
# <start state> <actions> <end state> <cost>
24+
graph: """
25+
start_state: A
26+
goal_states: G
27+
A 0:A->B1 B1 1.0
28+
A 1:A->C C 2.0
29+
A 2:A->B2 B2 4.0
30+
B1 0:B1->C C 8.0
31+
B2 0:B2->C C 16.0
32+
C 0:C->D D 32.0
33+
D 0:D->E1 E1 64.0
34+
D 1:D->F F 128.0
35+
D 2:D->E2 E2 256.0
36+
E1 0:E1->F F 512.0
37+
E2 0:E2->F F 1024.0
38+
F 0:F->G G 2048.0
39+
"""

test_cases/q1/pacman_1.solution

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# This is the solution file for test_cases/q1/pacman_1.test.
2+
# This solution is designed to support both right-to-left
3+
# and left-to-right implementations.
4+
# Number of nodes expanded must be with a factor of 1.0 of the numbers below.
5+
solution: """
6+
West West West West West West West West West West West West West West
7+
West West West West West West West West West West West West West West
8+
West West West West West South South South South South South South
9+
South South East East East North North North North North North North
10+
East East South South South South South South East East North North
11+
North North North North East East South South South South East East
12+
North North East East East East East East East East South South South
13+
East East East East East East East South South South South South South
14+
South West West West West West West West West West West West West West
15+
West West West West South West West West West West West West West West
16+
"""
17+
expanded_nodes: "146"
18+
rev_solution: """
19+
South South West West West West South South East East East East South
20+
South West West West West South South East East East East South South
21+
West West West West South South South East North East East East South
22+
South South West West West West West West West North North North North
23+
North North North North West West West West West West West North North
24+
North East East East East South East East East North North North West
25+
West North North West West West West West West West West West West
26+
West West West West West West West West West West West West West West
27+
South South South South South South South South South East East East
28+
North North North North North North North East East South South South
29+
South South South East East North North North North North North East
30+
East South South South South East East North North North North East
31+
East East East East South South West West West South South East East
32+
East South South West West West West West West South South West West
33+
West West West South West West West West West South South East East
34+
East East East East East North East East East East East North North
35+
East East East East East East North East East East East East South
36+
South West West West South West West West West West West South South
37+
West West West West West South West West West West West West West West
38+
West
39+
"""
40+
rev_expanded_nodes: "269"

test_cases/q1/pacman_1.test

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This is a basic depth first search test
2+
class: "PacmanSearchTest"
3+
algorithm: "depthFirstSearch"
4+
5+
# The following specifies the layout to be used
6+
layoutName: "mediumMaze"
7+
layout: """
8+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9+
% P%
10+
% %%%%%%%%%%%%%%%%%%%%%%% %%%%%%%% %
11+
% %% % % %%%%%%% %% %
12+
% %% % % % % %%%% %%%%%%%%% %% %%%%%
13+
% %% % % % % %% %% %
14+
% %% % % % % % %%%% %%% %%%%%% %
15+
% % % % % % %% %%%%%%%% %
16+
% %% % % %%%%%%%% %% %% %%%%%
17+
% %% % %% %%%%%%%%% %% %
18+
% %%%%%% %%%%%%% %% %%%%%% %
19+
%%%%%% % %%%% %% % %
20+
% %%%%%% %%%%% % %% %% %%%%%
21+
% %%%%%% % %%%%% %% %
22+
% %%%%%% %%%%%%%%%%% %% %% %
23+
%%%%%%%%%% %%%%%% %
24+
%. %%%%%%%%%%%%%%%% %
25+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26+
"""
27+

test_cases/q2/CONFIG

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
max_points: "3"
2+
class: "PassAllTestsQuestion"
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This is the solution file for test_cases/q2/graph_backtrack.test.
2+
# This solution is designed to support both right-to-left
3+
# and left-to-right implementations.
4+
solution: "1:A->C 0:C->G"
5+
expanded_states: "A B C D"
6+
rev_solution: "1:A->C 0:C->G"
7+
rev_expanded_states: "A D C B"

test_cases/q2/graph_backtrack.test

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
class: "GraphSearchTest"
2+
algorithm: "breadthFirstSearch"
3+
4+
diagram: """
5+
B
6+
^
7+
|
8+
*A --> C --> G
9+
|
10+
V
11+
D
12+
13+
A is the start state, G is the goal. Arrows mark
14+
possible state transitions. This tests whether
15+
you extract the sequence of actions correctly even
16+
if your search backtracks. If you fail this, your
17+
nodes are not correctly tracking the sequences of
18+
actions required to reach them.
19+
"""
20+
# The following section specifies the search problem and the solution.
21+
# The graph is specified by first the set of start states, followed by
22+
# the set of goal states, and lastly by the state transitions which are
23+
# of the form:
24+
# <start state> <actions> <end state> <cost>
25+
graph: """
26+
start_state: A
27+
goal_states: G
28+
A 0:A->B B 1.0
29+
A 1:A->C C 2.0
30+
A 2:A->D D 4.0
31+
C 0:C->G G 8.0
32+
"""
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This is the solution file for test_cases/q2/graph_bfs_vs_dfs.test.
2+
# This solution is designed to support both right-to-left
3+
# and left-to-right implementations.
4+
solution: "1:A->G"
5+
expanded_states: "A B"
6+
rev_solution: "1:A->G"
7+
rev_expanded_states: "A D"

test_cases/q2/graph_bfs_vs_dfs.test

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Graph where BFS finds the optimal solution but DFS does not
2+
class: "GraphSearchTest"
3+
algorithm: "breadthFirstSearch"
4+
5+
diagram: """
6+
/-- B
7+
| ^
8+
| |
9+
| *A -->[G]
10+
| | ^
11+
| V |
12+
\-->D ----/
13+
14+
A is the start state, G is the goal. Arrows
15+
mark possible transitions
16+
"""
17+
# The following section specifies the search problem and the solution.
18+
# The graph is specified by first the set of start states, followed by
19+
# the set of goal states, and lastly by the state transitions which are
20+
# of the form:
21+
# <start state> <actions> <end state> <cost>
22+
graph: """
23+
start_state: A
24+
goal_states: G
25+
A 0:A->B B 1.0
26+
A 1:A->G G 2.0
27+
A 2:A->D D 4.0
28+
B 0:B->D D 8.0
29+
D 0:D->G G 16.0
30+
"""

test_cases/q2/graph_infinite.solution

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This is the solution file for test_cases/q2/graph_infinite.test.
2+
# This solution is designed to support both right-to-left
3+
# and left-to-right implementations.
4+
solution: "0:A->B 1:B->C 1:C->G"
5+
expanded_states: "A B C"
6+
rev_solution: "0:A->B 1:B->C 1:C->G"
7+
rev_expanded_states: "A B C"

test_cases/q2/graph_infinite.test

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Graph where natural action choice leads to an infinite loop
2+
class: "GraphSearchTest"
3+
algorithm: "breadthFirstSearch"
4+
5+
diagram: """
6+
B <--> C
7+
^ /|
8+
| / |
9+
V / V
10+
*A<-/ [G]
11+
12+
A is the start state, G is the goal. Arrows mark
13+
possible state transitions.
14+
"""
15+
# The following section specifies the search problem and the solution.
16+
# The graph is specified by first the set of start states, followed by
17+
# the set of goal states, and lastly by the state transitions which are
18+
# of the form:
19+
# <start state> <actions> <end state> <cost>
20+
graph: """
21+
start_state: A
22+
goal_states: G
23+
A 0:A->B B 1.0
24+
B 0:B->A A 2.0
25+
B 1:B->C C 4.0
26+
C 0:C->A A 8.0
27+
C 1:C->G G 16.0
28+
C 2:C->B B 32.0
29+
"""
30+
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This is the solution file for test_cases/q2/graph_manypaths.test.
2+
# This solution is designed to support both right-to-left
3+
# and left-to-right implementations.
4+
solution: "1:A->C 0:C->D 1:D->F 0:F->G"
5+
expanded_states: "A B1 C B2 D E1 F E2"
6+
rev_solution: "1:A->C 0:C->D 1:D->F 0:F->G"
7+
rev_expanded_states: "A B2 C B1 D E2 F E1"

0 commit comments

Comments
 (0)