feat: p0 and p1

This commit is contained in:
zsq259
2024-06-23 00:05:13 +08:00
parent f105d29e25
commit 71975d5889
228 changed files with 11213 additions and 0 deletions

1
search/test_cases/CONFIG Normal file
View File

@ -0,0 +1 @@
order: "q1 q2 q3 q4 q5 q6 q7 q8"

View File

@ -0,0 +1,2 @@
max_points: "3"
class: "PassAllTestsQuestion"

View File

@ -0,0 +1,7 @@
# This is the solution file for test_cases/q1/graph_backtrack.test.
# This solution is designed to support both right-to-left
# and left-to-right implementations.
solution: "1:A->C 0:C->G"
expanded_states: "A D C"
rev_solution: "1:A->C 0:C->G"
rev_expanded_states: "A B C"

View File

@ -0,0 +1,32 @@
class: "GraphSearchTest"
algorithm: "depthFirstSearch"
diagram: """
B
^
|
*A --> C --> G
|
V
D
A is the start state, G is the goal. Arrows mark
possible state transitions. This tests whether
you extract the sequence of actions correctly even
if your search backtracks. If you fail this, your
nodes are not correctly tracking the sequences of
actions required to reach them.
"""
# The following section specifies the search problem and the solution.
# The graph is specified by first the set of start states, followed by
# the set of goal states, and lastly by the state transitions which are
# of the form:
# <start state> <actions> <end state> <cost>
graph: """
start_state: A
goal_states: G
A 0:A->B B 1.0
A 1:A->C C 2.0
A 2:A->D D 4.0
C 0:C->G G 8.0
"""

View File

@ -0,0 +1,7 @@
# This is the solution file for test_cases/q1/graph_bfs_vs_dfs.test.
# This solution is designed to support both right-to-left
# and left-to-right implementations.
solution: "2:A->D 0:D->G"
expanded_states: "A D"
rev_solution: "0:A->B 0:B->D 0:D->G"
rev_expanded_states: "A B D"

View File

@ -0,0 +1,30 @@
# Graph where BFS finds the optimal solution but DFS does not
class: "GraphSearchTest"
algorithm: "depthFirstSearch"
diagram: """
/-- B
| ^
| |
| *A -->[G]
| | ^
| V |
\-->D ----/
A is the start state, G is the goal. Arrows
mark possible transitions
"""
# The following section specifies the search problem and the solution.
# The graph is specified by first the set of start states, followed by
# the set of goal states, and lastly by the state transitions which are
# of the form:
# <start state> <actions> <end state> <cost>
graph: """
start_state: A
goal_states: G
A 0:A->B B 1.0
A 1:A->G G 2.0
A 2:A->D D 4.0
B 0:B->D D 8.0
D 0:D->G G 16.0
"""

View File

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

View File

@ -0,0 +1,30 @@
# Graph where natural action choice leads to an infinite loop
class: "GraphSearchTest"
algorithm: "depthFirstSearch"
diagram: """
B <--> C
^ /|
| / |
V / V
*A<-/ [G]
A is the start state, G is the goal. Arrows mark
possible state transitions.
"""
# The following section specifies the search problem and the solution.
# The graph is specified by first the set of start states, followed by
# the set of goal states, and lastly by the state transitions which are
# of the form:
# <start state> <actions> <end state> <cost>
graph: """
start_state: A
goal_states: G
A 0:A->B B 1.0
B 0:B->A A 2.0
B 1:B->C C 4.0
C 0:C->A A 8.0
C 1:C->G G 16.0
C 2:C->B B 32.0
"""

View File

@ -0,0 +1,7 @@
# This is the solution file for test_cases/q1/graph_manypaths.test.
# This solution is designed to support both right-to-left
# and left-to-right implementations.
solution: "2:A->B2 0:B2->C 0:C->D 2:D->E2 0:E2->F 0:F->G"
expanded_states: "A B2 C D E2 F"
rev_solution: "0:A->B1 0:B1->C 0:C->D 0:D->E1 0:E1->F 0:F->G"
rev_expanded_states: "A B1 C D E1 F"

View File

@ -0,0 +1,39 @@
class: "GraphSearchTest"
algorithm: "depthFirstSearch"
diagram: """
B1 E1
^ \ ^ \
/ V / V
*A --> C --> D --> F --> [G]
\ ^ \ ^
V / V /
B2 E2
A is the start state, G is the goal. Arrows mark
possible state transitions. This graph has multiple
paths to the goal, where nodes with the same state
are added to the fringe multiple times before they
are expanded.
"""
# The following section specifies the search problem and the solution.
# The graph is specified by first the set of start states, followed by
# the set of goal states, and lastly by the state transitions which are
# of the form:
# <start state> <actions> <end state> <cost>
graph: """
start_state: A
goal_states: G
A 0:A->B1 B1 1.0
A 1:A->C C 2.0
A 2:A->B2 B2 4.0
B1 0:B1->C C 8.0
B2 0:B2->C C 16.0
C 0:C->D D 32.0
D 0:D->E1 E1 64.0
D 1:D->F F 128.0
D 2:D->E2 E2 256.0
E1 0:E1->F F 512.0
E2 0:E2->F F 1024.0
F 0:F->G G 2048.0
"""

View File

@ -0,0 +1,40 @@
# This is the solution file for test_cases/q1/pacman_1.test.
# This solution is designed to support both right-to-left
# and left-to-right implementations.
# Number of nodes expanded must be with a factor of 1.0 of the numbers below.
solution: """
West West West West West West West West West West West West West West
West West West West West West West West West West West West West West
West West West West West South South South South South South South
South South East East East North North North North North North North
East East South South South South South South East East North North
North North North North East East South South South South East East
North North East East East East East East East East South South South
East East East East East East East South South South South South South
South West West West West West West West West West West West West West
West West West West South West West West West West West West West West
"""
expanded_nodes: "146"
rev_solution: """
South South West West West West South South East East East East South
South West West West West South South East East East East South South
West West West West South South South East North East East East South
South South West West West West West West West North North North North
North North North North West West West West West West West North North
North East East East East South East East East North North North West
West North North West West West West West West West West West West
West West West West West West West West West West West West West West
South South South South South South South South South East East East
North North North North North North North East East South South South
South South South East East North North North North North North East
East South South South South East East North North North North East
East East East East South South West West West South South East East
East South South West West West West West West South South West West
West West West South West West West West West South South East East
East East East East East North East East East East East North North
East East East East East East North East East East East East South
South West West West South West West West West West West South South
West West West West West South West West West West West West West West
West
"""
rev_expanded_nodes: "269"

View File

@ -0,0 +1,27 @@
# This is a basic depth first search test
class: "PacmanSearchTest"
algorithm: "depthFirstSearch"
# The following specifies the layout to be used
layoutName: "mediumMaze"
layout: """
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% P%
% %%%%%%%%%%%%%%%%%%%%%%% %%%%%%%% %
% %% % % %%%%%%% %% %
% %% % % % % %%%% %%%%%%%%% %% %%%%%
% %% % % % % %% %% %
% %% % % % % % %%%% %%% %%%%%% %
% % % % % % %% %%%%%%%% %
% %% % % %%%%%%%% %% %% %%%%%
% %% % %% %%%%%%%%% %% %
% %%%%%% %%%%%%% %% %%%%%% %
%%%%%% % %%%% %% % %
% %%%%%% %%%%% % %% %% %%%%%
% %%%%%% % %%%%% %% %
% %%%%%% %%%%%%%%%%% %% %% %
%%%%%%%%%% %%%%%% %
%. %%%%%%%%%%%%%%%% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"""

View File

@ -0,0 +1,2 @@
max_points: "3"
class: "PassAllTestsQuestion"

View File

@ -0,0 +1,7 @@
# This is the solution file for test_cases/q2/graph_backtrack.test.
# This solution is designed to support both right-to-left
# and left-to-right implementations.
solution: "1:A->C 0:C->G"
expanded_states: "A B C D"
rev_solution: "1:A->C 0:C->G"
rev_expanded_states: "A D C B"

View File

@ -0,0 +1,32 @@
class: "GraphSearchTest"
algorithm: "breadthFirstSearch"
diagram: """
B
^
|
*A --> C --> G
|
V
D
A is the start state, G is the goal. Arrows mark
possible state transitions. This tests whether
you extract the sequence of actions correctly even
if your search backtracks. If you fail this, your
nodes are not correctly tracking the sequences of
actions required to reach them.
"""
# The following section specifies the search problem and the solution.
# The graph is specified by first the set of start states, followed by
# the set of goal states, and lastly by the state transitions which are
# of the form:
# <start state> <actions> <end state> <cost>
graph: """
start_state: A
goal_states: G
A 0:A->B B 1.0
A 1:A->C C 2.0
A 2:A->D D 4.0
C 0:C->G G 8.0
"""

View File

@ -0,0 +1,7 @@
# This is the solution file for test_cases/q2/graph_bfs_vs_dfs.test.
# This solution is designed to support both right-to-left
# and left-to-right implementations.
solution: "1:A->G"
expanded_states: "A B"
rev_solution: "1:A->G"
rev_expanded_states: "A D"

View File

@ -0,0 +1,30 @@
# Graph where BFS finds the optimal solution but DFS does not
class: "GraphSearchTest"
algorithm: "breadthFirstSearch"
diagram: """
/-- B
| ^
| |
| *A -->[G]
| | ^
| V |
\-->D ----/
A is the start state, G is the goal. Arrows
mark possible transitions
"""
# The following section specifies the search problem and the solution.
# The graph is specified by first the set of start states, followed by
# the set of goal states, and lastly by the state transitions which are
# of the form:
# <start state> <actions> <end state> <cost>
graph: """
start_state: A
goal_states: G
A 0:A->B B 1.0
A 1:A->G G 2.0
A 2:A->D D 4.0
B 0:B->D D 8.0
D 0:D->G G 16.0
"""

View File

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

View File

@ -0,0 +1,30 @@
# Graph where natural action choice leads to an infinite loop
class: "GraphSearchTest"
algorithm: "breadthFirstSearch"
diagram: """
B <--> C
^ /|
| / |
V / V
*A<-/ [G]
A is the start state, G is the goal. Arrows mark
possible state transitions.
"""
# The following section specifies the search problem and the solution.
# The graph is specified by first the set of start states, followed by
# the set of goal states, and lastly by the state transitions which are
# of the form:
# <start state> <actions> <end state> <cost>
graph: """
start_state: A
goal_states: G
A 0:A->B B 1.0
B 0:B->A A 2.0
B 1:B->C C 4.0
C 0:C->A A 8.0
C 1:C->G G 16.0
C 2:C->B B 32.0
"""

View File

@ -0,0 +1,7 @@
# This is the solution file for test_cases/q2/graph_manypaths.test.
# This solution is designed to support both right-to-left
# and left-to-right implementations.
solution: "1:A->C 0:C->D 1:D->F 0:F->G"
expanded_states: "A B1 C B2 D E1 F E2"
rev_solution: "1:A->C 0:C->D 1:D->F 0:F->G"
rev_expanded_states: "A B2 C B1 D E2 F E1"

View File

@ -0,0 +1,39 @@
class: "GraphSearchTest"
algorithm: "breadthFirstSearch"
diagram: """
B1 E1
^ \ ^ \
/ V / V
*A --> C --> D --> F --> [G]
\ ^ \ ^
V / V /
B2 E2
A is the start state, G is the goal. Arrows mark
possible state transitions. This graph has multiple
paths to the goal, where nodes with the same state
are added to the fringe multiple times before they
are expanded.
"""
# The following section specifies the search problem and the solution.
# The graph is specified by first the set of start states, followed by
# the set of goal states, and lastly by the state transitions which are
# of the form:
# <start state> <actions> <end state> <cost>
graph: """
start_state: A
goal_states: G
A 0:A->B1 B1 1.0
A 1:A->C C 2.0
A 2:A->B2 B2 4.0
B1 0:B1->C C 8.0
B2 0:B2->C C 16.0
C 0:C->D D 32.0
D 0:D->E1 E1 64.0
D 1:D->F F 128.0
D 2:D->E2 E2 256.0
E1 0:E1->F F 512.0
E2 0:E2->F F 1024.0
F 0:F->G G 2048.0
"""

