Millisecond Forums

Problem with counter feature

https://forums.millisecond.com/Topic4105.aspx

By Keith Leavitt - 3/10/2010

Hi All,


I'm having a problem with a "counter" in a script that worked great in a slightly different version. The task is roughly modeled after the Cyberball task, but designed to look at predictors of cheating/enabling cheating within a 'group' context.


In my previous (functional) version, participants took a couple surveys, selected useritems (an avatar and a handle), and jumped in to the game. Each turn consists of generating an answer, the answer being displayed on the screen, choosing a player to pass the next turn to, and the animation for the ball-pass. Participants believe that they are "racing the clock", but after the actual subject takes 12 turns, they get an "out of time" countdown.


In the new version, I added a block in front of the "game" block, in which the pattern of the first five passes is scripted (so that the participant sees the cheating player first being ostracized for cheating). This pre-block seemlessly transitions into the normal game play, where the participant passes a turn to whomever they wish, and the electronic confederates pass at random.


However, when testing this, the counter for "score" doesn't seem to work now; the game goes on for an infinite amount of turns.


Here are the relevant script items for the counter ("turns" is an unrelated value used elsewhere in the study):



<block game>


/ trials = [1= 1to2]


/ stop= [values.score==12]


</block>



<values>


/ score = 0


/ turns = 0


</values>



<trial pass>


/stimulusframes= [1=player1, player2, player3, player4, throw, player1label, player2label, player3label, player4label, teamnumber, teamnumber2]


/ validresponse = (player1, player3, player4)


/ontrialend=[values.score = values.score + 1]


/ branch = [if (trial.pass.response == "player1") trial.2to1]


/ branch = [if (trial.pass.response == "player3") trial.2to3]


/ branch = [if (trial.pass.response == "player4") trial.2to4]


</trial>






I'm attaching the actual file here as well. It's a pretty huge script, but the relevant parts are labeled under "***************actual game trials*******************".


Thanks in advance; I've been beating my head against the wall all morning.


 

By Keith Leavitt - 3/10/2010

For convenience sake, I posted the script to Web-Inquisit to take a peek at. You can control+B through the first couple of blocks but not from the third on (the third collects user items necessary in the next blocks, so it crashes without them).


 http://research.millisecond.com/lab/Experimenttroubleshoot.web


--Keith

By Dave - 3/10/2010

So, you have this "scripted" block called <block game_ostracism>. The block runs these <trial> elements:


/ trials = [1 = loading; 2= loading2; 3=start_ostracise; 4=pause1fixed; 5=player1fixed; 6=1to3fixed; 7=pause3fixed; 8=player3fixed; 9=3to4fixed; 10=pause4fixed; 11=player4fixed; 12=4to3fixed; 13=pause3fixed; 14=player3fixed; 15=3to1fixed; 16=pause1fixed; 17=player1fixed]


Some of these trials (player1fixed, player2fixed, etc.) update values.score via an '/ ontrialend' command


<trial player1fixed>
/stimulusframes =  [1=player1, player2, player3, player4, player1label, player2label, player3label, player4label, answer1, teamnumber, teamnumber2]
/ validresponse = (noresponse)
/ trialduration =2500
/ ontrialend=[values.score = values.score + 1]
</trial>


such that at the end of <block game_ostracism> values.score will equal 5!


Then you have the actual or "real" game block which is defined like this in the script you attached:


<block game>
/ trials = [1= 1to2]
/ stop= [values.score==2] (sic! It's not 'values.score==12' in the attached script)
</block>


Obviously, the stop condition can never evaluate to true, since already values.score=5 at this point, thus sending you off into an infinite loop.


What you'll need to do is (a) reset values.score to zero at the start of <block game> and (b) define a proper stop condition:


<block game>
/ onblockbegin = [values.score=0]
/ trials = [1= 1to2]
/ stop= [values.score==12]
</block>


Also, when running the attached script, there'll be a runtime error thrown relating to 'expressions.cyberdecisiontime.2' because there's a nasty typo in <trial 4to2>:


<trial 4to2>
/ stimulusframes = [1= player1, player2, player3, player4, player1label, player2label, teamnumber, teamnumber2, player3label, player4label, 4to2]
/ validresponse = (noresponse)
/trialduration= expressions.cyberdecisiontime.2 (needs to read 'expressions.cyberdecisiontime2')
/ responsetrial= ("noresponse", get)
</trial>


Regards,


~Dave

By Keith Leavitt - 3/10/2010

Thanks Dave.


The "fixed" trials were supposed to increase a different counter, not the one for "score". The "ontrialbegin" command was the ticket.