Inquisit code:

<defaults>  
 /quitcommand = (Ctrl+'e') 
 /fontstyle=("Arial", 3%)
</defaults>

<values>
 /upper = 3000
 /lower = 0
 /current = 1500
</values>

<parameters>
 /gamble_position_xR = 80%
 /gamble_position_xL = 20%
 /gamble_position_y = 50%
</parameters>

### Define the stimuli
<text safe>
 /items = ("100% chance of <%values.current%> CHF now")
 /position = (parameters.gamble_position_xL, parameters.gamble_position_y)
 /hjustify = center
</text>

<text risky>
 /items = ("10% chance of 3000 CHF now")
 /position = (parameters.gamble_position_xR, parameters.gamble_position_y)
 /hjustify = center
</text>

<text too_slow_message>
 /items = ("Too slow")
 /position = (50%, 50%)
 /fontstyle = ("Arial", 8%)
</text>

<text too_fast_message>
 /items = ("Too fast")
 /position = (50%, 50%)
 /fontstyle = ("Arial", 8%)
</text>

### Define the trial elements
<trial choice>
 /stimulustimes = [0=safe; 0=risky]
 /validresponse = ("a", "l")
 /pretrialpause = 500
 /ontrialbegin = [values.current = round((values.upper + values.lower)/2)] 
 /ontrialend=[if (trial.risk.response == 30) values.upper = values.current]
 /ontrialend=[if (trial.risk.response == 38) values.lower = values.current]
 /skip = [values.upper - values.lower<25]
 /branch = [if(trial.choice.latency > 8000) trial.too_slow else if (trial.choice.latency < 250) trial.too_fast]
</trial>

<trial too_slow>
 /stimulustimes = [0 = too_slow_text]
 /timeout = 2000
</trial>

<trial too_fast>
 /stimulustimes = [0 = too_fast_text]
 /timeout = 2000
</trial>

### Define the block and exp elements
<block choiceblock>
 /trials = [1-15 = choice]
</block>

<expt choiceexperiment>
 /blocks = [1 = choiceblock]
</expt>