E-prime编写仿真气球冒险任务(BART)
时间: 2023-07-05 10:36:23 浏览: 734
BART(Balloon Analog Risk Task)是一种心理学验,旨在测试参与者的冒险倾向和风险偏好。参与者需要通过点击气球来获得虚拟的奖励点数,但是每次点击都有一定的概率让气球爆炸,导致失去所有的奖励点数。以下是一个简单的 E-Prime 版本的 BART 实验的代码:
```
' E-Prime BART Experiment
' Global Variables
Dim BalloonCount, PumpCount, TotalPoints
' Set Up Experiment
Sub ExperimentSetUp()
BalloonCount = 0
PumpCount = 0
TotalPoints = 0
End Sub
' Run Trial
Sub TrialProc()
' Clear Screen
ClearScreen
' Display Balloon
DisplayBalloon(BalloonCount)
' Get Response
Dim Response
Response = GetResponse
' Update Balloon and Points
If Response = "Pump" Then
PumpCount = PumpCount + 1
If PumpCount = 4 Then
' Balloon Explodes
BalloonCount = 0
PumpCount = 0
TotalPoints = 0
Else
' Balloon Expands
BalloonCount = BalloonCount + 1
End If
Else
' Cash Out
TotalPoints = TotalPoints + BalloonCount
BalloonCount = 0
PumpCount = 0
End If
' Wait 500ms
Wait 500
End Sub
' Display Balloon
Sub DisplayBalloon(BalloonCount)
' Draw Balloon
DrawOval 100, 100, 50 + BalloonCount * 10, 50 + BalloonCount * 10, "Red", True
' Draw String
DrawString "Pump Balloon or Cash Out", 200, 200, 20, "Black"
End Sub
' Get Response
Function GetResponse()
' Wait for Response
Dim Response
While Response <> "Pump" And Response <> "Cash Out"
Response = WaitForInput("Pump", "Cash Out")
Wend
' Return Response
Return Response
End Function
' Main Experiment Loop
Sub Main()
' Set Up Experiment
ExperimentSetUp
' Loop Trials
For i = 1 To 20
TrialProc
Next
' End Experiment
EndExperiment
End Sub
' End Experiment
Sub EndExperiment()
' Clear Screen
ClearScreen
' Display Total Points
DrawString "Total Points: " & TotalPoints, 200, 200, 20, "Black"
' Wait for Key Press
WaitForKeypress
' Quit Experiment
QuitExperiment
End Sub
```
该代码模拟了一个气球冒险任务(BART)实验,参与者需要在每个试验中点击气球以获得奖励点数。每次点击都会使气球膨胀一点,但是每个气球都有一定的概率会爆炸,导致失去所有的奖励点数。参与者可以随时选择“Cash Out”以结束当前试验并将点数转换为奖励,或者继续“Pump”气球以获取更多的点数。试验结束后,参与者将获得所有试验的总点数。
阅读全文