Description
In this assignment you will create an agent to traverse a maze. You will implement and compare several search algorithms, and collect some statistics related to their performances.
Please read all sections carefully: I. Introduction II. Algorithm Review III. What You Need To Submit IV. What Your Program Outputs V. Implementation and Testing VI. Before You Finish I.
Introduction
The aim of this homework is to build a search agent for a robotic path planning. You will be implementing and comparing several search algorithms and evaluating their performances. More specifically, we would like to build Mark1, a search agent robot for our AI class. We want Mark1 to be able to navigate in a given map with obstacles. The first important task of the robot is assigned to you. To make crafting this first prototype easier and manageable, the robot leader has allowed for various assumptions to hold in the map and the robot.
These are described as follows: Assumptions: 1. The map is a rectangular arena of size m × n which is bounded by walls on the four sides. 2. An obstacle in the map is marked by an “o”, and an empty positions is marked by “ ” (blank space) in the map. 3. The robot always starts from one exact position marked “s” in the map. 4. The robot has to reach one and only one goal position marked “g” in the map.
The goal position is guaranteed to be reachable from the start position. 5. The robot is allowed to move only in one of the four directions (UP, RIGHT, DOWN and LEFT), one move at a time. 6. The cost of moving from one point to any neighbour is the same and equal to one. Thus, the total cost of path is equal to the number of moves made from start to the goal position. 7. Though the robot is autonomous, it is assumed that the robot is always aware of the complete map and its current location w.r.t to the map at anytime.
NOTE: This example diagram is intended to illustrate the format of the input maze and the expected output maze only and may or may not represent a solution from any of the expected implementations
II. Algorithm Review Recall from lecture that search begins by visiting the root node of the search tree, given by the initial state. Three main events occur when visiting a node: • First, we remove a node from the frontier set. • Second, we check if this node matches the goal state. • If not, we then expand the node. To expand a node, we generate all of its immediate successors and add them to the frontier, if they (i) are not yet already in the frontier, and (ii) have not been visited yet.
• Nodes MUST BE expanded in the order Up, Right, Down, Left as is implemented in the expand method of the MazeState class of the pseudocode. If this order is not followed, your solution may differ from the expected solution and the autograder will mark your solution as incorrect. Be careful when implementing any method that uses a stack or LIFO queue.
This describes the life cycle of a visit, and is the basic order of operations for search agents in this assignment–(1) remove, (2) check, and (3) expand. We will implement the assignment algorithms as described here. Please refer to lecture notes for further details, and review the lecture pseudo-code before you begin. IMPORTANT: You may encounter implementations that attempt to short-circuit this order by performing the goal-check on successor nodes immediately upon expansion of a parent node.
For example, Russell & Norvig’s implementation of BFS does precisely this. Doing so may lead to edgecase gains in efficiency, but do not alter the general characteristics of complexity and optimality for each method. For simplicity and grading purposes in this assignment, do not make such modifications to algorithms learned in lecture. III. What You Need To Submit Your job in this assignment is to write maze.py, which solves any maze using the graph search method(s) passed in as flags.
The program will be executed as follows: $python3 maze.py -m