Simpler version of demo program

[From Bill Powers (950105.1330 MST)]

Bruce Abbott, Rick Marken, Tom Bourbon, other modelers:

Here is the code for "THREECV1.PAS", a much simpler version of the last
one. The mouse x position affects three cursors equally. The participant
is to select one of the cursors and maintain it as close as possible to
the corresponding red target line, for 1 minute.

The three disturbances are now stored on the heap as an
array[1..3,1..3600] of integer, and the three cursor positions are
stored in a similar array. The handle (mouse) position is stored in an
array[1..3600].

To access the nth cursor position at time t, use c^[n,t]. The handle
position at time t is accessed as handle^[t]. The disturbances are
accessed as dist^[n,t]. N is 1,2, or 3, and t runs from 1 to 3600.

The participant picks one cursor and holds it as close as possible to
the corresponding red target during the 1-minute run.

Again, the task is to analyze the data consisting of handle positions
and the three cursor positions by some conventional method. I will
provide a PCT analysis later. Anyone wishing to propose a conventional
analysis can just post the source code for the "analyze" procedure.

Best,

Bill P.

···

====================================================================
Program threecv1;

{ A PROGRAM FOR TESTING METHODS OF ANALYSIS

required: setparam.pas revision of 941220; mouse unit

Horizontal mouse movements affect three cursors next to three stationary
target lines. The paricipant picks one cursor and holds it on its
target line throughout a 1-minute experimental run. The handle (mouse)
position and the three cursor positions are recorded for analysis after
the run.

The user is invited to write an analysis program to go where the dummy
procedure "analyze" is, according to whatever way it is thought that a
conventional psychological analyst would do it.

When the program starts, the first disturbance is shown on the screen.
Pressing the space bar generates a new pattern, pressing escape accepts
that pattern and goes on to the next of three disturbances. After the
third disturbance pattern is accepted, the program pauses (to allow
the participant to select which variable to control). When a key is
struck, the one-minute run starts with a run-in time (not recorded)
of 2 seconds to allow gaining control. MAXDATA data points are recorded.

}

Uses Dos,Crt,Graph,grUtils,mouse;

{Note: use version of frameplt of 941220 or later}

const
left = 203; right = 205; up = 200; down = 208; PgUp = 201; PgDn = 209;
Ins = 210; Del = 211; EndKey = 207; Home = 199; EscKey = 27; Cr = 13;
f1 = 187; f2 = 188; f3 = 189; f4 = 190; f5 = 191;
f6 = 192; f7 = 193; f8 = 194; f9 = 195; f10 = 196;

      MAXDATA = 3600;

type datalist = array[1..MAXDATA] of integer;
     listptr = ^datalist;
     dataarray = array[1..3] of datalist;
     dataptr = ^dataarray;

var i,j,maxx,maxy: integer;
    slow,d1,d2,d3: real;
    maxcolor: word;
    dist: dataptr;
    c: dataptr;
    handle: listptr;
    ch: char;

procedure InitScreen;
begin
  ClrScr;
  InitGraphics;
  MaxX := GetMaxX; MaxY := GetMaxY;
  maxColor := getmaxcolor;
end;

procedure labelscreen;
begin
  setcolor(white);
  outtextxy(0,0,'KEEP ONE WHITE CURSOR AT RED TARGET POSITION');
  outtextxy(0,20,' PRESS SPACE TO START RUN');
end;

procedure InitDist(d: listptr; n: integer);
var i,max: integer;
    avg,tmp: real;
begin
repeat
clearviewport;
outtextxy(0,0,'PRESS SPACE FOR NEW PATTERN, ESC KEY TO ACCEPT');
case n of
  1: outtextxy(0,20,'FIRST DISTURBANCE');
  2: outtextxy(0,20,'SECOND DISTURBANCE');
  3: outtextxy(0,20,'THIRD DISTURBANCE');
end;
d1 := 0.0; d2 := 0.0; d3 := 0.0;

for j := -100 to MAXDATA do
  begin
   i := abs(j) + 1;
   d1 := random * 10000.0 - 5000.0;
   d2 := d2 + slow*(d1 - d2);
   d3 := d3 + slow*(d2 - d3);
   d^[i] := round(d3);
   if j > 0 then
   putpixel(i div 6,maxy div 2 - d^[i] div 2,white);
  end;
  avg := 0.0;
  for i := 1 to MAXDATA do avg := avg + d^[i];
  avg := avg/MAXDATA;
  for i := 1 to MAXDATA do d^[i] := d^[i] - round(avg);
  max := 0;
  for i := 1 to MAXDATA do if abs(d^[i]) > max then max := abs(d^[i]);
  for i := 1 to MAXDATA do { normalize to max of 120 }
   begin
    tmp := 120.0/max;
    d^[i] := round(d^[i]*tmp);
   end;

ch := readkey;
until ch = chr(EscKey);
end;

var oldc: array[1..3] of integer;

procedure drawcursor(c,n,init: integer);
begin
  if init = 0 then
  line(oldc[n], maxy div 2 - 60 + 25*(n - 1),
       oldc[n], maxy div 2 - 45 + 25*(n - 1));
  oldc[n] := c + maxx div 2;

  line(oldc[n], maxy div 2 - 60 + 25*(n - 1),
       oldc[n], maxy div 2 - 45 + 25*(n - 1));
end;

procedure drawtargets;
begin
setcolor(lightred);
for i := 1 to 3 do
  line(maxx div 2, maxy div 2 - 60 + 25*(i - 1),
       maxx div 2, maxy div 2 - 45 + 25*(i - 1));
setcolor(white);
end;

procedure RunExpt;
var h,k: integer;
begin
readmouse;
for k := 1 to 3 do
  drawcursor(mousex,k,1);
for j := -120 to MAXDATA do { 2-sec run-in period }
  begin
   i := abs(j) + 1;
   readmouse;
   h := mousex;
   handle^[i] := h;
   retrace;
   for k := 1 to 3 do
    begin
     drawcursor(mousex + dist^[k,i],k,0);
     c^[k,i] := oldc[k];
    end;

   if j = -120 then ch := readkey;
   if keypressed then break;
  end;
  if keypressed then ch := readkey;
end;

procedure Analyze; { to be created by user}
begin
end;

begin
ClrScr;
if not initmouse then
  begin
   gotoxy(20,10);
   writeln('MOUSE NOT INSTALLED. EXITING');
   delay(2000);
   exit;
  end;
new(dist);
new(c);
new(handle);
Randomize;
slow := 0.005; { rapidity of disturbance, smaller = slower }
InitScreen;
for i := 1 to 3 do InitDist(@dist^[i],i);
clearviewport;
labelscreen;
setwritemode(XORPUT);
drawtargets;
RunExpt;
Analyze; { To be created by user}
RestoreCrtMode;
closegraph;
dispose(handle);
dispose(c);
dispose(dist);
end.