Getting the counter to reset when it hits 0


Author
Message
aghartley
aghartley
Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)
Group: Awaiting Activation
Posts: 16, Visits: 127
Hello,

I am designing an experiment in which participants can either earn money (incentive) or lose money (decentive) for correct guess per trial. For example, if it's an incentive block, participants will earn $.15 for each correct guess per trial within that block. But if the next block is a decentive block, they will lose $.05 for each correct guess.

I'm using the counter element so that participants can keep track of their earnings. However, currently, as I've programmed the experiment, if participants lose money below $0, the program records negative numbers, but their counter amount shows $0. So, when participants start earning money again, they need to get out of the negative range before the counter will show anything over $0.

Basically, I need to know how to get the counter to reset the participant's earnings to 0 when they dip into the negative digits (we are not interested in having participants owe money for this task). Would I do this using the reset interval attribute? Or would I need to fix something elsewhere in the code, outside the counter element?

Please let me know if you'd like to see my code. Thank you!
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 98K
I'm not sure why you would use a <counter> to keep track of earnings at all. The best-suited element for that is a <values> entry -- you simply update that value by adding or subtracting earnings or losses. Setting that value to zero if it goes negative is trivial.

<values>
/ points = 0
</values>

<block myblock>
/ trials = [1-10 = mytrial]
</block>

<trial mytrial>
/ ontrialend = [if (trial.mytrial.response == 17) values.points += 10]
/ ontrialend = [if (trial.mytrial.response == 38) values.points -= 10]
/ ontrialend = [values.points=max(0,values.points)]
/ stimulusframes = [1=mytext, mypoints]
/ validresponse = ("w", "l")
</trial>

<text mytext>
/ items = ("Press 'W' to win points, press 'L' to lose points.")
</text>

<text mypoints>
/ items = ("Your have <%values.points%> points")
/ position = (50%, 10%)
/ erase = false
/ size = (25%, 10%)
</text>


A <counter>'s /resetinterval will not help you, nor will explicitly calling the reset() function on it. Neither changes the counter's *contents*, both merely reset it's selection pool.

Edited 9 Years Ago by Dave
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search