EECS110 Course
Project Option 4, Spring 2018
The
picobot Project
Overview
In this project you will
implement your version of the picobot program that we used in homework 1 (http://networks.cs.northwestern.edu/EECS110-s17/hw/hw0/hw0pr3.htm).
The screenshot above shows
the desired outcome of the program. It should simply execute the picobot
program based on a given text file, exactly in the same way it was done in
Homework 0. There should be at least two control buttons: one that would run
the program without any delays, and the other one that would enable
step-by-step program execution.
Project
Goal
You should design and
implement a program that will create the above window and run the picobot
program based on a TXT file that you will provide. Feel free to reuse the TXT
files you created for Homework 0. (To simplify the task, we will explain how to
change your Homework 0 solutions below). Details about picobot operations are
available here: http://networks.cs.northwestern.edu/EECS110-s17/hw/hw0/hw0pr3.htm
Getting
Started
You should download the graphics32.py
file from this link, originally posted and available from this site. It is a graphics library you
will use in this project. Browseable reference documentation for the graphics
package is available here.
To help you start,
consider the following program:
from graphics32 import *
def main():
win =
GraphWin("MyWindow", 400, 400)
p1 =
Point(0,355)
p2 =
Point(400,400)
square5 =
Rectangle(p1,p2)
square5.setFill("yellow")
square5.setOutline("yellow")
square5.draw(win)
#Exit button
p1 =
Point(122,360)
p2 =
Point(198,390)
square1 =
Rectangle(p1,p2)
square1.setFill("gray")
square1.draw(win)
p =
square1.getCenter()
t = Text(p,
"Exit")
t.draw(win)
#loop
while True:
K = win.getMouse()
if K.getX() > 122 and K.getX() <
198 and K.getY() > 360 and K.getY() < 390:
win.close()
exit("The end")
At
the beginning, the program creates an object win of the type GraphWin, using win = GraphWin("MyWindow", 400, 400). The object win has
400*400 pixels.
Next,
the program draws a yellow rectangle at the bottom of the window. It first
generates to points, p1 and p2,
with appropriate coordinates (e.g., (0,355) for p1 and (400,400) for p2). Then,
it creates a rectangle yr using points p1 and p2, respectively.
Next, the program yellows object yr using rectangle
methods setFill()and setOutline(). Finally, the yr object draws
itself onto the window using yr.draw(win).
Further,
the program creates a new rectangle object, called eb, which
short from exit button. The
coordinates of eb are (122,360) and (198,390). This object
also draws itself onto the window using eb.draw(win).
In
addition, the program creates text object t, the value of
which becomes Exit, and draws itself in the center of
the exit button.
Finally,
the program enters a while loop. Variable K holds the
coordinate at which the user clicks. When the user clicks the Exit button, the
program terminates.
What
You Will Do
Your task is to design and
implement a program that will create the above window and run the picobot
program based on a TXT file that you will provide.
Here are the requirements
for your picobot program:
If you mark blue by 1, and white by 0, then
the above maze could be represented as a 2D list:
X =
[[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[1,0,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,1,0,1],
[1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0,0,1,0,0,0,0,1],
[1,1,0,1,0,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,1,1,1,0,1],
[1,0,0,1,0,0,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,0,1,0,1],
[1,0,1,1,1,0,1,1,1,1,0,1,0,1,0,1,0,1,0,1,1,0,0,0,1],
[1,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,0,1,0,1,1,1,1,1,1],
[1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,1,0,0,1,0,0,0,1],
[1,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1,1,0,1,0,1,1,1],
[1,1,0,1,0,1,0,0,0,1,0,1,0,1,1,1,0,1,1,0,1,0,0,0,1],
[1,1,0,1,0,1,1,1,1,1,0,1,0,1,0,1,0,1,1,0,1,0,1,0,1],
[1,1,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,0,1,1,1,0,1],
[1,1,0,1,1,1,1,1,0,1,1,0,1,1,1,1,1,0,1,0,0,0,0,0,1],
[1,0,0,0,0,0,0,1,0,1,1,0,0,0,0,0,1,0,1,1,1,0,1,0,1],
[1,0,1,1,1,1,1,1,0,1,0,0,1,1,1,0,1,0,0,0,1,0,1,0,1],
[1,0,0,0,0,0,0,0,0,1,0,1,1,1,1,0,1,1,1,0,1,0,1,0,1],
[1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,0,0,0,1,0,1,0,1,0,1],
[1,0,0,0,0,1,0,0,0,1,1,1,0,1,1,1,1,0,1,0,1,0,1,0,1],
[1,0,1,1,0,1,0,1,0,0,0,0,0,0,0,0,1,0,1,0,1,1,1,0,1],
[1,0,0,1,0,1,0,1,1,1,1,1,0,1,1,0,1,0,1,0,1,0,1,0,1],
[1,0,1,1,0,1,0,1,0,1,0,0,0,1,0,0,1,0,0,0,1,0,0,0,1],
[1,0,1,0,0,1,0,1,0,0,0,1,1,1,0,1,1,1,1,1,1,1,0,1,1],
[1,0,1,1,1,1,0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,1,0,1,1],
[1,0,0,0,0,0,0,1,0,1,1,1,0,1,0,0,0,1,1,1,0,0,0,1,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]]
Hints
Here are several hints:
f = open('map3.txt', 'r')
text = f.read()
L = text.split()
f.close()
for i in range(len(L)):
if L[i] == '->':
if L[i-1] == 'xxxx':
#ETC
What
to Submit for the Intermediate and Final Submissions
There are two submission deadlines. By the
Intermediate Deadline on Sunday, 06/03 at 11:59 PM
you should submit the following:
Final submissions are due by 11:59 PM
on Sunday, 06/10.
For the final
project submission, you should submit the following:
Some
notes about the design, implementation and testing of your code: