示例#1
0
    void WriteJoystickResult(ChallengeData chData, StreamWriter sw)
    {
        float[]  averageTimeSpent = new float[4];
        float[]  averageFailures  = new float[4];
        double[] averageDistance  = new double[4];
        double[] averageArea      = new double[4];
        string   header           = "Attack,Average Time Spent,Average Failures,Average Distance,Average Area";

        sw.WriteLine("--------" + chData.name + "--------");
        sw.WriteLine(header);

        for (int i = 0; i < 4; i++)
        {
            int attackID = LogParser.ReorderAttackID(i);
            averageTimeSpent[attackID] = chData.totalTimeSpent[attackID] / (
                chData.attempts[attackID] - chData.failures[attackID]
                );
            averageFailures[attackID] = (float)chData.failures[attackID] / chData.attempts[attackID];
            averageDistance[attackID] = chData.totalDistance[attackID] / chData.attempts[attackID];
            averageArea[attackID]     = chData.totalArea[attackID] / chData.attempts[attackID];

            string line = LogParser.AttackIDToName(attackID) + ",";
            line += averageTimeSpent[attackID].ToString(usCulture) + ",";
            line += averageFailures[attackID].ToString(usCulture) + ",";
            line += averageDistance[attackID].ToString(usCulture) + ",";
            line += averageArea[attackID].ToString(usCulture);
            sw.WriteLine(line);
        }
    }
示例#2
0
    static void WriteTotalAverages(ChallengeData[] chData, StreamWriter sw)
    {
        string header = "Attack,Average Time Spent,Average Failures,Average Distance,Average Area";

        sw.WriteLine(header);
        for (int i = 0; i < 4; i++)
        {
            int    attackID  = LogParser.ReorderAttackID(i);
            int    attempts  = 0;
            int    failures  = 0;
            int    successes = 0;
            float  timeSpent = 0f;
            double distance  = 0.0;
            double area      = 0.0;

            for (int subjectID = 0; subjectID < chData.Length; subjectID++)
            {
                int subjectSuccesses = chData[subjectID].attempts[attackID] - chData[subjectID].failures[attackID];
                if (subjectSuccesses > 0)
                {
                    // When calculating the total number of successes we must avoid cases where
                    // the subject did not succeed impacting the averages as negative values.
                    // (Remember that totalTimeSpent == 0 when a subject skips an attack)
                    successes += subjectSuccesses;
                }
                attempts  += chData[subjectID].attempts[attackID];
                failures  += chData[subjectID].failures[attackID];
                timeSpent += chData[subjectID].totalTimeSpent[attackID];
                distance  += chData[subjectID].totalDistance[attackID];
                area      += chData[subjectID].totalArea[attackID];
            }

            float  averageTimeSpent = timeSpent / successes;
            float  averageFailures  = (float)failures / attempts;
            double averageDistance  = distance / attempts;
            double averageArea      = area / attempts;

            string line = LogParser.AttackIDToName(attackID) + ",";
            line += averageTimeSpent.ToString(usCulture) + ",";
            line += averageFailures.ToString(usCulture) + ",";
            line += averageDistance.ToString(usCulture) + ",";
            line += averageArea.ToString(usCulture);
            sw.WriteLine(line);
        }
    }