How to use

This is the main source code for the experiment. If you want to use it, you should copy the actual zip file to your own PsyToolkit account, because often there are other files included for stimuli.

The source code for bart

options
  fullscreen
  scale
  resolution 1920 1080
  background color white
  set &balloonX -350 # for positioning balloon
  set &balloonY -65
  var out &bartScoreSoFar &earnings # this makes data analysis easier
  set &&blueExplosionPoints 49 101 65 25 74 100 18 31 49 128 71 100 89 37 110 20 26 114 70 3 89 27 36 101 95 109 5 52 34 92 
  set &&yellowExplosionPoints 3 26 1 10 24 30 11 7 22 26 18 1 24 23 17 21 26 18 6 6 20 3 22 21 21 23 6 26 10 8 
  set &&orangeExplosionPoints 5 4 1 4 7 4 2 3 5 5 1 7 8 2 3 2 2 8 4 3 4 6 5 2 1 1 5 3 6 7 
  set &&mixedBlockTypes 2 2 2 2 2 2 2 2 2 2   3 3 3 3 3 3 3 3 3 3   4 4 4 4 4 4 4 4 4 4  ## 10 of each 3 types
  set &pointsPerBalloon 5 # in the original paper, it is 5 cents per balloon
 
bitmaps
  instructions1
  instructions2
  instructions3
  pumpButton
  collectButton
  collectButtonGrey
  screenoutline
  explode1
  explode2
  arrows
  startButton   # for instructions
  nextPage      # for instructions
  previousPage  # for instructions
  reportLayout        # for report after block with stats
  greenContinueButton # for report after block with stats

fonts
  arial 50
  
task bart
  ##--first choose the correct explosion point for trial-----------------------------------------
  if &blockType = 0 ## green training trials
    set %balloonColor "green"
    set $explosionPoint 10
    set $currentRed   0
    set $currentGreen 128
    set $currentBlue   0 
  fi
  if &blockType = 1 ## mixed color balloons, it can be randomly of any color. We know there are 30 trials, so we use blocktype 2, 3 , 4, but then randomly interleaved
    set &blockType &&mixedBlockTypes remove random
    set $inMixedBlock = 1 # actually, &blockType should not really be changed, but it is convenient for choosing one of following
  fi
  ## now if it was blockType 1, not the blocktype will actually have been chosen to be 2,3,4
  if &blockType = 2 ## blue balloons (mean explosion point at 64)
    set %balloonColor "blue"
    set $explosionPoint &&blueExplosionPoints remove first
    set $currentRed   100
    set $currentGreen 100
    set $currentBlue  255 
  fi
  if &blockType = 3 ## yellow balloons (mean explosion point at 16)
    set %balloonColor "yellow"
    set $explosionPoint &&yellowExplosionPoints remove first
    set $currentRed   255
    set $currentGreen 255
    set $currentBlue   0 
  fi
  if &blockType = 4 ## orange balloons (mean explosion point at 4)
    set %balloonColor "orange"
    set $explosionPoint &&orangeExplosionPoints remove first
    set $currentRed   255
    set $currentGreen 128
    set $currentBlue   0 
  fi
  ##-- potential earnings calculation -----------------------------------------------------------
  set $potentialEarningsThisBalloon expression ( $explosionPoint - 1 ) * &pointsPerBalloon
  set &potentialEarnings increase $potentialEarningsThisBalloon
  ##---------------------------------------------------------------------------------------------
  if $inMixedBlock = 1 # this is only for next trial, so that we select correct color
    set &blockType 1
  fi
  ##---------------------------------------------------------------------------------------------
  set &&averageRTarray clear # for calculating average time it took to press pump up button
  set &balloonCount increase
  ##--setup screen
  show bitmap screenoutline  # 1
  show bitmap pumpButton -595 450  # 2
  show bitmap collectButtonGrey -80 450 # 3
  set $balloonSize 10
  show text &earnings 550 -50 black # 4
  show text $earningsThisBalloon 550 -350 black # 5
  show text &balloonCount 550 250 black # 6
  show circle &balloonX &balloonY $balloonSize $currentRed $currentGreen $currentBlue # 7 , in training we show green balloon
  if &blockType = 0
    show text "TRAINING BLOCK" 570 450 black
  fi
  while $timesPumped < $explosionPoint && $collected != 1
    ## now check what decision participant makes
    if $timesPumped = 0
      readmouse l 2 999999 range 2 2 # if $timesPumped is 0, you cannot click collect, you are forced to pump at least once
    else
      readmouse l 2 999999 range 2 3
    fi
    set &&averageRTarray append RT
    if UNDER_MOUSE = 2 ## people pump up
       if $timesPumped = 0
         update bitmap 3 collectButton # make collectButton yellow instead of unclickable grey
       fi
       set $timesPumped increase
       if $timesPumped != $explosionPoint
         set $earningsThisBalloon increase &pointsPerBalloon
	 set $balloonSize increase 3
         update circle 7 &balloonX &balloonY $balloonSize $currentRed $currentGreen $currentBlue
         update text 5 $earningsThisBalloon
       else
         set $explosion 1 # code that explosion happened
       fi
       scale 2 105
       delay 50
       scale 2 110
       delay 50
       scale 2 100
    fi
    if UNDER_MOUSE = 3
       set $collected 1 # this way you end
       set &earnings increase $earningsThisBalloon
       set &&bartScoreArray append $timesPumped # this is the adjusted score for calculating average later
       set &bartScoreSoFar &&bartScoreArray roundmean
    fi
  while-end
  if $explosion = 1
    clear 7 # remove balloon
    show animation &balloonX &balloonY 200 explode1 explode2
    delay 100
    clear -1
    show text "balloon exploded..." &balloonX &balloonY black
    update text 6 "earnings lost"
    delay 500
    clear -1
  fi
  if $collected = 1
    # now show arrows moving from current to earned amount
    for $y in -270 to -220 by 10
      show bitmap arrows 550 $y
      delay 50
      clear -1
    for-end
  fi
  ## -- we keep a count for exploded and unexploded balloons
  if $explosion = 1
    set &balloonCountExploded increase
  else
    set &balloonCountUnexploded increase
  fi
  ## -- we need to calculate the average response time for this balloon
  set &averageRT &&averageRTarray roundmean
  save BLOCKNAME %balloonColor &balloonCount $timesPumped $explosion $earningsThisBalloon &earnings &bartScoreSoFar &averageRT $potentialEarningsThisBalloon &potentialEarnings

