Created
October 20, 2016 21:36
-
-
Save shauvik/c889dac450c1290537fef02e76a4bba7 to your computer and use it in GitHub Desktop.
Print Autonomous Car Events to console
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
"use strict"; | |
var events = [ | |
"INFO: Car passed on the right", | |
"INFO: Car passed on the left", | |
"SIGN: STOP sign ahead", | |
"SIGN: Signal turned RED", | |
"SIGN: Signal turned GREEN", | |
"WARN: Car stopped ahead", | |
"WARN: Pedestrian crossing ahead", | |
"INFO: Right turn ahead", | |
"INFO: Left turn ahead", | |
"WARN: Speed limit 55mph", | |
"WARN: Speed limit 20mph" | |
]; | |
function getRandomInt(min, max) { | |
min = Math.ceil(min); | |
max = Math.floor(max); | |
return Math.floor(Math.random() * (max - min)) + min; | |
} | |
var outputEvent = function () { | |
// Print event to console | |
console.log(events[getRandomInt(0, 11)]) | |
setTimeout(outputEvent, getRandomInt(500,5000)) | |
} | |
setTimeout(outputEvent, getRandomInt(500,5000)) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment