我想在循环中编码,如果精确度=1,那么实验应该显示一个信息文本,说明他们的选择是正确的,反之亦然,如果精确度=0。在按enter键继续之后,它应该返回到原始循环,然后重复自身。你知道吗
我该怎么做?你知道吗
# make a function for one trial of colour practice
def con1_trial(self):
global trial
global key
trial += 1
target_colour = random.choice(colours)
# show one square with gouloboy colour in top right corner of screen
col3rec.setFillColor(target_colour)
col3rec.draw()
sinij_text.draw()
boy_text.draw()
# draw and flip
win.flip()
key, test_answer = event.waitKeys(keyList=['right', 'left', 'escape'], timeStamped = True)[0]
for colour_pair in colour_pairs:
if test_colour == colours[0] and key == "left":
accuracy = 1
elif test_colour == colours[1] and key == "right":
accuracy = 1
elif key == 'escape':
core.quit()
else: accuracy = 0
# records time in ms
rt = (test_answer - test_start)*1000
return accuracy, rt
试用的定义是:挑选一种颜色,画一幅画,等待输入,然后记录答案。 这里有一些伪代码
要使代码整洁,首先在脚本的前面定义一个反馈函数:
在代码后面添加以下内容:
。。。有正确的压痕。我总是有某种功能来显示信息。在
show_feedback
中,您还可以添加一些内容以退出实验:相关问题 更多 >
编程相关推荐