in datawig-js/static/jspsych-6.1.0/plugins/jspsych-rdk.js [994:1078]
function updateDots() {
//Cycle through to the next set of dots
if (currentSetArray[currentApertureNumber] == nSets - 1) {
currentSetArray[currentApertureNumber] = 0;
} else {
currentSetArray[currentApertureNumber] = currentSetArray[currentApertureNumber] + 1;
}
//Load in the current set of dot array for easy handling
var dotArray = dotArray2d[currentSetArray[currentApertureNumber]];
//Load in the current set of dot array for easy handling
//dotArray = dotArray2d[currentSetArray[currentApertureNumber]]; //Global variable, so the draw function also uses this array
//Loop through the dots one by one and update them accordingly
for (var i = 0; i < nDots; i++) {
var dot = dotArray[i]; //Load the current dot into the variable for easy handling
//Generate a random value
var randomValue = Math.random();
//Update based on the dot's update type
if (dot.updateType == "constant direction") {
dot = constantDirectionUpdate(dot);
} else if (dot.updateType == "opposite direction") {
dot = oppositeDirectionUpdate(dot);
} else if (dot.updateType == "random position") {
dot = resetLocation(dot);
} else if (dot.updateType == "random walk") {
dot = randomWalkUpdate(dot);
} else if (dot.updateType == "random direction") {
dot = randomDirectionUpdate(dot);
} else if (dot.updateType == "constant direction or opposite direction or random position") {
//Randomly select if the dot goes in a constant direction or random position, weighted based on the coherence level
if (randomValue < coherence) {
dot = constantDirectionUpdate(dot);
} else if(randomValue >= coherence && randomValue < (coherence + oppositeCoherence)){
dot = oppositeDirectionUpdate(dot);
} else {
dot = resetLocation(dot);
}
} else if (dot.updateType == "constant direction or opposite direction or random walk") {
//Randomly select if the dot goes in a constant direction or random walk, weighted based on the coherence level
if (randomValue < coherence) {
dot = constantDirectionUpdate(dot);
} else if(randomValue >= coherence && randomValue < (coherence + oppositeCoherence)){
dot = oppositeDirectionUpdate(dot);
} else {
dot = randomWalkUpdate(dot);
}
} else if (dot.updateType == "constant direction or opposite direction or random direction") {
//Randomly select if the dot goes in a constant direction or random direction, weighted based on the coherence level
if (randomValue < coherence) {
dot = constantDirectionUpdate(dot);
} else if(randomValue >= coherence && randomValue < (coherence + oppositeCoherence)){
dot = oppositeDirectionUpdate(dot);
} else {
dot = randomDirectionUpdate(dot);
}
}//End of if dot.updateType == ...
//Increment the life count
dot.lifeCount++;
//Check if out of bounds or if life ended
if (lifeEnded(dot)) {
dot = resetLocation(dot);
}
//If it goes out of bounds, do what is necessary (reinsert randomly or reinsert on the opposite edge) based on the parameter chosen
if (outOfBounds(dot)) {
switch (reinsertType) {
case 1:
dot = resetLocation(dot);
break;
case 2:
dot = reinsertOnOppositeEdge(dot);
break;
} //End of switch statement
} //End of if
} //End of for loop
} //End of updateDots function