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 tower_hanoi
options
mouse on
bitmaps
titlescreen
instructions
gradient
peg
disc1
disc2
disc3
welldone
## possible y positions; 84,120,158
task tower
show bitmap gradient #1
show rectangle 0 192 600 30 100 149 237 #2
show bitmap peg -200 100 #3
show bitmap peg 0 100 #4
show bitmap peg 200 100 #5
#################################################
show bitmap disc1 &disc1_x &disc1_y # stimulus #6
show bitmap disc2 &disc2_x &disc2_y # stimulus #7
show bitmap disc3 &disc3_x &disc3_y # stimulus #8
#
# now determine which disc can be moved (only the top ones)
#
set &&topdiscs clear
set $peg1size &&peg1 size
set $peg2size &&peg2 size
set $peg3size &&peg3 size
if $peg1size > 0
set $tmp &&peg1 use last
set &&topdiscs append $tmp
fi
if $peg2size > 0
set $tmp &&peg2 use last
set &&topdiscs append $tmp
fi
if $peg3size > 0
set $tmp &&peg3 use last
set &&topdiscs append $tmp
fi
#
#
#
drag option from &&topdiscs
drag option snap center bottom no_overlap 6 7 8
drag option to 3 4 5
drag 999999
#
# now process data
set $wrong 0
if DRAG_CHANGED == 1 && STATUS == 1
## make copies of the 3 pegs in case the dragging was wrong
set &&peg1copy &&peg1
set &&peg2copy &&peg2
set &&peg3copy &&peg3
## remove the DRAGGED value from whichever peg it was on
set &&peg1 remove value DRAGGED
set &&peg2 remove value DRAGGED
set &&peg3 remove value DRAGGED
## now check on which peg the disc is
set $newX getx DRAGGED ## the x position of the dragged stimulus
set $newY gety DRAGGED ## the x position of the dragged stimulus
set &stepcounter increase
if $newX == -200
set &&peg1 append DRAGGED
set &&peg1 reverse
if &&peg1[1] > &&peg1[2]
set $wrong 1
fi
set &&peg1 reverse
fi
if $newX == 0
set &&peg2 append DRAGGED
set &&peg2 reverse
if &&peg2[1] > &&peg2[2]
set $wrong 1
fi
set &&peg2 reverse
fi
if $newX == 200
set &&peg3 append DRAGGED
set &&peg3 reverse
if &&peg3[1] > &&peg3[2]
set $wrong 1
fi
set &&peg3 reverse
fi
if $wrong == 1
set &mistakes increase
delay 200
show text "Wrong, do not put disc on smaller one."
delay 500
relocate DRAGGED DRAG_OLD_X DRAG_OLD_Y
## reinstate pegs
set &&peg1 &&peg1copy
set &&peg2 &&peg2copy
set &&peg3 &&peg3copy
set &stepcounter decrease
fi
show text &stepcounter 300 250
if $wrong == 0
set &moves increase
##
## set the new positions
##
if DRAGGED == 6
set &disc1_x $newX
set &disc1_y $newY
fi
if DRAGGED == 7
set &disc2_x $newX
set &disc2_y $newY
fi
if DRAGGED == 8
set &disc3_x $newX
set &disc3_y $newY
fi
fi
fi
if DRAG_CHANGED == 1 && STATUS == 2
set &outplaced increase
fi
## now check if the pegs really changed
delay 500
timestamp the_time_now
set &time_so_far timestamp-diff block_start_time the_time_now
save &time_so_far &stepcounter &mistakes &outplaced
set $peg3size &&peg3 size
if $peg3size == 3
if &&peg3[1] == 8 and &&peg3[2] == 7 and &&peg3[3] == 6
show bitmap welldone 0 -100
delay 1000
end tasklist
fi
fi
message titlescreen mouse
message instructions mouse
block test
timestamp block_start_time
set &stepcounter 0
set &disc1_y 82
set &disc2_y 118
set &disc3_y 157
set &disc1_x -200
set &disc2_x -200
set &disc3_x -200
set &&peg1 8 7 6
task tower 100 ## each trial is one step.