Programming Robots Musical Chairs. Programming Robots The Game: Version 1:  Wander around the corral until a bright light shines.  Upon seeing the bright.

Slides:



Advertisements
Similar presentations
Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.
Advertisements

Heuristic Search techniques
Brookwood High School Women’s Lacrosse
Amandela Jones Think of all the reasons you shouldn’t go to class. Realize you have a quiz or homework to turn in. Press snooze three more times before.
Procedures There are many procedures that everyone will need to follow in this class. They will help make your life easier and will keep our classroom.
Play To Win Score My Team. Play to Win Play to Win is part of Score My Team and it assigns points based on winning and losing games Play to Win fosters.
Entering the Band Room C Conversation  Voice Level 1 or 2 H Help  Clipboard in the front of the room or wait for class to start and raise your hand A.
Final Project Web Design. Final Project Your robot will be placed in a room with the red cone. Your robot will need to find the cone in the room and run.
Programming Robots Python-Threading. Programming Robots Thread vs Threading Python offers two thread modules  Thread: used up to now; including this.
Sensing the World Intro to Robots.
Harry Potter Scratch Game
Adventures in Animation Harry Potter Game Pranali Choubal Kunal Shaw Barb Ericson Dec 2007.
e-safety and cyber bullying
Intro to Robots Lab 6: Robot Behaviours. Intro to Robots Further Braitenberg Vehicles: Timid: –Moves forward in a straight line –One threshold light sensor.
Cs4411 – Operating Systems Practicum November 4, 2011 Zhiyuan Teo Supplementary lecture 4.
Programming Robots Programming Notes:. Programming Robots Programming a Timed Event Suppose we want a behaviour like the default behaviour to go on but.
Main task -write me a program
Wizard Game: Class-Level Variables in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July
1 ©2006 INSciTE Lab Two Task: Make the program from Lab One (Move forward 5 rotations and turn right 90 degrees) into a MyBlock.
This is Google Drive. It stores all the documents you have made here.
1 - buttons Click “Step Forward” to execute one line of the program. Click “Reset” to start over. “Play,” “Stop,” and “Step Back” are disabled in this.
Your Python program uses the create library. It supplies functions that send commands: to your laptop’s Bluetooth radio, then to the BAM on the Create,
Looping forever Reading/observing sensors (inputs) Reacting to sensors Obstacle sensors.
Overview of Project 1 Slides are available at : Report due next week Matthew Murach.
How to make Space Invaders
Nachos Phase 1 Code -Hints and Comments
Threads. Sequential control Sequential programs: begin execute end At any time, there is a single point of execution Threads: also structured as begin.
Fox and Mule Go To The Library. Fox and Mule went to the library. Only one of them had a good day. Can you tell why only one of them had a good day?
In my classes it will be assumed that everyone wants to be successful. Based on that assumption, each student will be expected to behave in a way that.
Artificial Intelligence in Game Design Behavior Trees.
2 Point Perspective How To Learn the basics of two point perspective with these boxes. © 2012 Lesson Lady
Today’s Agenda 1.Scribbler Program Assignment 1.Project idea due next class 2.Program demonstration due Wednesday, June 3 2.Attendance & lab pair groupings.
1 Day 5 Additional Unix Commands. 2 Important vs. Not Often in Unix there are multiple ways to do something. –In this class, we will learn the important.
Java Threads. What is a Thread? A thread can be loosely defined as a separate stream of execution that takes place simultaneously with and independently.
Procedures There are many procedures that everyone will need to follow in this class. They will help make your life easier and will keep our classroom.
Procedures There are many procedures that everyone will need to follow in this class. They will help make your life easier and will keep our classroom.
CS320n –Visual Programming Introduction to Recursion (Slides 8-1) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
Session 16 Pinball Game Construction Kit:. Pinball Version 1 Replaced the fire button with a mouse event. Multiple balls can be in the air at once. –Uses.
Sistem Operasi © Sekolah Tinggi Teknik Surabaya 1.
How to play chess? By Mervyn George. The Rules of the Game White always move first White always move first You should always play touch a piece move a.
The George Washington University Department of ECE ECE Intro: Electrical & Computer Engineering Dr. S. Ahmadi Class 4/Lab3.
ROOM CHAIR PROCEDURES. 1.BEFORE ROUND 1 BEGINS BEFORE THE ROOM CHAIR MEETING 1.Sign in and choose your event.( Events are on a first-come basis. All rooms.
Games for Changing State. Word Ball  An association game. All players in a circle. One player starts by “tossing” a word to another player. The receiver.
A Principle of Design.  The principle of proximity states that you group related items together, move them physically close to each other, so the related.
How to Go Hide and Seek in the Dark! Ms. Ricks
CSCI 4310 Lecture 5: Steering Behaviors in Raven.
6.2 Classes “ A class is basically a structure with member functions as well as member data. Classes are central to the programming methodology known as.
Chomp. How is the game played Human player goes first choose a square, all to the right and down are “eaten” computer takes a turn whoever is forced to.
ITEC 109 Lecture 18 Looping. Review Questions? Conditionals –if / elif / else –and / or / not.
More on Logic Today we look at the for loop and then put all of this together to look at some more complex forms of logic that a program will need The.
Hamster Transport Vehicle HTV Joey Siracusa Computer Engineering 4/14/2015.
SNIPING TUTORIAL – BY TMAN THE IDEA: The objective of this tutorial is to create a sniping effect. To create the sniping effect you need to create a scope.
Casne.ncl.ac.uk Taking care of the CrumbleBot Please do NOT stress the robot's motors 1.Do NOT push the robot 2.Do NOT hold the.
Creating a Simple Game in Scratch Barb Ericson Georgia Tech May 2009.
A personality for every occasion. High Level Actions  Flee  Follow  Attack  Find Light/Roam  Sit and Wait  Hibernate.
DAY 4. MAKING SOMETHING ‘JUMP’ Simple! Move it a certain amount ‘up’ Glide back to your original spot.
This is a while loop. The code is done while the condition is true. The code that is done is enclosed in { }. Note that this program has three parts: Housekeeping.
You need one printout of your first draft for class today
FLOWCHARTS Part 1.
More (C#) Scripting Day 2, Lesson 1.
You need one printout of your first draft for class today
STOP THINK GO!.
Touch Sensor.
Welcome to the YOUR NAME HERE TOURNAMENT.
Conditions and Ifs BIS1523 – Lecture 8.
CIS 488/588 Bruce R. Maxim UM-Dearborn
My Story Andrew.
Creating a Simple Game in Scratch
Wrapup which is the document write that says the end.
Presentation transcript:

Programming Robots Musical Chairs

Programming Robots The Game: Version 1:  Wander around the corral until a bright light shines.  Upon seeing the bright light move towards that light  In front of the light there will be a black line on the floor; stop when you cross the black line

Programming Robots Musical Chairs: Version 2 Like before, you wander aimlessly within the corral. Avoid obstacles and back away if you stall against anything. Ignore light until a distinctly bright light shines. When the bright light shines move towards it until you cross the black line. In this version you will notify other robots who are doing the same thing that you have crossed the black line. The last robot left who has not yet crossed the black line is the loser of the game and should print out “I Lost”; other robots should print out “I Won” when they cross the black line.

Programming Robots Chatting with other robots # add yourself to chat chat = # get other participant names name = raw_input('Other Participants: '); while name != 'DONE': mc.addToPlayerList(name.lower())‏ maxRobotCount = maxRobotCount + 1 name = raw_input('Other Participants (DONE to finish): '); # if you cross the black line tell everyone you did. L= self.getLine()‏ if L[0] == 1 or L[1] == 1: for p in self.playerList: self.myChat.send(p,'Done')‏ print 'I won'

Programming Robots Issues: This program must be threaded. This is because the robot needs to wander around doing its thing while the main program waits for a chat message to arrive. # robot sets mc.STOP when it has crossed the black line messages = chat.receive()‏ while len(messages) == 0 or mc.STOP != 0: time.sleep(1)‏ messages = chat.receive()‏ if len(messages) > 0 : print messages

Programming Robots Main program: Create a robot that extends MyScribbler and threading.Thread (Remember you must implement the run() method now)‏ Get a list of other players Connect to chat Start your thread Wait for messages and as they arrive increment a counter that allows the robot to see if it is the last to cross the line Terminate when the robot has stopped running; either because it crossed the line or because it is the only robot not to cross the line.

Programming Robots The Robot: How to make our normal robot object run in a separate thread. From threading import Thread class MCRobot (MyScribbler,Thread):... def run(self): self.main(120)‏

Programming Robots Methods Needed: checkLine: checks if you crossed the black line; sends out messages to other players and stops the robot and its thread; fails otherwise checkLight: checks if light has suddenly gotten brighter; if so, directs robot to get closer to the light; fails otherwise checkMsgs: Determines if you have received n-1 messages where n is the number of participating robots (including yourself). Fails unless you are the last robot, in which case it succeeds and directs you to a “terminating” method. checkStall: checks if you are stalled; if so reverses the direction of the robot. checkObstacle: checks if obstacle in view; if so, alters course.

Programming Robots Methods Needed: dflt: This method sets a random behaviour that will run for a few seconds before being replaced by another random behaviour. We can keep track of how long to implement a specific behaviour by having this method change the behaviour only once every 10 (for example) times it is called. def dflt(self): if self.count < 10: self.count = self.count + 1 else: self.count = 0 self.T = random.random()*random.choice([-1,1])‏ self.R = random.random()*random.choice([-1,1])‏ return [True,self.T,self.R,self.move]

Programming Robots Strategy: As long as the light is more or less ambient you should:  Ignore any black lines  Keep your eye open for a light change  Avoid obstacles  Back away from something you have hit  Wander around randomly.  Watch for messages Once you notice the presence of a bright light you should:  Ignore everything but the bright light source  Keep your eye open for the black line  Continue to watch for messages