Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,449 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Copy of reactiontest.c #312195
02/23/10 16:55
02/23/10 16:55
Joined: Feb 2006
Posts: 52
C
carlpa Offline OP
Junior Member
carlpa  Offline OP
Junior Member
C

Joined: Feb 2006
Posts: 52
You have no doubt forgotten me but have been very helpful in the past. I am a neurologist who does research in cognition and sleep medicine. I have used 3D Gamestudio with success in developing Choice reaction time programs. Might I have a copy of reactiontest.c to review? I am sure you have some ideas which would be helpful to me.

I have just completed a program based on the article you referenced.

Thank you very much.
Carl Rosenberg MD


Researcher & clinician. A6, A7, & A8
First computer a Commodore Pet
Re: Copy of reactiontest.c [Re: carlpa] #312319
02/24/10 08:42
02/24/10 08:42
Joined: Apr 2005
Posts: 4,506
Germany
F
fogman Offline
Expert
fogman  Offline
Expert
F

Joined: Apr 2005
Posts: 4,506
Germany
Just download the newest & free version of Gamestudio or Lite-C. It´s located in the folder "samples".


no science involved
Re: Copy of reactiontest.c [Re: fogman] #312330
02/24/10 10:34
02/24/10 10:34
Joined: Jul 2000
Posts: 28,024
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,024
Frankfurt
I believe reactiontest.c is not yet in the release, but as far as I remember it does not need a function of the beta version, so here is it:

Code:
////////////////////////////////////////////////////////////////////
// Choice reaction time test
// (c) jcl / oP group 2010
////////////////////////////////////////////////////////////////////

var key_number;

PANEL* panel =
{
	digits (260,200,1,"Arial#150b",1,key_number); 
	flags = OUTLINE;
}

TEXT* text =
{
	font = "Arial#30b";
	string("Choice reaction time test\nPress number key when number appears\nAny key to start"); 
	pos_x = 10; pos_x = 10;
}

SOUND* beep2 = "beep2.wav";

/////////////////////////////////////////////////////////////////////

function main()
{
  screen_size.x = 600;
  screen_size.y = 600;
	screen_color.blue = 150;
	video_window(NULL,NULL,0,"Choice Reaction Time Test");
  random_seed(0);

// reaction test loop
  while(1)
  {
// any key to start
	  set(text,SHOW);
	  while (!key_any) wait(1);
	  reset(text,SHOW);
	
// start reaction test
	  var key_time = 0;
	  var loop;
	  for (loop = 0; loop < 5; loop++)
	  { 
// 	wait a random time until number appears
		  reset(panel,SHOW);
		  wait(-2 - random(2)); 
		  
// display a random number between 1 and 5
		  key_number = 1 + integer(random(5));
		  snd_play(beep2,100,0);
		  set(panel,SHOW);
		  timer();
	
// wait until key is pressed	  
		  while (!key_any) wait(1);
		  
// wrong key -> blink red and repeat  
		  if (key_number != str_to_num(str_for_key(NULL,key_lastpressed)))
		  {
		  	var i;
		  	for (i=0; i<3; i++) {
					vec_set(panel.blue,COLOR_RED);
					wait(-0.1);
					vec_set(panel.blue,COLOR_WHITE);
					wait(-0.1);
				}
				loop--;
				continue;
			}
		  
// build average time over 5 loops	  
		  key_time += timer()/5; 
	  }
	
	  reset(panel,SHOW);
	  str_printf((text.pstring)[0],
	  "Average choice reaction time: %.3f seconds\nEsc to quit, other key to restart",
	  ((double)key_time)/1000000.);
// wait until key released		
		while (key_any) wait(1);
	}  
}



Re: Copy of reactiontest.c [Re: jcl] #312424
02/24/10 18:11
02/24/10 18:11
Joined: Feb 2006
Posts: 52
C
carlpa Offline OP
Junior Member
carlpa  Offline OP
Junior Member
C

Joined: Feb 2006
Posts: 52
Thank you very much. I did learn something new.


Researcher & clinician. A6, A7, & A8
First computer a Commodore Pet
Re: Copy of reactiontest.c [Re: carlpa] #312626
02/25/10 18:08
02/25/10 18:08
Joined: Feb 2006
Posts: 52
C
carlpa Offline OP
Junior Member
carlpa  Offline OP
Junior Member
C

Joined: Feb 2006
Posts: 52
A few comments about reaction timers, if I may.

It is better to use total_tics as a time counter than timer(). The actual accuracy is the same with both, a frame cycle, due to the need to use a wait(1) command. However, timer() will return a negative value if the time to react is very long. Setting fps_max = 200 will deliver a resolution of 5 msec. This is too long for a "GO/NOGO" reaction time but excellent for a "CHOICE" reaction time.

Reaction time has both cognitive and motor components: one is the time to process the stimuli and make a decision and the other is the correct motor response which may involve a search for the correct key to press. Task design can emphasize either cognition or motor. "reactiontime.c" stresses both cognitive and motor functions.

Thank you.


Researcher & clinician. A6, A7, & A8
First computer a Commodore Pet
Re: Copy of reactiontest.c [Re: carlpa] #312659
02/25/10 19:40
02/25/10 19:40
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
Originally Posted By: carlpa
Setting fps_max = 200 will deliver a resolution of 5 msec.

no, it will deliver a resolution UP TO 5 msec.

Re: Copy of reactiontest.c [Re: Joey] #313475
03/01/10 17:08
03/01/10 17:08
Joined: Feb 2006
Posts: 52
C
carlpa Offline OP
Junior Member
carlpa  Offline OP
Junior Member
C

Joined: Feb 2006
Posts: 52
Joey,

You are correct. fps_max = 200 does not limit the resolution to 5 msec. However, it yields an accurate reading when the program is not "video intensive". A very complex presentation could slow the frame rate. That is why I check fps for each reaction time trial. This yields the best measure of time resolution.


Researcher & clinician. A6, A7, & A8
First computer a Commodore Pet

Moderated by  old_bill, Tobias 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1