ADVANCED EV3 PROGRAMMING LESSON By Seshan Brothers Random Block.

Slides:



Advertisements
Similar presentations
Squaring or Aligning on a Line
Advertisements

BEGINNER EV3 PROGRAMMING Lesson
BEGINNER EV3 PROGRAMMING Lesson
Parallel Beam Synchronization
Menu System ADVANCED EV3 PROGRAMMING LESSON By Droids Robotics
Using the Gyro Sensor and Dealing with Drift
By Mesa Robles Robotworks and Droids Robotics
BEGINNER EV3 PROGRAMMING Lesson
INTERMEDIATE PROGRAMMING LESSON By: Droids Robotics Color Line Follower My Blocks with Inputs: Move Until Black © 2014, Droids Robotics, v. 2.0, Last edit.
ADVANCED EV3 PROGRAMMING LESSON
Gyro Turns ADVANCED EV3 PROGRAMMING LESSON By Droids Robotics
BEGINNER EV3 PROGRAMMING LESSON By: Droids Robotics Topics Covered: Switches.
Calibrating Color Sensors
Alternative Squaring on a Line
ADVANCED EV3 PROGRAMMING LESSON By Droids Robotics 1 Data Logging (Part 2)
BEGINNER EV3 PROGRAMMING Lesson
By Droids Robotics INTERMEDIATE EV3 PROGRAMMING LESSON SIMPLE & OPTIMIZED ULTRASONIC WALL FOLLOW.
By Droids Robotics INTERMEDIATE PROGRAMMIN G LESSON DATA WIRES.
By Droids Robotics INTERMEDIATE PROGRAMMING LESSON BRICK BUTTONS AS SENSORS.
ADVANCED EV3 PROGRAMMING LESSON By Droids Robotics PROPORTIONAL ULTRASONIC WALL FOLLOWER © 2015, EV3Lessons.com, Last edit 11/17/2015.
By Droids Robotics INTERMEDIATE PROGRAMMIN G LESSON COLOR LINE FOLLOWER MY BLOCK WITH INPUTS: MOVE FOR DISTANCE.
ADVANCED EV3 PROGRAMMING LESSON By Droids Robotics © 2015, EV3Lessons.com (last edit 4/9/2015) Stall Detection with code from Hoosier Girlz.
TABLET LESSONS INTRODUCTION TO THE EV3 BRICK AND SOFTWARE By Sanjay and Arvind Seshan.
BEGINNER PROGRAMMING LESSON
BEGINNER PROGRAMMING LESSON
INTERMEDIATE PROGRAMMING LESSON
By Sanjay and Arvind Seshan
Squaring or Aligning on a Line
Proportional Control with the Sound Sensor
Mindsensors PSP-Nx Controller Simon Game
Parallel Beam Synchronization
By Sanjay and Arvind Seshan
SIMPLE & OPTIMIZED ULTRASONIC WALL FOLLOW
INTERMEDIATE PROGRAMMING LESSON
By Sanjay and Arvind Seshan
SIMPLE & OPTIMIZED ULTRASONIC WALL FOLLOW
Gyro Turns © 2015 EV3Lessons.com, Last edit 12/19/2015.
INTERMEDIATE PROGRAMMING LESSON
Parallel Beam Synchronization
INTERMEDIATE PROGRAMMING LESSON
INTERMEDIATE PROGRAMMING LESSON
By Sanjay and Arvind Seshan
Downloading & Uploading Files
BEGINNER PROGRAMMING LESSON
Controlling your quadcopter
By Sanjay and Arvind Seshan
INTERMEDIATE PROGRAMMING LESSON
INTERMEDIATE PROGRAMMING LESSON
By Sanjay and Arvind Seshan
BEGINNER EV3 PROGRAMMING Lesson
INTERMEDIATE PROGRAMMING LESSON
INTERMEDIATE PROGRAMMING LESSON
By Sanjay and Arvind Seshan
By Sanjay and Arvind Seshan
Repeating Actions (Loops)
By Sanjay and Arvind Seshan
BEGINNER PROGRAMMING LESSONS
Downloading & Uploading Files
Proportional Control with the Sound Sensor
INTERMEDIATE PROGRAMMING LESSON
INTERMEDIATE PROGRAMMING LESSON
INTERMEDIATE PROGRAMMING LESSON
INTERMEDIATE PROGRAMMING LESSON
BEGINNER PROGRAMMING LESSONS
By Sanjay and Arvind Seshan
By Sanjay and Arvind Seshan
Menu System.
BEGINNER PROGRAMMING LESSON
INTERMEDIATE PROGRAMMING LESSON
Controlling your quadcopter
Presentation transcript:

