Published
Edited
Jan 8, 2021
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
t = {
let i = 0;
let fps = 1;
let previousDir = -1;
while (true) {
var p_Direction = 1/avgDelay/fps;
if (d3.randomUniform()()<p_Direction){
previousDir = giveDirection(previousDir, pSwap);
}
yield Promises.delay(1000/fps, ++i);
}
}
Insert cell
giveDirection = function(previousDir, pSwap){
var nextDir = (d3.randomUniform()() < pSwap) ? -1*previousDir : previousDir;
if (soundOn == "true"){
if (nextDir <0){
speechSynth.speak(speech_left);
}else{
speechSynth.speak(speech_right);
}
}
return(nextDir);
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more