Author | Message |
---|---|
rabbott
Posts: 1649
|
Posted 15:33 Sep 02, 2019 |
The function print("Start:", problem.getStartState()) # => Start: (5, 5) print("Is the start a goal?", problem.isGoalState(problem.getStartState())) # => Is the start a goal? False print("Start's successors:", problem.getSuccessors(problem.getStartState())) # => Start's successors: [((5, 4), 'South', 1), ((4, 5), 'West', 1)] The start state looks like this. As you can see, Pacman starts in position (5, 5); the goal is in position (0, 0), which is not the same as the start position; and Start's possible successors are South by one unit to (5, 4) and West by one unit to (4, 5). (See message below about the apparent interchanging of West and East.) You can see the definition of the TinyMaze in the layouts directory. It is defined with alpha characters:
%%%%%%%
% P%
% %%% %
% % %
%% %%
%. %%%%
%%%%%%%
P is the start position; . is the goal position; % are walls This information should help you get started writing your search functions. Post additional questions here on the Forum. Last edited by rabbott at
17:11 Sep 02, 2019.
|
rabbott
Posts: 1649
|
Posted 17:11 Sep 02, 2019 |
In search.py the function tinyMazeSearch, which is defined directly above depthFirstSearch returns a hard-wired solution to the tinyMaze problem. That solution is as follows: [s, s, w, s, w, w, s, w], where s is 'south' and w is 'west'. These seem like strange directions. Instead of 'west', one should go 'east' at each of the 'w' steps. Yet that solution works. If your depthFirstSearch simply calls and returns tinyMazeSearch(problem), you will solve the problem. I'm confused about why 'east' and 'west' seem to be reversed, but that seems to be the way it is. Apparently, you don't have to worry about this since the directions you get from the getSuccessors function is consistent in this regard. If anyone understands this better than I do, please post your thoughts. The class Actions in game.py defines the actions as indicated.
{Directions.NORTH: (0, 1),
Directions.SOUTH: (0, -1),
Directions.EAST: (1, 0),
Directions.WEST: (-1, 0),
Directions.STOP: (0, 0)}
Last edited by rabbott at
17:44 Sep 02, 2019.
|
jgnong
Posts: 10
|
Posted 17:56 Sep 02, 2019 |
I believe, its because the board is created on the 2D plane with x and y coordinates that we are used to, positive y being North(up), negative y being South(down), positive x being East(right), and negative x being West(left) from a 3rd person pov. In tinyMazeSearch(problem) it just an example hard coded traversal for the tiny maze like the one you posted earlier, so to reach the goal the pacman only needs to go [s, s, w, s, w, w, s, w] or i.e [down, down, left, down, left, left, down, left] |
rabbott
Posts: 1649
|
Posted 19:26 Sep 02, 2019 |
You're right about the x-y plane. The reason I was confused was that I kept thinking that left was east. But left is west, which explains everything. My confusion is a long-term holdover from the fact that I came to California from the east coast. I can't even explain what the confusion is anymore. It's been decades since I moved here, but I still get confused. |
rabbott
Posts: 1649
|
Posted 19:47 Sep 02, 2019 |
If you want the display to remain on the screen longer, insert
input('Press "Enter" to continue.')
in game.py before
self.display.finish()
on line 729. Last edited by rabbott at
20:16 Sep 02, 2019.
|
rabbott
Posts: 1649
|
Posted 22:17 Sep 02, 2019 |
My dfs and bfs results using the mediumMaze. DFS
BFS
But BFS paid a price. The DFS search expanded only 76 nodes, whereas the BFS expanded 269 nodes. Last edited by rabbott at
22:43 Sep 02, 2019.
|
rabbott
Posts: 1649
|
Posted 22:46 Sep 02, 2019 |
Since the Project 1 assignment is fairly long, let's split it up over two weeks. The first week will be questions 1 - 4. The second week will be questions 5 - 8. We'll drop the assignment that requires that you read and explain the A* code. |
rabbott
Posts: 1649
|
Posted 23:40 Sep 02, 2019 |
As Question 2 points out, you can solve the eight-puzzle using BFS. It works, but it shows how much simpler the 8-puzzle is than the 15-puzzle! |
rabbott
Posts: 1649
|
Posted 12:54 Sep 03, 2019 |
Question 3 poses an interesting challenge. The search agents themselves compute the cost of going east or west. You don't have to worry about that. But you do have to decide how to include that information in a priority. One option is to add the new cost to the length of the current path. (That's what I did at first.) The problem with that is that the length of the path dominates, and one gets a BFS solution. An alternative is to us the cost of the current step (computed by the agent and given to you) as the priority. But that generates something like a greedy search. I eventually decided to use a tuple ( succ_cost, len(new_path) ) as a priority. This is very much like using the successor's cost as a priority, but if two costs are the same, it favors shorter paths. If you use this strategy, please be prepared to explain why it does what it does. Last edited by rabbott at
14:34 Sep 03, 2019.
|