ADVANCED EV3 PROGRAMMING LESSON By Seshan Brothers Random Block

 Understand what the random block does  Fix the random block’s “lack of randomness”  Create a game using the random block  Prerequisites: Math Blocks, Data Wires, Variables, Constants, My Blocks with Inputs and Outputs © 2016 EV3Lessons.com, Last edit 6/30/ Lesson Objectives

 Random Block (Numeric Mode)  Two inputs: The minimum and maximum values for the output  It outputs a number between the range specified  The output is only integers (no decimals/fractions)  Random Block (Logic Mode)  One input: The probability of True being the output  It outputs either True of False © 2016 EV3Lessons.com, Last edit 6/30/ What Does the Random Block Do?

 As a replacement for dice  Making your robot unpredictable (e.g. random animal movements)  Making a Game © 2016 EV3Lessons.com, Last edit 6/30/ What Can You Use a Random Block For?

 Make a random number generation system to pick a number between 1 and 3  In a loop, record how many times you get each number using three variables  Run your system 1000 times  Display the results to the screen  What do you notice about the number of times you got #1 vs. #2 vs. #3? © 2016 EV3Lessons.com, Last edit 6/30/ Challenge 1: Is the Random Block Random?

© 2016 EV3Lessons.com, Last edit 6/30/ Challenge 1 Solution Three variables – one for each number Loop 1000 times Wait before exiting Get random number Add 1 to the variable decided by the random block and display to the screen

 You will notice that you got the #1 and #3 about 250 times each. But you got the #2 around 500 times  This is due to a bug in the EV3 that causes the boundary values (1 and 3 in our example) to occur half as often as the middle values (2 in our example). This is true no matter what your range of numbers is.  Can you think of how you might fix this problem to get a better random number? © 2016 EV3Lessons.com, Last edit 6/30/ Challenge 1 Discussion

 Create a new system that is more random in picking a number in Challenge 1 and fixes for the bug in the EV3 code  Record how many times you get each number and compare the results to the previous results © 2016 EV3Lessons.com, Last edit 6/30/ Challenge 2: Fix the “Lack of Randomness”

© 2016 EV3Lessons.com, Last edit 6/30/ Challenge 2 Solution In our solution, we subtract one from the lowest range value and add one to the highest range value, and reject those two values (so that we eliminate using the boundary values) Add and Subtract 1 from the range Get random value If random is a boundary value -> repeat Same code as Challenge 1 except the random block is replaced with our new My Block

 #1, #2 and #3 have an equal chance of being picked at random with our fix © 2016 EV3Lessons.com, Last edit 6/30/ Challenge 2 Discussion

 Make a game that is similar to the Simon Game using your EV3  Unfamiliar with the game? See: Wikipedia Simon Game Wikipedia Simon Game  You can use touch sensors, color sensors, brick buttons (see Simon Game by Damien Kee), or even the Mindsensors PSP-Nx Controller (see the PSP-Nx Controller Lesson in Beyond on EV3Lessons.com)  Our version (see photo on the right) uses four color sensors. The code to play the game can be downloaded on ev3lessons.com © 2016 EV3Lessons.com, Last edit 6/30/ Bonus Challenge: Create a Simon Game

 This tutorial was created by Sanjay Seshan and Arvind Seshan  More lessons at © 2016 EV3Lessons.com, Last edit 6/30/ Credits This work is licensed under a Creative Commons Attribution- NonCommercial-ShareAlike 4.0 International License.Creative Commons Attribution- NonCommercial-ShareAlike 4.0 International License