task showReport
  set $xpos 360
  set &missedPotential expression &potentialEarnings - &earnings
  text color black
  text align left
  show bitmap reportLayout -140 0
  show text &potentialEarnings      $xpos -390
  show text &earnings               $xpos -260
  show text &missedPotential        $xpos -130
  show text &balloonCount           $xpos 0
  show text &balloonCountUnexploded $xpos 130
  show text &balloonCountExploded   $xpos 260
  show text &bartScoreSoFar         $xpos 385
  delay 2000
  show bitmap greenContinueButton   780 392
  readmouse l SHOW_COUNTER 999999 range SHOW_COUNTER SHOW_COUNTER

####################################################################################
## blocks
####################################################################################

block training
  set &blockType 0 # training, green balloons
  pager option mouse previousPage 0 490 nextPage 300 490 startButton 650 490
  pager instructions1 instructions2
  task bart 3

block feedback1
  task showReport 1

block realdataMixed
  # first reset various variables
  set &potentialEarnings 0
  set &earnings 0 # reset training
  set &balloonCount 0 # reset count
  set &balloonCountUnexploded 0 # reset count
  set &balloonCountExploded 0 # reset count
  set &bartScoreSoFar 0
  set &&bartScoreArray clear
  #
  set &blockType 1 # mixed, there are 30 trials
  message instructions3 mouse
  delay 1000
  message greenContinueButton mouse
  task bart 30

block realdataBlockedBlue
  set &blockType 2 # blue only
  task bart 20

block realdataBlockedYellow
  set &blockType 3 # yellow only
  task bart 20

block realdataBlockedOrange
  set &blockType 4 # orange only
  task bart 20

block feedback2
  task showReport 1