View File

@ -0,0 +1,22 @@
# This is the solution file for test_cases/q2/pacman_1.test.
# This solution is designed to support both right-to-left
# and left-to-right implementations.
# Number of nodes expanded must be with a factor of 1.0 of the numbers below.
solution: """
West West West West West West West West West South South East East
South South South West West West North West West West West South South
South East East East East East East East South South South South South
South South West West West West West West West West West West West
West West West West West West South West West West West West West West
West West
"""
expanded_nodes: "269"
rev_solution: """
West West West West West West West West West South South East East
South South South West West West North West West West West South South
South East East East East East East East South South South South South
South South West West West West West West West West West West West
West West West West West West South West West West West West West West
West West
"""
rev_expanded_nodes: "269"

View File

@ -0,0 +1,27 @@
# This is a basic breadth first search test
class: "PacmanSearchTest"
algorithm: "breadthFirstSearch"
# The following specifies the layout to be used
layoutName: "mediumMaze"
layout: """
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% P%
% %%%%%%%%%%%%%%%%%%%%%%% %%%%%%%% %
% %% % % %%%%%%% %% %
% %% % % % % %%%% %%%%%%%%% %% %%%%%
% %% % % % % %% %% %
% %% % % % % % %%%% %%% %%%%%% %
% % % % % % %% %%%%%%%% %
% %% % % %%%%%%%% %% %% %%%%%
% %% % %% %%%%%%%%% %% %
% %%%%%% %%%%%%% %% %%%%%% %
%%%%%% % %%%% %% % %
% %%%%%% %%%%% % %% %% %%%%%
% %%%%%% % %%%%% %% %
% %%%%%% %%%%%%%%%%% %% %% %
%%%%%%%%%% %%%%%% %
%. %%%%%%%%%%%%%%%% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"""

View File

@ -0,0 +1,2 @@
class: "PassAllTestsQuestion"
max_points: "3"

View File

@ -0,0 +1,7 @@
# This is the solution file for test_cases/q3/graph_backtrack.test.
# This solution is designed to support both right-to-left
# and left-to-right implementations.
solution: "1:A->C 0:C->G"
expanded_states: "A B C D"
rev_solution: "1:A->C 0:C->G"
rev_expanded_states: "A B C D"

View File

@ -0,0 +1,32 @@
class: "GraphSearchTest"
algorithm: "uniformCostSearch"
diagram: """
B
^
|
*A --> C --> G
|
V
D
A is the start state, G is the goal. Arrows mark
possible state transitions. This tests whether
you extract the sequence of actions correctly even
if your search backtracks. If you fail this, your
nodes are not correctly tracking the sequences of
actions required to reach them.
"""
# The following section specifies the search problem and the solution.
# The graph is specified by first the set of start states, followed by
# the set of goal states, and lastly by the state transitions which are
# of the form:
# <start state> <actions> <end state> <cost>
graph: """
start_state: A
goal_states: G
A 0:A->B B 1.0
A 1:A->C C 2.0
A 2:A->D D 4.0
C 0:C->G G 8.0
"""

View File

@ -0,0 +1,7 @@
# This is the solution file for test_cases/q3/graph_bfs_vs_dfs.test.
# This solution is designed to support both right-to-left
# and left-to-right implementations.
solution: "1:A->G"
expanded_states: "A B"
rev_solution: "1:A->G"
rev_expanded_states: "A B"

View File

@ -0,0 +1,30 @@
# Graph where BFS finds the optimal solution but DFS does not
class: "GraphSearchTest"
algorithm: "uniformCostSearch"
diagram: """
/-- B
| ^
| |
| *A -->[G]
| | ^
| V |
\-->D ----/
A is the start state, G is the goal. Arrows
mark possible transitions
"""
# The following section specifies the search problem and the solution.
# The graph is specified by first the set of start states, followed by
# the set of goal states, and lastly by the state transitions which are
# of the form:
# <start state> <actions> <end state> <cost>
graph: """
start_state: A
goal_states: G
A 0:A->B B 1.0
A 1:A->G G 2.0
A 2:A->D D 4.0
B 0:B->D D 8.0
D 0:D->G G 16.0
"""

View File

@ -0,0 +1,7 @@
# This is the solution file for test_cases/q3/graph_infinite.test.
# This solution is designed to support both right-to-left
# and left-to-right implementations.
solution: "0:A->B 1:B->C 1:C->G"
expanded_states: "A B C"
rev_solution: "0:A->B 1:B->C 1:C->G"
rev_expanded_states: "A B C"

View File

@ -0,0 +1,30 @@
# Graph where natural action choice leads to an infinite loop
class: "GraphSearchTest"
algorithm: "uniformCostSearch"
diagram: """
B <--> C
^ /|
| / |
V / V
*A<-/ [G]
A is the start state, G is the goal. Arrows mark
possible state transitions.
"""
# The following section specifies the search problem and the solution.
# The graph is specified by first the set of start states, followed by
# the set of goal states, and lastly by the state transitions which are
# of the form:
# <start state> <actions> <end state> <cost>
graph: """
start_state: A
goal_states: G
A 0:A->B B 1.0
B 0:B->A A 2.0
B 1:B->C C 4.0
C 0:C->A A 8.0
C 1:C->G G 16.0
C 2:C->B B 32.0
"""

View File

