DMDX Help.


Dynamic Item content notes.


    A recent task here involved presenting a series of randomly chosen item elements and rather than generate the whole possible set of items and stop once some criteria were met I opted to use macros to determine the selections in a subroutine and have them expand in the actual item tests themselves.  Not only that but the set of stimuli to choose from was to change as the task progressed.  So one set of macros (A to H) determined stimuli that could be chosen (here A to D were four versions of "a" and E to H were four versions of "b") and nine macros (1 to 9) were returned that were used to set  up an item (here in the form of aaabbbaaa).  A track record of what was actually played is made by emitting the text into the output and the macros A to H are redefined as needed as the items are run.  Double tildes (~~) are used for skip display CR indicators in front of item numbers because once you are are using macros 1 to 9 (and 0 although I don't use it here) they would expand in skip display item numbers, not what we want (so ~100 would expand to say DA300 here).  So a double tilde collapses to a single skip display CR indicator.  Pretty sure this sets a record for the all time number of macros in one item file too...

<ep> f60 <nfb> <vm desktop> <id keyboard>
<cr> <eop>

0 “Start" <bu 999>;

~~100 <set c100 = (random 4) + 101> <ib 100>         <!aaabbbaaa>;
~~101 m1+"~A"+ <bu 110>;
~~102 m1+"~B"+ <bu 110>;
~~103 m1+"~C"+ <bu 110>;
~~104 m1+"~D"+;
~~110 <set c100 = (random 4) + 111> <ib 100>;
~~111 m2+"~A"+ <bu 120>;
~~112 m2+"~B"+ <bu 120>;
~~113 m2+"~C"+ <bu 120>;
~~114 m2+"~D"+;
~~120 <set c100 = (random 4) + 121> <ib 100>;
~~121 m3+"~A"+ <bu 130>;
~~122 m3+"~B"+ <bu 130>;
~~123 m3+"~C"+ <bu 130>;
~~124 m3+"~D"+;
~~130 <set c100 = (random 4) + 131> <ib 100>;
~~131 m4+"~E"+ <bu 140>;
~~132 m4+"~F"+ <bu 140>;
~~133 m4+"~G"+ <bu 140>;
~~134 m4+"~H"+;
~~140 <set c100 = (random 4) + 141> <ib 100>;
~~141 m5+"~E"+ <bu 150>;
~~142 m5+"~F"+ <bu 150>;
~~143 m5+"~G"+ <bu 150>;
~~144 m5+"~H"+;
~~150 <set c100 = (random 4) + 151> <ib 100>;
~~151 m6+"~E"+ <bu 160>;
~~152 m6+"~F"+ <bu 160>;
~~153 m6+"~G"+ <bu 160>;
~~154 m6+"~H"+;
~~160 <set c100 = (random 4) + 161> <ib 100>;
~~161 m7+"~A"+ <bu 170>;
~~162 m7+"~B"+ <bu 170>;
~~163 m7+"~C"+ <bu 170>;
~~164 m7+"~D"+;
~~170 <set c100 = (random 4) + 171> <ib 100>;
~~171 m8+"~A"+ <bu 180>;
~~172 m8+"~B"+ <bu 180>;
~~173 m8+"~C"+ <bu 180>;
~~174 m8+"~D"+;
~~180 <set c100 = (random 4) + 181> <ib 100>;
~~181 m9+"~A"+ <bu 190>;
~~182 m9+"~B"+ <bu 190>;
~~183 m9+"~C"+ <bu 190>;
~~184 m9+"~D"+;
~~190 <emit sound files ~1 ~2 ~3 ~4 ~5 ~6 ~7 ~8 ~9> <return>;

~~999  mA+DA1+ mB+DA2+ mC+DA3+ mD+DA4+ <! a1, a2, a3, a4>
       mE+TA5+ mF+TA6+ mG+TA7+ mH+TA8+ <! b1, b2, b3, b4>;

~~1001 <call -100>;
+1002 * <wav 2> ~1 / <wav 2> ~2 / <wav 2> ~3 / <wav 2> ~4 / <wav 2> ~5 / <wav 2> ~6 / <wav 2> ~7 / <wav 2> ~8 / <wav 2> ~9 ;

~~2001 <call -100>;
+2002 * <wav 2> ~1 / <wav 2> ~2 / <wav 2> ~3 / <wav 2> ~4 / <wav 2> ~5 / <wav 2> ~6 / <wav 2> ~7 / <wav 2> ~8 / <wav 2> ~9 ;

~~1 mA+DA5+ mB+DA6+ mC+DA7+ mD+DA8+ <! a1, a2, a3, a4>
    mE+TA1+ mF+TA2+ mG+TA3+ mH+TA4+ <! b1, b2, b3, b4>;

~~3001 <call -100>;
+3002 * <wav 2> ~1 / <wav 2> ~2 / <wav 2> ~3 / <wav 2> ~4 / <wav 2> ~5 / <wav 2> ~6 / <wav 2> ~7 / <wav 2> ~8 / <wav 2> ~9 ;

~~3101 <call -100>;
+3102 * <wav 2> ~1 / <wav 2> ~2 / <wav 2> ~3 / <wav 2> ~4 / <wav 2> ~5 / <wav 2> ~6 / <wav 2> ~7 / <wav 2> ~8 / <wav 2> ~9 ;
 


The Ultimatum Game.


    Another recent task involved coding Alan Sanfey's (2003) Ultimatum game.  Here a fixed number of offers of various fixed amounts have to be made by a set of fake offerers.  The problem with the obvious solution to picking an offer where one checks to see if one's random choice has been made already is that by the time the last few offers are being made those random numbers are going to have to rolled a increasing number of times till you get to the last one where a every number selected except one will require another shot.  Which can take serious amounts of time for even a moderately large number of offers.  The standard solution is to build an array of offers, shuffle it and then just take offers from the first element to the last which takes the same amount of time for each offer, the trick comes with building an array in DMDX.  I built this solution with a series of pairs of items, the first of every pair being a target for a branch that doesn't get scrambled and the second of the pair which makes the selection which gets scrambled.  While our example only has five offers (one of each of the sizes of offer) in reality many more would be added but the item numbers 100, 101, 102, etc would have to be kept in strict ascending order otherwise when that offer is to be selected our selecting routine will fail when the indexed branch to that item number can't be completed.
    The rest of the task is a subroutine that takes the name, gender indicator, image name and item number from a series of macros setup and scrambled by the body of the item file.  One nice frilly bit, the subroutine uses macro T to indicate a change in the total the subject has accumulated if they accept an offer ("You now have $N" instead of "You have $N").  One slight problem was the item number, I initially wanted to use macro
I in the item number of the item that prompts for a response so the data file has responses and item numbers nicely matching.  However I soon discovered that branching code doesn't expand macros before checking item numbers and the item file would fail as the branching code skipped over the subroutine initially because I'd used macro I and of course that was a syntax error because a letter was where the item number would be.  So I made it macro 9 and of course any incidental use of 9 in an item number that has a skip display CR indicator now has to get ~~, but hey, it wouldn't be DMDX without some really arcane kludge...

<ep> <Backgroundcolor 000> <fd 0> <dfm 1.4> <vm desktop> <RtfColorOverride> <df Lucida Sans> <WritingColor 255255255> <azk> <id keyboard> <nfb> <ntl>
<cr> s1 </ep>

$
~1 <bu 0> <set c0=99> <set c4=0>;
~~99 <set c0=c0+1> <ib 0>;
$
$~100; $ ~1<set c1=9><bu 500>;
$~101; $ ~1<set c1=8><bu 500>;
$~102; $ ~1<set c1=7><bu 500>;
$~103; $ ~1<set c1=6><bu 500>;
$~104; $ ~1<set c1=5><bu 500>;
\
$
500 <XY 0.5,0.4> <jpg> "~F" , <fd 90> <XY 0.5,0.8> "~N has been given $10 to split with you." / <ne>;
501 <fd 240> <ocb> <XY 0.5,0.8>
"~N proposes that ~She will keep $%d and give you $%d."
<set c2=10-c1><set c3=c2><sprintf 1,2>/;
~9 "Do you accept this offer?" <crp> */ <ne> <bic 502> mT+now +;
~501 <set c3=0> mT++;
502 <set c4=c4+c3> "You have received $%d." <sprintf 3>,
<fd 180> @1 “You ~Thave $%d." <sprintf 4> /
<emit ~N> <emit 2> <emit 3> <emit 4> <return>;

! emits offerer name, offered amount, accepted amount, running total;

0 <XYJustification 1> "Ready to begin?";
$

! macro 9 sets the item number for the response, macro F is the file name
macro N is the offerer’s name, macro S is set to s for female names;

1101 m9+1101+ mF+1+ mN+David+ mS++ <call -99>;

1102 m9+1102+ mF+17+ mN+Katie+ mS+s+ <call -99>;

1103 m9+1103+ mF+16+ mN+Rachel+ mS+s+ <call -99>;

1104 m9+1104+ mF+3+ mN+Josh+ mS++ <call -99>;

1105 m9+1105+ mF+4+ mN+Rick+ mS++ <call -99>;

$
0 "END";
$




 




DMDX Index.