-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExperimentController.cpp
179 lines (154 loc) · 7.33 KB
/
ExperimentController.cpp
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#include "ExperimentController.h"
ExpirementController::ExpirementController(QApplication* a, QString id, bool colored_series, double dist, bool is_hand, double circle_angle, double text_angle, double shift_angle)
: experiment_block(this, id, colored_series, dist, is_hand, circle_angle, text_angle, shift_angle)
, is_colored(colored_series)
{
formed_for_experiment.reserve(3*8*10);
QTextCodec *codec = QTextCodec::codecForName("Windows-1251");
common_words.reserve(10);
common_words.push_back(CategorialWord(codec->toUnicode("îáëàäàòü"), colored_series ? (Red | Common): Common));
common_words.push_back(CategorialWord(codec->toUnicode("óñèëèòü"), colored_series ? (Red | Common): Common));
common_words.push_back(CategorialWord(codec->toUnicode("âûó÷èòü"), colored_series ? (Red | Common): Common));
common_words.push_back(CategorialWord(codec->toUnicode("óâëå÷ü"), colored_series ? (Red | Common): Common));
common_words.push_back(CategorialWord(codec->toUnicode("óäåëèòü"), colored_series ? (Red | Common): Common));
common_words.push_back(CategorialWord(codec->toUnicode("âåðèòü"), colored_series ? (Green | Common): Common));
common_words.push_back(CategorialWord(codec->toUnicode("ðàçâèòü"), colored_series ? (Green | Common): Common));
common_words.push_back(CategorialWord(codec->toUnicode("æåëàòü"), colored_series ? (Green | Common): Common));
common_words.push_back(CategorialWord(codec->toUnicode("îáåùàòü"), colored_series ? (Green | Common): Common));
common_words.push_back(CategorialWord(codec->toUnicode("âîçìóòèòü"), colored_series ? (Green | Common): Common));
hand_words.reserve(10);
hand_words.push_back(CategorialWord(codec->toUnicode("áðîñàòü"), colored_series ? (Red | Hand) : Hand));
hand_words.push_back(CategorialWord(codec->toUnicode("âÿçàòü"), colored_series ? (Red | Hand) : Hand));
hand_words.push_back(CategorialWord(codec->toUnicode("äåðæàòü"), colored_series ? (Red | Hand) : Hand));
hand_words.push_back(CategorialWord(codec->toUnicode("êèäàòü"), colored_series ? (Red | Hand) : Hand));
hand_words.push_back(CategorialWord(codec->toUnicode("êðàñèòü"), colored_series ? (Red | Hand) : Hand));
hand_words.push_back(CategorialWord(codec->toUnicode("ðóáèòü"), colored_series ? (Green | Hand) : Hand));
hand_words.push_back(CategorialWord(codec->toUnicode("õâàòàòü"), colored_series ? (Green | Hand) : Hand));
hand_words.push_back(CategorialWord(codec->toUnicode("ðåçàòü"), colored_series ? (Green | Hand) : Hand));
hand_words.push_back(CategorialWord(codec->toUnicode("îùóïûâàòü"), colored_series ? (Green | Hand) : Hand));
hand_words.push_back(CategorialWord(codec->toUnicode("êàñàòüñÿ"), colored_series ? (Green | Hand) : Hand));
leg_words.reserve(10);
leg_words.push_back(CategorialWord(codec->toUnicode("áåæàòü"), colored_series ? (Red | Leg) : Leg));
leg_words.push_back(CategorialWord(codec->toUnicode("âñòàâàòü"), colored_series ? (Red | Leg) : Leg));
leg_words.push_back(CategorialWord(codec->toUnicode("ïèíàòü"), colored_series ? (Red | Leg) : Leg));
leg_words.push_back(CategorialWord(codec->toUnicode("ïðèñåäàòü"), colored_series ? (Red | Leg) : Leg));
leg_words.push_back(CategorialWord(codec->toUnicode("ïðûãàòü"), colored_series ? (Red | Leg) : Leg));
leg_words.push_back(CategorialWord(codec->toUnicode("òîïàòü"), colored_series ? (Green | Leg) : Leg));
leg_words.push_back(CategorialWord(codec->toUnicode("õîäèòü"), colored_series ? (Green | Leg) : Leg));
leg_words.push_back(CategorialWord(codec->toUnicode("øàãàòü"), colored_series ? (Green | Leg) : Leg));
leg_words.push_back(CategorialWord(codec->toUnicode("òîïòàòü"), colored_series ? (Green | Leg) : Leg));
leg_words.push_back(CategorialWord(codec->toUnicode("øàðêàòü"), colored_series ? (Green | Leg) : Leg));
FormExperimentSet();
connect(&experiment_block, SIGNAL(CloseAll()), a, SLOT(quit()));
std::random_device rd;
std::mt19937 gen(rd());
std::bernoulli_distribution d(0.5);
if (d(gen))
{
std::swap(hk_design[0], hk_design[1]);
}
experiment_block.SetHandKind(hk_design[0]);
/*
if (dis(gen)) {
std::swap(mvngtm_design[0], mvngtm_design[1]);
}
experiment_block.SetInterval(mvngtm_design[0]);
*/
}
void ChangeColor(QList<CategorialWord> & list)
{
uint tmp;
for (auto it = list.begin(); it != list.end(); ++it)
{
tmp = (*it).category;
(*it).category = (tmp & Red) ? ((tmp & 7) | Green) : ((tmp & 7) | Red);
}
}
void ExpirementController::FormExperimentSet()
{
formed_for_experiment.clear();
QList<CategorialWord> tmp;
tmp.reserve(30);
std::srand(time(0));
for (int i = 0; i < 8; ++i)
{
tmp.clear();
if (is_colored)
{
ChangeColor(hand_words);
ChangeColor(leg_words);
ChangeColor(common_words);
}
std::random_shuffle(hand_words.begin(), hand_words.end());
std::random_shuffle(leg_words.begin(), leg_words.end());
std::random_shuffle(common_words.begin(), common_words.end());
tmp += hand_words;
tmp += leg_words;
tmp += common_words;
std::random_shuffle(tmp.begin(), tmp.end());
formed_for_experiment += tmp;
}
/*
formed_for_experiment.clear();
QTextCodec *codec = QTextCodec::codecForName("Windows-1251");
formed_for_experiment.push_back(CategorialWord(codec->toUnicode("îáëàäàòü"), Common));
formed_for_experiment.push_back(CategorialWord(codec->toUnicode("óñèëèòü"), Hand));
formed_for_experiment.push_back(CategorialWord(codec->toUnicode("âûó÷èòü"), Leg));
formed_for_experiment.push_back(CategorialWord(codec->toUnicode("óâëå÷ü"), Common));
formed_for_experiment.push_back(CategorialWord(codec->toUnicode("óäåëèòü"), Common));
formed_for_experiment.push_back(CategorialWord(codec->toUnicode("âåðèòü"), Common));
formed_for_experiment.push_back(CategorialWord(codec->toUnicode("ðàçâèòü"), Common));
formed_for_experiment.push_back(CategorialWord(codec->toUnicode("æåëàòü"), Common));
formed_for_experiment.push_back(CategorialWord(codec->toUnicode("îáåùàòü"), Common));
formed_for_experiment.push_back(CategorialWord(codec->toUnicode("âîçìóòèòü"), Common));
*/
show_idx = 0;
}
void ExpirementController::EvaluateExperiment()
{
experiment_block.SetText(formed_for_experiment[show_idx].word, formed_for_experiment[show_idx].category);
show_idx++;
experiment_block.show();
}
void ExpirementController::NextTrial(bool failed)
{
if (failed)
{
// backup failed trial
int idx = dis(gen) * (formed_for_experiment.size() - show_idx) + show_idx;
formed_for_experiment.insert(idx, formed_for_experiment[std::max(show_idx-1, 0)]);
}
if (show_idx != formed_for_experiment.size())
{
experiment_block.SetText(formed_for_experiment[show_idx].word, formed_for_experiment[show_idx].category);
show_idx++;
experiment_block.SetBlockState(ShowingCentralCircle);
}
else
{
if (hk_idx == 1 /*&& mvngtm_idx == 1*/) {
experiment_block.SetBlockState(FinishExperiment);
return;
}
else
{
/*
if (hk_idx == 0 && mvngtm_idx == 0)
{
experiment_block.SetInterval(mvngtm_design[++mvngtm_idx]);
}
else if (hk_idx == 0 && mvngtm_idx == 1)
{
experiment_block.SetHandKind(hk_design[++hk_idx]);
experiment_block.SetInterval(mvngtm_design[--mvngtm_idx]);
}
else if (hk_idx == 1 && mvngtm_idx == 0)
{
experiment_block.SetInterval(mvngtm_design[++mvngtm_idx]);
}*/
experiment_block.SetHandKind(hk_design[++hk_idx]);
}
FormExperimentSet();
experiment_block.SetBlockState(DisplayTextMessage);
}
}