the simmon effect(in psychology) :build the function of subject_information(modify the experiment programme),before we begin the experiment
#the real experiment for simon effect
#load the library which is our need
import pygame
import sys
import random
from pygame.locals import * #creat the subject information function
def sub_info():
sub_ID = input("please input your number: ")
sub_name = input("please input your name: ")
sub_male = input("please input your male: ")
sub_age = input("please input your age: ")
return sub_ID, sub_name,sub_male,sub_age
#the variable result will be a tuple
result = sub_info()
#turn the tuple to a list
result = list(result) pygame.init()
win = pygame.display.set_mode((800,600),DOUBLEBUF|HWSURFACE)
left = (200,300)
right = (600,300)
red =(255,0,0)
blue = (0,0,255)
black = (0,0,0) #wait for the pressed key def wait4key(duration,key_list):
"""the function is to wait for subject to press the right key , and the experient will continue untill the\
subject press the key
duration : the time which is the subject wait to press the key ,if the time is too long ,the experiment will\
continue automaticly.
key_list: the key which the subject need to press to continue the experiment, and the key_list must \
be a list such as [K_A,K_/]""" fake_bool =False
time_out = False #empty the event before
pygame.event.clear() #use for count the time
start_time = pygame.time.get_ticks() #if the subject does not press the right key, he will in the while loop all the time untill the duration is exhausted
while not (fake_bool or time_out):
end_time = pygame.time.get_ticks()
#if the duration is too long , the experiment will continue
if end_time - start_time > duration:
time_out = True
#if subject press the right key ,the experimet will continue
for i in pygame.event.get():
if i.type ==KEYDOWN:
if i.key in key_list:
#prepare for the result of the function
response_time = pygame.time.get_ticks()
key_name = pygame.key.name(i.key)
#if has the right key ,the loop will quit
fake_bool = True
#in the end, if subject press the key ,we will collect the time , and the name of the key
if fake_bool:
return start_time, response_time, key_name
#the purpose of the next line is stay the same with the result
else:
return start_time, None, None #experiment for 10 times #creat the list
#L mean left ,R mean right , RE mean the color red, BL mean the color blue
lis = [ ["L","RE","Z"],
["L","BL","/"],
["R","RE","Z"],
["R","BL","/"]] #creat a function to ran one trial
def one_trial_list(pars):
#the parameters must be a list which contains the location, color ,right response of the stimuli and the the sequence of the element of parameters should not change"""
global left
global right
global red
global blue
global black
loc,col,ress=pars
if loc =="L":
pos = left
if loc =="R":
pos = right
if col =="BL":
color = red
if col == "RE":
color = blue win.fill(black)
pygame.draw.circle(win,color,pos,20,0)
pygame.display.flip()
result1 = wait4key(2000,[K_z,K_SLASH])
#turn the result1 which is the result of the wait4key function to a list
result1 = list(result1)
print(result + result1) #random our lis which contains four trails
lis1 = lis*2
random.shuffle(lis1) #run four trials
for i in lis1:
one_trial_list(i) #when one trail end ,fill the window black again
win.fill(black)
pygame.display.flip()
pygame.time.delay(500)
pygame.quit()
sys.exit()
the function sub_info is the function which is added based on the last experiment programme
the result is

we also change the print result
what we need to pay attention is that:
we turn the result such as result1,result to a list and then compile them to a single list ,then print it
the simmon effect(in psychology) :build the function of subject_information(modify the experiment programme),before we begin the experiment的更多相关文章
- The `android.dexOptions.incremental` property is deprecated and it has no effect on the build process.
		
编译报错:The android.dexOptions.incremental property is deprecated and it has no effect on the build pro ...
 - simon effect (psychology experiment )   :  build the function of wait4key()
		
## #the real experiment for simon effect #load the library which is our need import pygame import sy ...
 - simmon effect(psychology experiment) : this time, we add file_function who can creat a file in the window which contains our result
		
#the real experiment for simon effect #load the library which is our need import pygame import sys i ...
 - simmon effect : build the funcion of trail list
		
#the real experiment for simon effect #load the library which is our need import pygame import sys i ...
 - Android Studio升级到3.1.4后打开旧项目警告:The `android.dexOptions.incremental` property is deprecated and it has no effect on the build process.
		
现象截图 问题原因&解决方案 在build.gralde中,对Android开发过程中突破的方法数的限制,做了如下解决配置: dexOptions { incremental true jav ...
 - fn project   打包Function
		
Option 1 (recommended): Use the fn cli tool We recommend using the fn cli tool which will handle a ...
 - PostgreSQL function examples
		
warehouse_db=# CREATE TABLE warehouse_tbl(warehouse_id INTEGER NOT NULL,warehouse_name TEXT NOT NULL ...
 - Mysql ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA
		
ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declar ...
 - verilog中的function用法与例子
		
函数的功能和任务的功能类似,但二者还存在很大的不同.在 Verilog HDL 语法中也存在函数的定义和调用. 1.函数的定义 函数通过关键词 function 和 endfunction 定义,不允 ...
 
随机推荐
- RabbitMQ安装与使用
			
官网地址: http://www.rabbitmq.com/ 安装Linux必要依赖包 下载RabbitMQ必须安装包 进行安装,修改相关配置文件即可 步骤 1.准备: yum install gcc ...
 - Go语言实现:【剑指offer】合并两个排序的链表
			
该题目来源于牛客网<剑指offer>专题. 输入两个单调递增的链表,输出两个链表合成后的链表,当然我们需要合成后的链表满足单调不减规则. Go语言实现: //递归 func merge(l ...
 - 基于 Serverless Component 全栈解决方案 Ⅱ
			
虽然之前的文章 基于 Serverless Component 的全栈解决方案 介绍了如何借助 Serverless Component 快速搭建 Restful API 后端服务 和 Vue.js ...
 - 制作一个docker镜像:mysql-8-x64-linux
			
因为个人学习需要,为软件系统的虚拟容器化,以下将mysql制作为docker镜像,并记录下详细步骤. 欢迎大家学习交流和转载,同时写作不易,如果各位觉得不错,请点赞支持. 备注:以下代码和文章,欢迎复 ...
 - 协程的原理(Coroutine Theory)
			
原文链接:https://lewissbaker.github.io/2017/09/25/coroutine-theory This is the first of a series of post ...
 - postman简单接口测试
			
Postman简单接口测试 1. get请求: a. 选择get请求时,地址栏输入地址,如果需要添加参数,可以直接在地址栏加?后面写参数,也可以在点击params添加参数 b. 在headers中添加 ...
 - 无线网络WPA加密算法基础
			
2013-11-13 23:08 (分类:网络安全) 对无线没什么认识,总听说有人蹭网,还有卖蹭网器的,于是补充一下知识. 无线加密有两类:WEP WAP,目前采用WEP加密的非常少了,WEP应该只是 ...
 - 在Linux安装MySQL
			
yum 方式卸载MySQL与安装MySQL . rpm -qa | grep -i mysql命令查看已经安装过的组件 [root@VM_0_10_centos ~]# rpm -qa | grep ...
 - docker实战部署Javaweb项目
			
一.部署环境说明 docker服务版本:version 18.09.0nginx服务版本:version: nginx/1.15.10redis服务版本:version: redis/5.0.3tom ...
 - 解决掉你心中 js function与Function的关系的疑问
			
前言 在网上有很多关于js function 与 Function直接关系的文章. 但是我感觉过于抽象化了,那么如何是具体化的解释? 正文部分为个人理解部分,如有不对望指出. 正文 <scrip ...