Dear, Loved ~~Practice Speed Software

Posted by adrianuk29 on Tue, 27 Aug 2019 03:25:52 +0200

Dear, Loved ~~Practice Speed Software

Author: Call for fry

Source: WeChat gzh: A small home with pain, itching and itching

The CTF competition not only tests the professional background of the players, but also their reaction speed.*

In order to improve the sensitivity of K&K team members, Korean Chamber of Commerce has dedicated a hand speed software for training.Korean Merchant Speed test results were 0.1 seconds, but the poor team member Demo (Diamond) was miserable, I remember as if it was 0.3 seconds?That's okay. It's not important.

After knowing their needs for hand speed measurement in the past year, the genius Big Brother began to play its dominant nature silently and put forward upgrade suggestions for their existing software: I have a small idea - the hand speed measurement software now in use is to press the mouse based on the sound of "drops" to reflect personal sensitivity.

The bug is, however, that listening is highly disruptive and the final CTF contest does not require sound capability.Instead of using visual functions, click the mouse at the instant of a color change.

Ouch~As an ineligible programmer ape, I'm obliged to show you how to implement this simple little software for Science popularization.

 

The source code is as follows: (Comments have been added, if in doubt, background message oh~)

var startTime=new Date();//Define start time
var endTime=new Date(); //Define end time
var startPressed=false; //Define Start Button
var bgChangeStarted=false; //Define Background Change Start Button
var maxWait=20;
var timerID;

/*Start function*/
function startTest()
{
  /*Set the background color that will be changed. Multiple background colors are available here*/
  document.bgColor = document.response.bgColorChange.options
  [document.response.bgColorChange.selectedIndex].text;
  bgChangeStarted=true;  //Open the Background Start Change button
  startTime=new Date();  // Get the current system time as the start time
}

/* Feedback function: provide feedback based on the speed measurement time at the end*/
function remark(responseTime)
{
/* Different time periods correspond to different feedback languages*/
  var responseString="";
  if (responseTime > 0 && responseTime <0.01)
    responseString="Are you still human?"
  if (responseTime >.01 && responseTime <.05 )
    responseString="You are lightning fast!";
  if (responseTime >= 0.05 && responseTime <.10)
    responseString="Well done";
  if (responseTime >= 0.10 && responseTime < 0.20)
    responseString="Pretty good!";
  if (responseTime >=0.20 && responseTime < 0.30)
    responseString="It could be better...";
  if (responseTime >=0.30 && responseTime < 0.60)
    responseString="Practice more!";
  if (responseTime >=0.60 && responseTime < 1)
    responseString="Drunken?";
  if (responseTime >=1)
    responseString="I think you're asleep!";

  return responseString;
}

/* Stop Testing Function*/
function stopTest()
{
  if(bgChangeStarted)/* If you have clicked the Start button, enter the code snippet*/
  {
    endTime=new Date(); // Get the current system time as the end time
    /* The reaction time is calculated as end time-start time, and the last unit is converted to milliseconds.*/
    var responseTime=
    (endTime.getTime()-startTime.getTime())/1000;
    /* Give time feedback + remark language feedback above*/
    document.bgColor="aliceblue";
    alert("Your reaction time is:" + responseTime + " second " + "\n"
     + remark(responseTime));
    startPressed=false; // Close the previously opened start button
    bgChangeStarted=false; //Close the previously opened Background Change button
  }
  else 
  {
    if (!startPressed)
    {/*You did not click the Start button before clicking the End button*/
      alert("Start the test by pressing the Start key first");
    }
    else
    {
    /*The picture did not change color, so the End button was pressed*/
      clearTimeout(timerID); 
      startPressed=false;
      alert("Liar!You pressed the end key earlier!");
    }
  }
}

var randMULTIPLIER=0x015a4e35;
var randINCREMENT=1;
var today=new Date();
var randSeed=today.getSeconds();//Provide random number seeds

/*Randomly change the moment when the background color changes */
function randNumber()
{
  randSeed = 
  (randMULTIPLIER * randSeed + randINCREMENT) % (1 << 31);
  return((randSeed >> 15) & 0x7fff) / 32767;
}

/*Program response after clicking Start button*/
function startit()
{
  if(startPressed)
  { /*Repeatedly press the Start button */
    alert("Already started, press End to finish");
    return;
  }
  else
  {
  /* Normally click the Start button to set the timeout to prevent infinite waiting*/
    startPressed=true;
    timerID=setTimeout('startTest()', 6000*randNumber());
  }
}

If you are in the picture above, please leave a message to tell me the duck~

Of course, a tough guy can point out a little bit or two.

 

The final result is:

(Detailed video please pay attention to WeChat Public Number: Pain, itch and small home)

Game Page Link: http://games.sina.com.cn/z/cs/test.shtml

 

Science: Range of normal people's reaction speed

Many psychologists have measured physiological responses of people over 0.1 seconds, while normal people have a response time of 0.15 to 0.4 seconds.But it also varies from person to person.Response time has a lot to do with people's state of mind as well. When you are in a good mood, you react faster than when you are in a bad mood, and when you are excited, you react faster than when you are depressed.If a person does not wake up or drink alcohol, the reaction time will be much longer, about a second."Flying man" Liu Xiang's reaction time is 0.139 seconds. It is said that Liu Guoliang's reaction time is 0.01 seconds faster than his teammates, so his results are better.

 

END

 

 

Topics: React