@ -0,0 +1,7 @@
# This is the solution file for test_cases/q3/graph_manypaths.test.
# This solution is designed to support both right-to-left
# and left-to-right implementations.
solution: "1:A->C 0:C->D 1:D->F 0:F->G"
expanded_states: "A B1 C B2 D E1 F E2"
rev_solution: "1:A->C 0:C->D 1:D->F 0:F->G"
rev_expanded_states: "A B1 C B2 D E1 F E2"

View File

@ -0,0 +1,39 @@
class: "GraphSearchTest"
algorithm: "uniformCostSearch"
diagram: """
B1 E1
^ \ ^ \
/ V / V
*A --> C --> D --> F --> [G]
\ ^ \ ^
V / V /
B2 E2
A is the start state, G is the goal. Arrows mark
possible state transitions. This graph has multiple
paths to the goal, where nodes with the same state
are added to the fringe multiple times before they
are expanded.
"""
# The following section specifies the search problem and the solution.
# The graph is specified by first the set of start states, followed by
# the set of goal states, and lastly by the state transitions which are
# of the form:
# <start state> <actions> <end state> <cost>
graph: """
start_state: A
goal_states: G
A 0:A->B1 B1 1.0
A 1:A->C C 2.0
A 2:A->B2 B2 4.0
B1 0:B1->C C 8.0
B2 0:B2->C C 16.0
C 0:C->D D 32.0
D 0:D->E1 E1 64.0
D 1:D->F F 128.0
D 2:D->E2 E2 256.0
E1 0:E1->F F 512.0
E2 0:E2->F F 1024.0
F 0:F->G G 2048.0
"""

View File

@ -0,0 +1,7 @@
# This is the solution file for test_cases/q3/ucs_0_graph.test.
# This solution is designed to support both right-to-left
# and left-to-right implementations.
solution: "Right Down Down"
expanded_states: "A B D C G"
rev_solution: "Right Down Down"
rev_expanded_states: "A B D C G"

View File

@ -0,0 +1,39 @@
class: "GraphSearchTest"
algorithm: "uniformCostSearch"
diagram: """
C
^
| 2
2 V 4
*A <----> B -----> [H]
|1
1.5 V 2.5
G <----- D -----> E
|
2 |
V
[F]
A is the start state, F and H is the goal. Arrows mark possible state
transitions. The number next to the arrow is the cost of that transition.
"""
# The following section specifies the search problem and the solution.
# The graph is specified by first the set of start states, followed by
# the set of goal states, and lastly by the state transitions which are
# of the form:
# <start state> <actions> <end state> <cost>
graph: """
start_state: A
goal_states: H F
A Right B 2.0
B Right H 4.0
B Down D 1.0
B Up C 2.0
B Left A 2.0
C Down B 2.0
D Right E 2.5
D Down F 2.0
D Left G 1.5
"""

View File

@ -0,0 +1,22 @@
# This is the solution file for test_cases/q3/ucs_1_problemC.test.
# This solution is designed to support both right-to-left
# and left-to-right implementations.
# Number of nodes expanded must be with a factor of 1.1 of the numbers below.
solution: """
West West West West West West West West West South South East East
South South South West West West North West West West West South South
South East East East East East East East South South South South South
South South West West West West West West West West West West West
West West West West West West South West West West West West West West
West West
"""
expanded_nodes: "269"
rev_solution: """
West West West West West West West West West South South East East
South South South West West West North West West West West South South
South East East East East East East East South South South South South
South South West West West West West West West West West West West
West West West West West West South West West West West West West West
West West
"""
rev_expanded_nodes: "269"

View File

@ -0,0 +1,28 @@
class: "PacmanSearchTest"
algorithm: "uniformCostSearch"
points: "0.5"
# The following specifies the layout to be used
layoutName: "mediumMaze"
layout: """
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% P%
% %%%%%%%%%%%%%%%%%%%%%%% %%%%%%%% %
% %% % % %%%%%%% %% %
% %% % % % % %%%% %%%%%%%%% %% %%%%%
% %% % % % % %% %% %
% %% % % % % % %%%% %%% %%%%%% %
% % % % % % %% %%%%%%%% %
% %% % % %%%%%%%% %% %% %%%%%
% %% % %% %%%%%%%%% %% %
% %%%%%% %%%%%%% %% %%%%%% %
%%%%%% % %%%% %% % %
% %%%%%% %%%%% % %% %% %%%%%
% %%%%%% % %%%%% %% %
% %%%%%% %%%%%%%%%%% %% %% %
%%%%%%%%%% %%%%%% %
%. %%%%%%%%%%%%%%%% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"""
leewayFactor: "1.1"
#costFn: "lambda pos: 1"

View File

@ -0,0 +1,22 @@
# This is the solution file for test_cases/q3/ucs_2_problemE.test.
# This solution is designed to support both right-to-left
# and left-to-right implementations.
# Number of nodes expanded must be with a factor of 1.1 of the numbers below.
solution: """
South South West West West West South South East East East East South
South West West West West South South East East East East South South
West West West West South South East East East East South South South
West West West West West West West North West West West West West West
West West West West West West West West West West West South West West
West West West West West West West
"""
expanded_nodes: "260"
rev_solution: """
South South West West West West South South East East East East South
South West West West West South South East East East East South South
West West West West South South East East East East South South South
West West West West West West West North West West West West West West
West West West West West West West West West West West South West West
West West West West West West West
"""
rev_expanded_nodes: "260"

View File

