public MachineTestAnalysisResultPrinter(MachineTestConfig config, MachineTestUserResult userResult, MachineTestAnalysisResult analysisResult)
 {
     _mode           = MachineTestAnalysisMode.User;
     _config         = config;
     _userResult     = userResult;
     _analysisResult = analysisResult;
 }
    private void PrintMachineResultAnalysis(MachineTestMachineResult machineResult)
    {
        string machineDir = Path.Combine(_outputDir, machineResult.MachineName) + "/";

        Directory.CreateDirectory(machineDir);

        for (int i = 0; i < machineResult.UserResults.Count; i++)
        {
            MachineTestUserResult userResult = machineResult.UserResults[i];

            MachineTestUserResultPrinter userPrinter = new MachineTestUserResultPrinter(userResult);
            userPrinter.WriteResult(machineDir, MachineTestPrintFileNameMode.UserId);

            MachineTestAnalysisResult singleAnalysisResult = MachineTestAnalysisHelper.Instance.AnalyzeSingleUser(userResult);
            userResult.AnalysisResult = singleAnalysisResult;

            MachineTestAnalysisResultPrinter singleAnalysisPrinter = new MachineTestAnalysisResultPrinter(_config, userResult, singleAnalysisResult);
            singleAnalysisPrinter.WriteResult(machineDir);
        }

        MachineTestAnalysisResult analysisResult = MachineTestAnalysisHelper.Instance.AnalyzeSingleMachine(machineResult, _config._userCount);

        machineResult.AnalysisResult = analysisResult;

        MachineTestAnalysisResultPrinter analysisPrinter = new MachineTestAnalysisResultPrinter(_config, machineResult, analysisResult);

        analysisPrinter.WriteResult(machineDir);
    }
    void OutputPrintMachineResult(MachineTestMachineResult machineResult, MachineSeedGenConfig genConfig)
    {
        if (genConfig._isOutputUserResult)
        {
            string machineDir = Path.Combine(_outputUserResultDir, machineResult.MachineName) + "/";
            if (Directory.Exists(machineDir))
            {
                DirectoryInfo info = new DirectoryInfo(machineDir);
                foreach (FileInfo file in info.GetFiles())
                {
                    file.Delete();
                }
            }

            Directory.CreateDirectory(machineDir);

            for (int i = 0; i < machineResult.UserResults.Count; i++)
            {
                MachineTestUserResult userResult = machineResult.UserResults[i];

                MachineTestUserResultPrinter userPrinter = new MachineTestUserResultPrinter(userResult);
                userPrinter.WriteResult(machineDir, MachineTestPrintFileNameMode.Seed);
            }
        }
    }
    bool IsUserResultPassLimitConfigs(MachineTestUserResult userResult, List <MachineSeedLimitationConfig> limitConfigs)
    {
        bool result = ListUtility.IsAllElementsSatisfied(limitConfigs, (MachineSeedLimitationConfig config) => {
            bool r = IsUserResultPassSingleLimitConfig(userResult, config);
            return(r);
        });

        return(result);
    }
    public MachineTestMachineResult RunSingleMachine(string machineName)
    {
        MachineTestMachineResult machineResult = new MachineTestMachineResult(machineName);

        for (int i = 0; i < _config._userCount; i++)
        {
            MachineTestUserResult userResult = RunSingleUser(machineName, i);
            machineResult.AddUserResult(userResult);
        }

        return(machineResult);
    }
    List <uint> FilterMachineSeeds(MachineTestMachineResult machineResult, List <MachineSeedLimitationConfig> limitConfigs)
    {
        List <uint> result = new List <uint>();

        for (int i = 0; i < machineResult.UserResults.Count; i++)
        {
            MachineTestUserResult userResult = machineResult.UserResults[i];
            bool isPass = IsUserResultPassLimitConfigs(userResult, limitConfigs);
            if (isPass)
            {
                result.Add(userResult.StartSeed);
            }
        }

        return(result);
    }
    public MachineTestAnalysisResult AnalyzeSingleUser(MachineTestUserResult userResult)
    {
        _machineConfig = MachineConfig.Instance;

        MachineTestAnalysisResult result = new MachineTestAnalysisResult();

        result._spinCountBeforeReachLuckyThreshold = GetSpinCountBeforeReachLuckyThreshold(userResult.RoundResults);
        result._spinCountBeforeLuckyZero           = GetSpinCountBeforeLuckyZero(userResult.RoundResults);

        for (int i = 0; i < (int)MachineTestLuckyMode.Count; i++)
        {
            MachineTestLuckyMode mode = (MachineTestLuckyMode)i;
            result._luckyModeResults[(int)mode] = GetLuckyModeResult(mode, userResult.RoundResults);
        }

        return(result);
    }
    private MachineTestUserResult RunSingleUser(string machineName, int userIndex)
    {
        uint startSeed = GetUserRandSeed(userIndex);

        // set longLucky first, then init machine
        UserBasicData.Instance.SetLongLucky(_config._initLucky, false);

        // reset pay protection
        bool bakcupPayProtectionState = ResetUserDataPayProtection();

        CoreMachine machine = new CoreMachine(machineName, startSeed);

        MachineTestUserResult userResult = RunSingleUserResult(machine, userIndex, startSeed);

        // recovery pay protection
        RecoveryUserDataPayProtection(bakcupPayProtectionState);

        return(userResult);
    }
    bool IsUserResultPassSingleLimitConfig(MachineTestUserResult userResult, MachineSeedLimitationConfig limitConfig)
    {
        bool result = false;
        List <MachineTestRoundResult> roundResults = userResult.RoundResults;

        if (limitConfig._type == MachineSeedLimitationType.Bankcrupt)
        {
            Debug.Assert(limitConfig._startSpinCount < limitConfig._endSpinCount);

            for (int i = limitConfig._startSpinCount; i < limitConfig._endSpinCount && i < roundResults.Count; i++)
            {
                MachineTestRoundResult roundResult = roundResults[i];
                if (roundResult._output._remainCredit <= 0)
                {
                    result = true;
                    break;
                }
            }
        }
        else if (limitConfig._type == MachineSeedLimitationType.CreditRange)
        {
            if (limitConfig._spinCount <= roundResults.Count)
            {
                MachineTestRoundResult roundResult = roundResults[limitConfig._spinCount - 1];
                long remainCredit = roundResult._output._remainCredit;
                result = (remainCredit >= limitConfig._minCredit && remainCredit <= limitConfig._maxCredit);
            }
            else
            {
                // just treat it as not passed
                result = false;
            }
        }
        else
        {
            Debug.Assert(false);
        }

        return(result);
    }
    private MachineTestUserResult RunSingleUserResult(CoreMachine machine, int userIndex, uint startSeed)
    {
        MachineTestUserResult userResult = new MachineTestUserResult(machine, userIndex, _config._spinCount, startSeed);

        MachineTestIndieGameManager indieGameManager = new MachineTestIndieGameManager(machine);
        MachineTestRound            round            = new MachineTestRound(machine, _config, indieGameManager);
        MachineTestInput            input            = null;
        MachineTestOutput           output           = null;

        for (int i = 0; i < _config._spinCount; i++)
        {
            bool canRun = true;
            do
            {
                input  = round.ConstructInput(output);
                canRun = round.CanRun(input);
                if (canRun)
                {
                    output = round.Run(input);
                    MachineTestRoundResult roundResult = new MachineTestRoundResult(input, output);
                    userResult.AddRoundResult(roundResult);
                }
                else
                {
                    break;
                }
            } while(output._shouldRespin);

            if (!canRun)
            {
                break;
            }
        }

        return(userResult);
    }
Beispiel #11
0
 public MachineTestUserResultPrinter(MachineTestUserResult userResult)
 {
     _userResult = userResult;
 }
Beispiel #12
0
 public void AddUserResult(MachineTestUserResult userResult)
 {
     _userResults.Add(userResult);
 }