Aleksandar Kuzmanovic Northwestern University

Slides:



Advertisements
Similar presentations
Mike Scott University of Texas at Austin
Advertisements

KompoZer. This is what KompoZer will look like with a blank document open. As you can see, there are a lot of icons for beginning users. But don't be.
Editing Your Faculty Homepage  This tutorial will go through the steps for editing your Faculty homepage.  Thank you to Ryan Vyborny for letting me use.
Lets Play Catch! Keeping Score in Alice By Francine Wolfe Duke University Professor Susan Rodger May 2010.
Chapter 6 Photoshop and ImageReady: Part II The Web Warrior Guide to Web Design Technologies.
Projects 3&4: PyRobot & Picobot
EECS 110: Lec 16: Projects Aleksandar Kuzmanovic Northwestern University
CSE 115 Week 12 March 31 – April 4, Announcements March 31 – Exam 8 March 31 – Exam 8 April 6 – Last day to turn in Lab 7 for a max grade of 100%,
Maze Running Robots EGR106 Project Spring Project Goal Computer control (through a Matlab program) of a Lego robot to: 1.Explore a maze (start to.
Week 4-5 Java Programming. Loops What is a loop? Loop is code that repeats itself a certain number of times There are two types of loops: For loop Used.
1 iSee Player Tutorial Using the Forest Biomass Accumulation Model as an Example ( Tutorial Developed by: (
EECS 110: Lec 2: What is Programming?
Making a Boat Racing Game in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2010.
Data, graphics, and programming in R 28.1, 30.1, Daily:10:00-12:45 & 13:45-16:30 EXCEPT WED 4 th 9:00-11:45 & 12:45-15:30 Teacher: Anna Kuparinen.
Bill's Amazing Content Rotator jQuery Content Rotator.
Introduction to Arrays. definitions and things to consider… This presentation is designed to give a simple demonstration of array and object visualizations.
An Introduction to Designing and Executing Workflows with Taverna Aleksandra Pawlik materials by: Katy Wolstencroft University of Manchester.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
How to link the robot and the computer (Bluetooth) How to turn on and off How to connect the adaptor Fluke card connection Sec Getting Started How.
Making Python Pretty!. How to Use This Presentation… Download a copy of this presentation to your ‘Computing’ folder. Follow the code examples, and put.
EECS 110 Projects 1&2 Juan Li – Project 1 Ning Xia – Project 2.
Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room.
EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University
Introduction to Programming Python Lab 7: if Statement 19 February PythonLab7 lecture slides.ppt Ping Brennan
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Into 3D with VPython Deepak Mishra MS-IT IIIT Hyderabad.
JavaScript Part 1 Introduction to scripting The ‘alert’ function.
Creating a UFO Rescue Game in Alice
Development Environment
Create a Halloween Computer Game in Scratch
CHAPTER 10 JAVA SCRIPT.
MOM! Phineas and Ferb are … Aims:
CSCI 203: Introduction to Computer Science I
Introduction to Programming
What you asked me to teach…
Java on the LEGO Mindstorms EV3
Understanding Communication with a Robot? Activity (60 minutes)
Getting Started with R.
EECS 110: Lec 2: What is Programming?
Editing Your Faculty Homepage
Introduction to Programming
Software Testing With Testopia
PowerPoint: Tables and Charts
Introduction To Flowcharting
Introduction to Events
Creating a UFO Rescue Game in Alice
Engineering Innovation Center
This week's classes Connect 4 aiMove
This week's classes Connect 4 Player
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
Prof. Neary Adapted from slides by Dr. Katherine Gibson
Introduction to Programming
T. Jumana Abu Shmais – AOU - Riyadh
Introduction to TouchDevelop
Introduction to Programming
Go to =>
Using Lists and Functions to Create Dialogue
CISC101 Reminders All assignments are now posted.
Flowcharts and Pseudo Code
Picobot Challenge! inspiration? walls Picobot area not covered (yet!)
Tonga Institute of Higher Education IT 141: Information Systems
Tonga Institute of Higher Education IT 141: Information Systems
creating a ecosystems model in net logo
Introduction to Programming
EECS 110: Lec 12: Mutable Data
Creating a Simple Game in Scratch
Getting started with LEGO EV3 Mindstorms software
CSCI 203: Introduction to Computer Science I
An Introduction to Designing and Executing Workflows with Taverna
Ionut Trestian Northwestern University
Presentation transcript:

Aleksandar Kuzmanovic Northwestern University EECS 110: Lec 16: Projects Aleksandar Kuzmanovic Northwestern University http://networks.cs.northwestern.edu/EECS110-s17/

The Rest of the Class… the view from here… Wed., 5/24 – review for Final Exam Fri., 5/26 – project recitations by TAs (10am) Fri., 5/26 – project recitations (Wilkinson Lab) (1-3pm) Sun., 5/28 – Interim milestones due (11:59pm) Tue., 5/30 – project recitations (Wilkinson Lab) (9-12) Wed., 5/31 – Final Exam Fri., 6/2 – Final exam solutions (10am) Sun., 6/4 – Final projects due (11:59pm)

vPool Text Clouds pyRobot picobot EECS 110 today… Today in EECS 110 All about the EECS 110 projects! vPool Text Clouds pyRobot picobot

Final projects Working solo or duo is OK open-ended Final assignment comprehensive more choice… Working solo or duo is OK Pairs need to share the work equally and together

Billiard Ball (at least 2) Option #1, vPool Cue ball Table Billiard Ball (at least 2) Cue (optional) Hole (optional)

Option #1: virtual pool Easily installable for windows… VPython? Not (really) installable for the Mac www.vpython.org A simple example from visual import * c = cylinder() What's visual? What's c?

What's the if/else doing? Option #1: virtual pool from visual import * floor = box( pos=(0,0,0), length=4, height=0.5, width=4, color=color.blue) ball = sphere( pos=(0,4,0), radius=1, color=color.red) ball.velocity = vector(0,-1,0) dt = 0.01 while True: rate(100) ball.pos = ball.pos + ball.velocity*dt if ball.y < ball.radius: ball.velocity.y = -ball.velocity.y else: ball.velocity.y = ball.velocity.y - 9.8*dt How many classes? How many objects? data members? What's the if/else doing?

Option #1: virtual pool Phunky Fisicks is welcome! Collisions with walls? Collisions with other pool balls? Pockets?

Option #1: virtual pool To start, just design your table, try to construct a scene which consists of the following objects: - table – made of walls, box objects - holes (optional) – use sphere objects - cueBall – another sphere -cue (optional) – cylinder object - billiard balls (at least 2) – sphere objects - you also should take a look at label objects to display game texts After you place all the objects you should have something similar to …

Option #1: virtual pool

Option #1: virtual pool Your main game loop should basically consist of: while gameOver == False: m = scene.mouse.getclick() #click event – cue hit # get mouse position and give the cue ball a direction # based on that # perform movement of the cue ball as shown before # handle collisions between different balls and # between balls and walls # check if game is over – when all balls have # been put in

Option #1: virtual pool Directing the cue ball: temp = scene.mouse.project(normal=(0,1,0), point=(0,-side,0)) this gets a vector with the projection of the mouse on the pool table. if temp: # temp is None if no intersection with pool table cueBall.p = norm(temp – cueBall.pos) The cue ball direction is now given by the vector that results from the difference of the point where we clicked projected on the pool table and the actual position of the cue ball So clicking in front of the cue ball will make it go into that direction.

Option #1: virtual pool Moving the cue ball: dt = 0.5 t = 0.0 while dt > 0.1: sleep(.01) t = t + dt dt = dt-dt/200.0 cueBall.pos = cueBall.pos + (cueBall.p/cueBall.mass)*dt We basically start with a bigger movement increment (0.5), move the ball in the direction we computed with the specific increment. Each time decrease the increment to account for drop in velocity. Stop at some point (0.1)

Option #1: virtual pool Handling collisions: With walls: if not (side > cueBall.x > -side): cueBall.p.x = -cueBall.p.x if not (side > cueBall.z > -side): cueBall.p.z = -cueBall.p.z When hitting wall, change directions

Option #1: virtual pool When is a ball in? if math.sqrt(math.pow(abs(ball1.x-hole1.x),2) + math.pow(abs(ball1.z-hole1.z),2)) <= hole1.radius*2: ballin = 1 ball1.visible = 0 ball1.y = 50 Holes are just spheres so we determine intersection between ball and hole same way as for different balls. When ball is in we do a few things: Signal that a ball has been put in (might be useful later) Make the specific ball invisible Move it out of the way

Option #1: virtual pool Handling the game logic? Need a way to keep track of players taking turns. Suggestion: use a simple variable for that which changes after every hit (take into account if balls have been sunk or not) Players need to be aware of the game flow, so show labels that display which player has turn, when the game was won and by whom The game is finished when all the balls are in, that is when all the balls are invisible. You can use that for check.

Project #2: text clouds tag cloud

Project #2: text clouds text cloud Summary of the words in a body of text, sized and painted according to their frequency. Demo: http://blue.cs.northwestern.edu/~ionut/index.html on: http://www.gutenberg.org/files/74/74-h/74-h.htm http://www.gutenberg.org/files/76/76-h/76-h.htm

Text-cloud history http://chir.ag/phernalia/preztags/

Project #2: text clouds From text… Start with entered webpage (URL) Read in text Create list of words out of text "Clean" the words "Stem" the words Count the words Return a string with frequencies Add advanced features… Stem the words: remove the, a, or faster -> fast … to cloud

Text Clouds, an example http://networks.cs.northwestern.edu/EECS110-s17/projects/ project2/page1.htm ignore this link for now Spamming spammers spammed spam. Spam spam spam! I love spam! Page 2 ['spamming', 'spammers', spammed', 'spam.', 'spam', 'spam', 'spam!', 'I', 'love', 'spam!', 'page', '2'] ['spamming', 'spammers', spammed', 'spam', 'spam', 'spam', 'spam', 'love', 'spam', 'page', '2'] ['spam', 'spam', spam', 'spam', 'spam', 'spam', 'spam', 'love', 'spam', 'page', '2']

Project #2: text clouds An Approach Develop the basic application the usual way (IDLE) Use our code to read HTML, but don't bother writing it yet… Once you have things working, try writing HTML/searching beyond depth 1/etc (NEXT SLIDE) Once you have everything working, transfer your .py files to your webspace. Set up the HTML wrapper files & go! Personalize! The project has a number of references…

Project #2: searching beyond depth 1 An Approach (1/2) def mtcURL(url): toVisit[url] = 0 #toVisit is a dictionary visited[url] = 1 #visited is a dictionary returnText = '' while len(toVisit) != 0: [url, depth] = toVisit.popitem() [textSite, listUrls] = getHTML(url) def mtcURL(url):     toVisit[url] = 0 #toVisit is a dictionary /a dictionary that contains the list of URL's to visit. The value in toVisit is actually the depth at which the url was found     visited[url] = 1 #visited is a dictionary /a dictionary of urls that were visited before     returnText = '' /the text we will return       while len(toVisit) != 0: /while we still have urls to visit        [url, depth] = toVisit.popitem() /pop one url and the depth        [textSite, listUrls] = getHTML(url) /get the text and the list of urls from that website

Project #2: searching beyond depth 1 An Approach (2/2) … for urlItem in listUrls: if visited.has_key(urlItem) == False \ and depth < DEPTH: visited[urlItem] = 1 toVisit[urlItem] = depth + 1 wordList = textSite.split()   for urlItem in listUrls: /browse the urls in the list of urls returned     if visited.has_key(urlItem) == False \     and depth < DEPTH: /check if we already visited the url and also if the depth is lower than what we are willing to go        visited[urlItem] = 1 /put as visited        toVisit[urlItem] = depth + 1 /increase the depth wordList = textSite.split()  /extract the words from the text.

Goal: get from Pt A to Pt B pyRobot option #3 Pt A 2d Roomba simulator Goal: get from Pt A to Pt B Pt B 25

pyRobot option #3 IMPORTANT: ROBOT CAN START ANYWHERE! IMPORTANT: Pt A IMPORTANT: ROBOT CAN START ANYWHERE! Pt B IMPORTANT: GOAL CAN BE ANYWHERE

Project #3: pyRobot while True: SENSE [x,y,thd], bump = self.getData() 27

Robot control continuously runs three things: Project #3: pyRobot while True: Robot control continuously runs three things: SENSE PLAN [x,y,thd], bump = self.getData() if bump[0] == True or bump[1] == True: print 'BUMP!', print ' [Left bump sensor:', bump[0], '] ', print ' [Right bump sensor:', bump[1], '] ' robotTask = STOP STOP is one of the robot's states. Every 40th of a second, the robot runs through this loop, sets the robot's state and sets the velocities accordingly. Don't sleep! 28

Robot control continuously runs three things: Project #3: pyRobot while True: Robot control continuously runs three things: SENSE PLAN ACT [x,y,thd], bump = self.getData() if bump[0] == True or bump[1] == True: print('BUMP!’) print(' [Left bump sensor:', bump[0], '] ‘) print(' [Right bump sensor:', bump[1], '] ’) robotTask = STOP STOP is one of the robot's states. Every 40th of a second, the robot runs through this loop, sets the robot's state and sets the velocities accordingly. Don't sleep! if robotTask == STOP: self.setVels(0,0) robotTask = KBD 29

Project #3: pyRobot BASIC ROBOT COMMANDS: STOP: self.setVels(0,0) GO FORWARD: self.setVels(FV,0) GO BACKWARD: self.setVels(-FV,0) GO CLOCKWISE: self.setVels(0,RV) GO COUNTERCLOCKWISE: self.setVels(0,-RV)

Project #3: pyRobot To make the robot go forward a set amount use The max forward velocity: FV Example... TIME_ONE_CIRCLE_OVER = RADIUS*2 / FV the key point is that you keep moving by assigning TIMERS. You basically tell the robot when to stop. if state==DO_GO_LEFT_LITTLE: #FIGURE OUT HOW TO TRAVEL pause_stop = time.time() + TIME_ONE_CIRCLE_OVER State = GOING_LEFT_LITTLE if pause_stop > time.time() and state==GOING_LEFT_LITTLE: self.setVels(0,0) #STOP! elif state==GOING_LEFT_LITTLE: self.setVels(FV,0) #KEEP GOING!

Project #3: pyRobot To rotate the robot use the Max Rotational Velocity: RV Example... TIME_ROTATE_90_DEGREES = 90.0 / RV if state==DO_ROTATE_LEFT_DOWN: #c-cwise #FIGURE OUT HOW LONG TO ROTATE pause_stop = time.time() + TIME_ROTATE_90_DEGREES State = ROTATING_LEFT_DOWN if pause_stop > time.time() and state==ROTATING_LEFT_DOWN: self.setVels(0,0) #STOP! elif state==ROTATING_LEFT_DOWN: self.setVels(0,-RV) #KEEP GOING!

Project #3: pyRobot One way to traverse the space is GO DOWN UNTIL BUMP SOMETHING, GO RIGHT A LITTLE GO UP UNTIL BUMP SOMETHING GO RIGHT A LITTLE DO THIS UNTIL HIT CORNER THEN REVERSE....

Maps Required We may test on any map with rectangular objects are set at the very bottom of the main.py file: Required We may test on any map with rectangular objects 34

Project #4: Picobot Returns!

Project 4: Picobot Basic idea: implement Picobot (the homework problem from Week 1) Picobot is a finite-state machine! Requirements: Graphical output Read Picobot program from a file* Read maze description from a file Track visited/unvisited squares Prohibit illegal moves

Reading a Picobot program from a file map3.txt contains solution to the HW0 problem Syntax: 0 xxxx -> N 1 0 Nxxx -> S 2 0 xExx -> W 3 0 xxWx -> E 4 0 xxxS -> N 1 0 xEWx -> N 1 ...

Reading a Picobot program from a file Importing map3.txt into the program 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

Graphics Library Graphics22.py (recommended)

Graphics Library Graphics22.py (recommended) You can use others as well: E.g., vPython

Plotting a window from graphics22 import * def main(): win = GraphWin("MyWindow", 400, 400)

Plotting a yellow rectangle from graphics22 import * def main(): win = GraphWin("MyWindow", 400, 400) p1 = Point(0,355) p2 = Point(400,400) rec1 = Rectangle(p1,p2) rec1.setFill("yellow“) rec1.setOutline("yellow") rec1.draw(win)

Plotting an Exit button … #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)

Accepting a mouse click … #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“)

Accepting a mouse click … #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“)

Example Functions createOneRow( n ) createBoard(width, height) done(X) #end of game: all visited in matrix X next_state(Cstate,Icurr,Jcurr,X,STATE) next_direction(Cstate,Icurr,Jcurr,X,DIRECTION) main(nameOfFile)

What’s due? milestone.txt milestone.py Sun., 5/28 – Interim milestones due (11:59 pm) milestone.txt milestone.py Name(s) Project chosen Description of User Interface What is your approach & plan? Classes and functions with docstrings 60-80+ lines of working, tested code

What’s due? final.txt final.py A final milestone Sun., 6/4 – Final projects due (11:59 pm) final.txt final.py Name(s) Project chosen Description of User Interface How do we run / play your project? What features did you implement? What was your approach & plan? Classes and functions with docstrings Working, tested code A final milestone

This and next week Wed., 5/24 – review for Final Exam Fri., 5/26 – project recitations by TAs (10am) Fri., 5/26 – project recitations (Wilkinson Lab) (1-3pm) Sun., 5/28 – Interim milestones due (11:59pm) Tue., 5/30 – project recitations (Wilkinson Lab) (9-12) Wed., 5/31 – Final Exam Fri., 6/2 – Final exam solutions (10am) Sun., 6/4 – Final projects due (11:59pm)

Be inventive – we will reward that! Good luck with the projects! Ask TAs for help Good luck with the projects!