@ -0,0 +1,28 @@
class: "PacmanSearchTest"
algorithm: "uniformCostSearch"
points: "0.5"
# The following specifies the layout to be used
layoutName: "mediumMaze"
layout: """
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% P%
% %%%%%%%%%%%%%%%%%%%%%%% %%%%%%%% %
% %% % % %%%%%%% %% %
% %% % % % % %%%% %%%%%%%%% %% %%%%%
% %% % % % % %% %% %
% %% % % % % % %%%% %%% %%%%%% %
% % % % % % %% %%%%%%%% %
% %% % % %%%%%%%% %% %% %%%%%
% %% % %% %%%%%%%%% %% %
% %%%%%% %%%%%%% %% %%%%%% %
%%%%%% % %%%% %% % %
% %%%%%% %%%%% % %% %% %%%%%
% %%%%%% % %%%%% %% %
% %%%%%% %%%%%%%%%%% %% %% %
%%%%%%%%%% %%%%%% %
%. %%%%%%%%%%%%%%%% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"""
leewayFactor: "1.1"
costFn: "lambda pos: .5 ** pos[0]"

View File

@ -0,0 +1,34 @@
# This is the solution file for test_cases/q3/ucs_3_problemW.test.
# This solution is designed to support both right-to-left
# and left-to-right implementations.
# Number of nodes expanded must be with a factor of 1.1 of the numbers below.
solution: """
West West West West West West West West West West West West West West
West West West West West West West West West West West West West West
West West West West West South South South South South South South
South South East East East North North North North North North North
East East South South South South South South East East North North
North North North North East East South South South South East East
North North East East South South East East East South South West West
West West West West South South West West West West West South West
West West West West South South East East East East East East East
North East East East East East North North East East East East East
East South South West West West West South South West West West West
West South West West West West West West West West West
"""
expanded_nodes: "173"
rev_solution: """
West West West West West West West West West West West West West West
West West West West West West West West West West West West West West
West West West West West South South South South South South South
South South East East East North North North North North North North
East East South South South South South South East East North North
North North North North East East South South South South East East
North North East East South South East East East South South West West
West West West West South South West West West West West South West
West West West West South South East East East East East East East
North East East East East East North North East East East East East
East South South West West West West South South West West West West
West South West West West West West West West West West
"""
rev_expanded_nodes: "173"

View File

@ -0,0 +1,28 @@
class: "PacmanSearchTest"
algorithm: "uniformCostSearch"
points: "0.5"
# The following specifies the layout to be used
layoutName: "mediumMaze"
layout: """
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% P%
% %%%%%%%%%%%%%%%%%%%%%%% %%%%%%%% %
% %% % % %%%%%%% %% %
% %% % % % % %%%% %%%%%%%%% %% %%%%%
% %% % % % % %% %% %
% %% % % % % % %%%% %%% %%%%%% %
% % % % % % %% %%%%%%%% %
% %% % % %%%%%%%% %% %% %%%%%
% %% % %% %%%%%%%%% %% %
% %%%%%% %%%%%%% %% %%%%%% %
%%%%%% % %%%% %% % %
% %%%%%% %%%%% % %% %% %%%%%
% %%%%%% % %%%%% %% %
% %%%%%% %%%%%%%%%%% %% %% %
%%%%%%%%%% %%%%%% %
%. %%%%%%%%%%%%%%%% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"""
leewayFactor: "1.1"
costFn: "lambda pos: 2 ** pos[0]"

View File

@ -0,0 +1,12 @@
# This is the solution file for test_cases/q3/ucs_4_testSearch.test.
# This solution is designed to support both right-to-left
# and left-to-right implementations.
# Number of nodes expanded must be with a factor of 2.0 of the numbers below.
solution: """
West East East South South West West
"""
expanded_nodes: "14"
rev_solution: """
West East East South South West West
"""
rev_expanded_nodes: "13"

View File

@ -0,0 +1,16 @@
class: "PacmanSearchTest"
algorithm: "uniformCostSearch"
points: "0.5"
# The following specifies the layout to be used
layoutName: "testSearch"
layout: """
%%%%%
%.P %
%%% %
%. %
%%%%%
"""
searchProblemClass: "FoodSearchProblem"
leewayFactor: "2"

View File

@ -0,0 +1,7 @@
# This is the solution file for test_cases/q3/ucs_5_goalAtDequeue.test.
# This solution is designed to support both right-to-left
# and left-to-right implementations.
solution: "1:A->B 0:B->C 0:C->G"
expanded_states: "A B C"
rev_solution: "1:A->B 0:B->C 0:C->G"
rev_expanded_states: "A B C"

View File

@ -0,0 +1,29 @@
class: "GraphSearchTest"
algorithm: "uniformCostSearch"
diagram: """
1 1 1
*A ---> B ---> C ---> [G]
| ^
| 10 |
\---------------------/
A is the start state, G is the goal. Arrows mark possible state
transitions. The number next to the arrow is the cost of that transition.
If you fail this test case, you may be incorrectly testing if a node is a goal
before adding it into the queue, instead of testing when you remove the node
from the queue. See the algorithm pseudocode in lecture.
"""
graph: """
start_state: A
goal_states: G
A 0:A->G G 10.0
A 1:A->B B 1.0
B 0:B->C C 1.0
C 0:C->G G 1.0
"""
# We only care about the solution, not the expansion order.
exactExpansionOrder: "False"

View File

@ -0,0 +1,2 @@
class: "PassAllTestsQuestion"
max_points: "3"

View File

@ -0,0 +1,7 @@
# This is the solution file for test_cases/q4/astar_0.test.
# This solution is designed to support both right-to-left
# and left-to-right implementations.
solution: "Right Down Down"
expanded_states: "A B D C G"
rev_solution: "Right Down Down"
rev_expanded_states: "A B D C G"

View File

@ -0,0 +1,39 @@
class: "GraphSearchTest"
algorithm: "aStarSearch"
diagram: """
C
^
| 2
2 V 4
*A <----> B -----> [H]
|
1.5 V 2.5
G <----- D -----> E
|
2 |
V
[F]
A is the start state, F and H is the goal. Arrows mark possible state
transitions. The number next to the arrow is the cost of that transition.
"""
# The following section specifies the search problem and the solution.
# The graph is specified by first the set of start states, followed by
# the set of goal states, and lastly by the state transitions which are
# of the form:
# <start state> <actions> <end state> <cost>
graph: """
start_state: A
goal_states: H F
A Right B 2.0
B Right H 4.0
B Down D 1.0
B Up C 2.0
B Left A 2.0
C Down B 2.0
D Right E 2.5
D Down F 2.0
D Left G 1.5
"""

