CSci 356 - Lab 2

Purpose: The purpose of this lab is to continue our exploration of the AIPython example code by running simulations of a virtual robot.

Warmup. Last week we talked about the Anaconda system installed on the lab computers. Anaconda is a virtual environment for Python containing a great many machine learning and data science frameworks. The tools we use for this class are installed as part of these frameworks.

You should be able to do this exercise without using the conda activate command (which activates our virtual environment, called base) but it doesn't hurt if you do. Remember, if the virtual environment has been activated, the environment name will appear as part of the command prompt in Terminal.

Exercise.

Show that you've been able to run the AIPython program agentTop.py by demonstrating the graph it produces. You can do this on the Linux Lab computers or your own installation.

Follow these steps to get the graph (I assume you've downloaded the AIPython zip file and expanded it into a directory):

  1. Open the file agentTop.py and look at the last 6 lines of the file which are commented out. We're interested in the 5 lines after the #try: comment:
    • pl=Plot_env(body,top) creates the object that plots the robot's movement
       
    • top.do({'visit':['o109','storage','o109','o103']}) calls the do method on the top layer and passes it the locations to visit (its to_do list, essentially)
       
    • middle.do({'go_to':(30,-10), 'timeout':200}) directs the robot through the middle layer (defined in agentMiddle.py) to move to a particular coordinate within 200 steps, you can use this to by-pass the top layer and give it direct movement commands.
       
  2. Run ipython -i agentTop.py, which initializes the environment and virtual robot.
     
  3. At the prompt, manually enter and run the first two commands. You should get a running plot of the virtual robot as it tries to visit each location in its to_do list.
     
  4. The last comment asks if you can make the robot crash. Try this! The easiest way is to use middle.do to try moving the robot to a specific coordinate, but through a wall. You may want to experiment with different approaches.
     
  5. Show the graph to the instructor before you leave.