/// <summary> /// Returns the players response accuracy. /// The perfect accuracy would be 1, most inaccuracy is 0. /// </summary> protected float GetAccuracy(Trial t, float time) { ReactDataRed data = sessionData.gameData as ReactDataRed; bool hasResponseTimeLimit = data.ResponseTimeLimit > 0; float rTime = time - data.GuessTimeLimit; float totalTimeWindow = hasResponseTimeLimit ? data.ResponseTimeLimit : (t as ReactTrialRed).duration; return(1f - (rTime / (totalTimeWindow - data.GuessTimeLimit))); }
/// <summary> /// Parses Game specific variables for this Trial from the given XmlElement. /// If no parsable attributes are found, or fail, then it will generate some from the given GameData. /// Used when parsing a Trial that IS defined in the Session file. /// </summary> public override void ParseGameSpecificVars(XmlNode n, SessionData session) { base.ParseGameSpecificVars(n, session); ReactDataRed data = (ReactDataRed)(session.gameData); if (!XMLUtil.ParseAttribute(n, ReactDataRed.ATTRIBUTE_DURATION, ref duration, true)) { duration = data.GeneratedDuration; } if (!XMLUtil.ParseAttribute(n, ReactDataRed.ATTRIBUTE_ISRED, ref isRed, true)) { isRed = data.IsRed; } if (!XMLUtil.ParseAttribute(n, ReactDataRed.ATTRIBUTE_ISRANDOMPOS, ref isRandomPos, true)) { isRandomPos = data.IsRandomPos; } if (!XMLUtil.ParseAttribute(n, ReactDataRed.ATTRIBUTE_MINX, ref minX, true)) { minX = data.MinX; } if (!XMLUtil.ParseAttribute(n, ReactDataRed.ATTRIBUTE_MAXX, ref maxX, true)) { maxX = data.MaxX; } if (!XMLUtil.ParseAttribute(n, ReactDataRed.ATTRIBUTE_MINY, ref minY, true)) { minY = data.MinY; } if (!XMLUtil.ParseAttribute(n, ReactDataRed.ATTRIBUTE_MAXY, ref maxY, true)) { maxY = data.MaxY; } if (!XMLUtil.ParseAttribute(n, ReactDataRed.ATTRIBUTE_FIXEDX, ref fixedX, true)) { fixedX = data.FixedX; } if (!XMLUtil.ParseAttribute(n, ReactDataRed.ATTRIBUTE_FIXEDY, ref fixedY, true)) { fixedX = data.FixedY; } }
/// <summary> /// Returns True if the given response time is considered valid. /// </summary> protected bool IsValidResponse(float time) { ReactDataRed data = sessionData.gameData as ReactDataRed; return(data.ResponseTimeLimit <= 0 || time < data.ResponseTimeLimit); }
/// <summary> /// Returns True if the given response time is considered a guess. /// </summary> protected bool IsGuessResponse(float time) { ReactDataRed data = sessionData.gameData as ReactDataRed; return(data.GuessTimeLimit > 0 && time < data.GuessTimeLimit); }