View File

@ -0,0 +1,7 @@
# This is the solution file for test_cases/q4/astar_1_graph_heuristic.test.
# This solution is designed to support both right-to-left
# and left-to-right implementations.
solution: "0 0 2"
expanded_states: "S A D C"
rev_solution: "0 0 2"
rev_expanded_states: "S A D C"

View File

@ -0,0 +1,54 @@
class: "GraphSearchTest"
algorithm: "aStarSearch"
diagram: """
2 3 2
S --- A --- C ---> G
| \ / ^
3 | \ 5 / 1 /
| \ / /
B --- D -------/
4 5
S is the start state, G is the goal. Arrows mark possible state
transitions. The number next to the arrow is the cost of that transition.
The heuristic value of each state is:
S 6.0
A 2.5
B 5.25
C 1.125
D 1.0625
G 0
"""
# The following section specifies the search problem and the solution.
# The graph is specified by first the set of start states, followed by
# the set of goal states, and lastly by the state transitions which are
# of the form:
# <start state> <actions> <end state> <cost>
graph: """
start_state: S
goal_states: G
S 0 A 2.0
S 1 B 3.0
S 2 D 5.0
A 0 C 3.0
A 1 S 2.0
B 0 D 4.0
B 1 S 3.0
C 0 A 3.0
C 1 D 1.0
C 2 G 2.0
D 0 B 4.0
D 1 C 1.0
D 2 G 5.0
D 3 S 5.0
"""
heuristic: """
S 6.0
A 2.5
B 5.25
C 1.125
D 1.0625
G 0
"""

View File

@ -0,0 +1,22 @@
# This is the solution file for test_cases/q4/astar_2_manhattan.test.
# This solution is designed to support both right-to-left
# and left-to-right implementations.
# Number of nodes expanded must be with a factor of 1.1 of the numbers below.
solution: """
West West West West West West West West West South South East East
South South South West West West North West West West West South South
South East East East East East East East South South South South South
South South West West West West West West West West West West West
West West West West West West South West West West West West West West
West West
"""
expanded_nodes: "221"
rev_solution: """
West West West West West West West West West South South East East
South South South West West West North West West West West South South
South East East East East East East East South South South South South
South South West West West West West West West West West West West
West West West West West West South West West West West West West West
West West
"""
rev_expanded_nodes: "221"

View File

@ -0,0 +1,27 @@
class: "PacmanSearchTest"
algorithm: "aStarSearch"
# The following specifies the layout to be used
layoutName: "mediumMaze"
layout: """
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% P%
% %%%%%%%%%%%%%%%%%%%%%%% %%%%%%%% %
% %% % % %%%%%%% %% %
% %% % % % % %%%% %%%%%%%%% %% %%%%%
% %% % % % % %% %% %
% %% % % % % % %%%% %%% %%%%%% %
% % % % % % %% %%%%%%%% %
% %% % % %%%%%%%% %% %% %%%%%
% %% % %% %%%%%%%%% %% %
% %%%%%% %%%%%%% %% %%%%%% %
%%%%%% % %%%% %% % %
% %%%%%% %%%%% % %% %% %%%%%
% %%%%%% % %%%%% %% %
% %%%%%% %%%%%%%%%%% %% %% %
%%%%%%%%%% %%%%%% %
%. %%%%%%%%%%%%%%%% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"""
leewayFactor: "1.1"
heuristic: "manhattanHeuristic"

View File

@ -0,0 +1,7 @@
# This is the solution file for test_cases/q4/astar_3_goalAtDequeue.test.
# This solution is designed to support both right-to-left
# and left-to-right implementations.
solution: "1:A->B 0:B->C 0:C->G"
expanded_states: "A B C"
rev_solution: "1:A->B 0:B->C 0:C->G"
rev_expanded_states: "A B C"

View File

@ -0,0 +1,29 @@
class: "GraphSearchTest"
algorithm: "aStarSearch"
diagram: """
1 1 1
*A ---> B ---> C ---> [G]
| ^
| 10 |
\---------------------/
A is the start state, G is the goal. Arrows mark possible state
transitions. The number next to the arrow is the cost of that transition.
If you fail this test case, you may be incorrectly testing if a node is a goal
before adding it into the queue, instead of testing when you remove the node
from the queue. See the algorithm pseudocode in lecture.
"""
graph: """
start_state: A
goal_states: G
A 0:A->G G 10.0
A 1:A->B B 1.0
B 0:B->C C 1.0
C 0:C->G G 1.0
"""
# We only care about the solution, not the expansion order.
exactExpansionOrder: "False"

View File

@ -0,0 +1,7 @@
# This is the solution file for test_cases/q4/graph_backtrack.test.
# This solution is designed to support both right-to-left
# and left-to-right implementations.
solution: "1:A->C 0:C->G"
expanded_states: "A B C D"
rev_solution: "1:A->C 0:C->G"
rev_expanded_states: "A B C D"

View File

@ -0,0 +1,32 @@
class: "GraphSearchTest"
algorithm: "aStarSearch"
diagram: """
B
^
|
*A --> C --> G
|
V
D
A is the start state, G is the goal. Arrows mark
possible state transitions. This tests whether
you extract the sequence of actions correctly even
if your search backtracks. If you fail this, your
nodes are not correctly tracking the sequences of
actions required to reach them.
"""
# The following section specifies the search problem and the solution.
# The graph is specified by first the set of start states, followed by
# the set of goal states, and lastly by the state transitions which are
# of the form:
# <start state> <actions> <end state> <cost>
graph: """
start_state: A
goal_states: G
A 0:A->B B 1.0
A 1:A->C C 2.0
A 2:A->D D 4.0
C 0:C->G G 8.0
"""

View File

