-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstaircase2edit.js
More file actions
90 lines (66 loc) · 2.91 KB
/
Copy pathstaircase2edit.js
File metadata and controls
90 lines (66 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
export function staircase2edit(dots_diff, lastTrialsCorrect, dir,trialNum)
{
var back1 = lastTrialsCorrect[lastTrialsCorrect.length-1]; // Last trial
var back2 = lastTrialsCorrect[lastTrialsCorrect.length-2]; // Two trials ago
var reverse = false; // Initialize reversal to false
if(back1) // If the last trial was correct
{
if(back2) // AND two trials ago were correct
{
if (trialNum < 7)
dots_diff -= 0.4;
// for 0==trial and for the second half of the practice
else if (trialNum > 6 && trialNum < 12)
dots_diff -= 0.2;
// for the first 5 trials of the practice
else if (trialNum > 11)
dots_diff -= 0.1;
// for next 5 trials of the practice
lastTrialsCorrect[lastTrialsCorrect.length-1] = false;
dir[0] = dir[1]; // Set the direction two trials ago to the direction one trial ago
dir[1] = "up"; // Set the direction one trial ago to up
reverse = check_reversal(dir); // Check if there was a reversal in direction as a result of the step down
}
// If the last trial was correct and two trials ago were wrong, do nothing.
}
else // If the last trial was wrong
{
if (trialNum < 7)
dots_diff += 0.4;
// for 0==trial and for the second half of the practice
else if (trialNum > 6 && trialNum < 12)
dots_diff += 0.2;
// for the first 5 trials of the practice
else if (trialNum > 11)
dots_diff += 0.1;
// for next 5 trials of the practice
dir[0] = dir[1]; // Set the direction two trials ago to the direction one trial ago
dir[1] = "down"; // Set the direction one trial ago to down
reverse = check_reversal(dir); // Check if there was a reversal in direction as a result of the step up
}
// Set limits on dots_diff s.t. it remains in the range of [0,50] inclusive
//if (dots_diff >= 4.25)
// dots_diff = 4.25;
if (dots_diff <= 1){
dots_diff = 1
};
if (dots_diff >= 5){
dots_diff = 5
};
var output =
{
diff: dots_diff,
direction: dir,
reversal: reverse,
stepcount: lastTrialsCorrect
};
return output;
}
// Note that we only call check_reversal when there was a step up or step down
function check_reversal(dir)
{
if(dir[0] !== dir[1]) // If the direction two trials ago is NOT the same direction as the last trial, then there was a reversal
return true;
else // If the direction two trials ago and the last trial are the same direction, no reversal
return false;
}