def executeNExperiences(self, grades, moduleDict,
                            solutionDict, n, checkValuesAndPolicy):
        testPass = True
        valuesPretty, qValuesPretty, actions, policyPretty, lastExperience = self.runAgent(
            moduleDict, n)
        stdOutString = ''
        fileOutString = "==================== Iteration %d ====================\n" % n
        if lastExperience is not None:
            fileOutString += "Agent observed the transition (startState = %s, action = %s, endState = %s, reward = %f)\n\n\n" % lastExperience
        for action in actions:
            qValuesKey = 'q_values_k_%d_action_%s' % (n, action)
            qValues = qValuesPretty[action]
            if self.comparePrettyValues(qValues, solutionDict[qValuesKey]):
                fileOutString += "Q-Values at iteration %d for action '%s' are correct." % (
                    n,
                    action)
                fileOutString += "   Student/correct solution:\n\t%s" % self.prettyValueSolutionString(
                    qValuesKey,
                    qValues)
            else:
                testPass = False
                outString = "Q-Values at iteration %d for action '%s' are NOT correct." % (
                    n,
                    action)
                outString += "   Student solution:\n\t%s" % self.prettyValueSolutionString(
                    qValuesKey,
                    qValues)
                outString += "   Correct solution:\n\t%s" % self.prettyValueSolutionString(
                    qValuesKey,
                    solutionDict[qValuesKey])
                stdOutString += outString
                fileOutString += outString
        if checkValuesAndPolicy:
            if not self.comparePrettyValues(valuesPretty, solutionDict['values']):
                testPass = False
                outString = "Values are NOT correct."
                outString += "   Student solution:\n\t%s" % self.prettyValueSolutionString(
                    'values',
                    valuesPretty)
                outString += "   Correct solution:\n\t%s" % self.prettyValueSolutionString(
                    'values',
                    solutionDict['values'])
                stdOutString += outString
                fileOutString += outString
            if not self.comparePrettyValues(policyPretty, solutionDict['policy']):
                testPass = False
                outString = "Policy is NOT correct."
                outString += "   Student solution:\n\t%s" % self.prettyValueSolutionString(
                    'policy',
                    policyPretty)
                outString += "   Correct solution:\n\t%s" % self.prettyValueSolutionString(
                    'policy',
                    solutionDict['policy'])
                stdOutString += outString
                fileOutString += outString
        return testPass, stdOutString, fileOutString
dataset/ETHPy150Open rlpy/rlpy/rlpy/Domains/PacmanPackage/reinforcementTestClasses.py/QLearningTest.executeNExperiences/original