@ -0,0 +1,7 @@
# This is the solution file for test_cases/q4/graph_manypaths.test.
# This solution is designed to support both right-to-left
# and left-to-right implementations.
solution: "1:A->C 0:C->D 1:D->F 0:F->G"
expanded_states: "A B1 C B2 D E1 F E2"
rev_solution: "1:A->C 0:C->D 1:D->F 0:F->G"
rev_expanded_states: "A B1 C B2 D E1 F E2"

View File

@ -0,0 +1,39 @@
class: "GraphSearchTest"
algorithm: "aStarSearch"
diagram: """
B1 E1
^ \ ^ \
/ V / V
*A --> C --> D --> F --> [G]
\ ^ \ ^
V / V /
B2 E2
A is the start state, G is the goal. Arrows mark
possible state transitions. This graph has multiple
paths to the goal, where nodes with the same state
are added to the fringe multiple times before they
are expanded.
"""
# The following section specifies the search problem and the solution.
# The graph is specified by first the set of start states, followed by
# the set of goal states, and lastly by the state transitions which are
# of the form:
# <start state> <actions> <end state> <cost>
graph: """
start_state: A
goal_states: G
A 0:A->B1 B1 1.0
A 1:A->C C 2.0
A 2:A->B2 B2 4.0
B1 0:B1->C C 8.0
B2 0:B2->C C 16.0
C 0:C->D D 32.0
D 0:D->E1 E1 64.0
D 1:D->F F 128.0
D 2:D->E2 E2 256.0
E1 0:E1->F F 512.0
E2 0:E2->F F 1024.0
F 0:F->G G 2048.0
"""

View File

@ -0,0 +1,3 @@
class: "PassAllTestsQuestion"
max_points: "3"
depends: "q2"

View File

@ -0,0 +1,2 @@
# This is the solution file for test_cases/q5/corner_tiny_corner.test.
solution_length: "28"

View File

@ -0,0 +1,14 @@
class: "CornerProblemTest"
layoutName: "tinyCorner"
layout: """
%%%%%%%%
%. .%
% P %
% %%%% %
% % %
% % %%%%
%.% .%
%%%%%%%%
"""

View File

@ -0,0 +1,3 @@
class: "Q6PartialCreditQuestion"
max_points: "3"
depends: "q4"

View File

@ -0,0 +1,7 @@
# In order for a heuristic to be admissible, the value
# of the heuristic must be less at each state than the
# true cost of the optimal path from that state to a goal.
cost: "8"
path: """
North South South East East East North North
"""

View File

@ -0,0 +1,12 @@
class: "CornerHeuristicSanity"
points: "1"
# The following specifies the layout to be used
layout: """
%%%%%%
%. .%
%P %
%. .%
%%%%%%
"""

View File

@ -0,0 +1,7 @@
# In order for a heuristic to be admissible, the value
# of the heuristic must be less at each state than the
# true cost of the optimal path from that state to a goal.
cost: "8"
path: """
West North North East East East South South
"""

View File

@ -0,0 +1,12 @@
class: "CornerHeuristicSanity"
points: "1"
# The following specifies the layout to be used
layout: """
%%%%%%
%. .%
% %% %
%.P%.%
%%%%%%
"""

View File

@ -0,0 +1,9 @@
# In order for a heuristic to be admissible, the value
# of the heuristic must be less at each state than the
# true cost of the optimal path from that state to a goal.
cost: "28"
path: """
South South South West West West West East East East East East North
North North North North West West West South South South West West
North North North
"""

View File

@ -0,0 +1,15 @@
class: "CornerHeuristicSanity"
points: "1"
# The following specifies the layout to be used
layout: """
%%%%%%%%
%.% .%
% % % %
% % %P %
% % %
%%%%% %
%. .%
%%%%%%%%
"""

View File

@ -0,0 +1,16 @@
# This solution file specifies the length of the optimal path
# as well as the thresholds on number of nodes expanded to be
# used in scoring.
cost: "106"
path: """
North East East East East North North West West West West North North
North North North North North North West West West West South South
East East East East South South South South South South West West
South South South West West East East North North North East East East
East East East East East South South East East East East East North
North East East North North East East North North East East East East
South South South South East East North North East East South South
South South South North North North North North North North West West
North North East East North North
"""
thresholds: "2000 1600 1200"

View File

@ -0,0 +1,19 @@
class: "CornerHeuristicPacman"
# The following specifies the layout to be used
layout: """
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%. % % % %.%
% % % %%%%%% %%%%%%% % %
% % % % % %
%%%%% %%%%% %%% %% %%%%% % %%%
% % % % % % % % %
% %%% % % % %%%%%%%% %%% %%% %
% % %% % % % %
%%% % %%%%%%% %%%% %%% % % % %
% % %% % % %
% % %%%%% % %%%% % %%% %%% % %
% % % % % % %%% %
%. %P%%%%% % %%% % .%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"""

View File

@ -0,0 +1,3 @@
class: "PartialCreditQuestion"
max_points: "4"
depends: "q4"

View File

@ -0,0 +1,2 @@
# This is the solution file for test_cases/q7/food_heuristic_1.test.
solution_cost: "0"

View File

@ -0,0 +1,13 @@
class: "HeuristicTest"
heuristic: "foodHeuristic"
searchProblemClass: "FoodSearchProblem"
layoutName: "Test 1"
layout: """
%%%%%%
% %
% %
%P %
%%%%%%
"""

View File

@ -0,0 +1,2 @@
# This is the solution file for test_cases/q7/food_heuristic_10.test.
solution_cost: "7"

View File

@ -0,0 +1,13 @@
class: "HeuristicTest"
heuristic: "foodHeuristic"
searchProblemClass: "FoodSearchProblem"
layoutName: "Test 10"
layout: """
%%%%%%%%
% %
%. P .%
% %
%%%%%%%%
"""

View File

@ -0,0 +1,2 @@
# This is the solution file for test_cases/q7/food_heuristic_11.test.
solution_cost: "8"

View File

@ -0,0 +1,13 @@
class: "HeuristicTest"
heuristic: "foodHeuristic"
searchProblemClass: "FoodSearchProblem"
layoutName: "Test 11"
layout: """
%%%%%%%%
% %
% P %
%. . .%
%%%%%%%%
"""

View File

@ -0,0 +1,2 @@
# This is the solution file for test_cases/q7/food_heuristic_12.test.
solution_cost: "1"

View File

@ -0,0 +1,13 @@
class: "HeuristicTest"
heuristic: "foodHeuristic"
searchProblemClass: "FoodSearchProblem"
layoutName: "Test 12"
layout: """
%%%%%%%%
% %
% P.%
% %
%%%%%%%%
"""

View File

@ -0,0 +1,2 @@
# This is the solution file for test_cases/q7/food_heuristic_13.test.
solution_cost: "5"

View File

@ -0,0 +1,13 @@
class: "HeuristicTest"
heuristic: "foodHeuristic"
searchProblemClass: "FoodSearchProblem"
layoutName: "Test 13"
layout: """
%%%%%%%%
% %
%P. .%
% %
%%%%%%%%
"""

View File

@ -0,0 +1,2 @@
# This is the solution file for test_cases/q7/food_heuristic_14.test.
solution_cost: "31"

View File

@ -0,0 +1,19 @@
class: "HeuristicTest"
heuristic: "foodHeuristic"
searchProblemClass: "FoodSearchProblem"
layoutName: "Test 14"
layout: """
%%%%%%%%%%
% %
% ...%...%
% .%.%.%.%
% .%.%.%.%
% .%.%.%.%
% .%.%.%.%
% .%.%.%.%
%P.%...%.%
% %
%%%%%%%%%%
"""

View File

@ -0,0 +1,2 @@
# This is the solution file for test_cases/q7/food_heuristic_15.test.
solution_cost: "21"

View File

@ -0,0 +1,32 @@
class: "HeuristicTest"
heuristic: "foodHeuristic"
searchProblemClass: "FoodSearchProblem"
layoutName: "Test 15"
layout: """
%%%
% %
% %
% %
% %
% %
%.%
%.%
% %
% %
% %
% %
% %
% %
% %
%.%
% %
%P%
% %
% %
% %
% %
%.%
%%%
"""

View File

@ -0,0 +1,2 @@
# This is the solution file for test_cases/q7/food_heuristic_16.test.
solution_cost: "7"

View File

@ -0,0 +1,15 @@
class: "HeuristicTest"
heuristic: "foodHeuristic"
searchProblemClass: "FoodSearchProblem"
layoutName: "Test 16"
layout: """
%%%%
% .%
% %
%P %
% %
% .%
%%%%
"""

View File

@ -0,0 +1,2 @@
# This is the solution file for test_cases/q7/food_heuristic_17.test.
solution_cost: "16"

View File

@ -0,0 +1,14 @@
class: "HeuristicTest"
heuristic: "foodHeuristic"
searchProblemClass: "FoodSearchProblem"
layoutName: "Test 17"
layout: """
%%%%%%%%
%.%....%
%.% %%.%
%.%P%%.%
%... .%
%%%%%%%%
"""

View File

@ -0,0 +1,2 @@
# This is the solution file for test_cases/q7/food_heuristic_2.test.
solution_cost: "0"

View File

@ -0,0 +1,32 @@
class: "HeuristicTest"
heuristic: "foodHeuristic"
searchProblemClass: "FoodSearchProblem"
layoutName: "Test 2"
layout: """
%%%
% %
% %
% %
% %
% %
% %
% %
% %
% %
% %
% %
% %
% %
% %
% %
% %
%P%
% %
% %
% %
% %
% %
%%%
"""

View File

@ -0,0 +1,2 @@
# This is the solution file for test_cases/q7/food_heuristic_3.test.
solution_cost: "0"

View File

@ -0,0 +1,15 @@
class: "HeuristicTest"
heuristic: "foodHeuristic"
searchProblemClass: "FoodSearchProblem"
layoutName: "Test 3"
layout: """
%%%%
% %
% %
%P %
% %
% %
%%%%
"""

View File

@ -0,0 +1,2 @@
# This is the solution file for test_cases/q7/food_heuristic_4.test.
solution_cost: "0"

View File

@ -0,0 +1,14 @@
class: "HeuristicTest"
heuristic: "foodHeuristic"
searchProblemClass: "FoodSearchProblem"
layoutName: "Test 4"
layout: """
%%%%%%%%
% % %
% % %% %
% %P%% %
% %
%%%%%%%%
"""

View File

@ -0,0 +1,2 @@
# This is the solution file for test_cases/q7/food_heuristic_5.test.
solution_cost: "11"

View File

@ -0,0 +1,13 @@
class: "HeuristicTest"
heuristic: "foodHeuristic"
searchProblemClass: "FoodSearchProblem"
layoutName: "Test 5"
layout: """
%%%%%%
%....%
%....%
%P...%
%%%%%%
"""

View File

@ -0,0 +1,2 @@
# This is the solution file for test_cases/q7/food_heuristic_6.test.
solution_cost: "5"

View File

@ -0,0 +1,13 @@
class: "HeuristicTest"
heuristic: "foodHeuristic"
searchProblemClass: "FoodSearchProblem"
layoutName: "Test 6"
layout: """
%%%%%%
% .%
%.P..%
% %
%%%%%%
"""

View File

@ -0,0 +1,2 @@
# This is the solution file for test_cases/q7/food_heuristic_7.test.
solution_cost: "7"

View File

@ -0,0 +1,13 @@
class: "HeuristicTest"
heuristic: "foodHeuristic"
searchProblemClass: "FoodSearchProblem"
layoutName: "Test 7"
layout: """
%%%%%%%
% .%
%. P..%
% %
%%%%%%%
"""

Some files were not shown because too many files have changed in this diff Show More