コード例 #1
0
ファイル: MasterMind.cs プロジェクト: bbumblebee/MasterMind
        public virtual MoveNode runOneStepAheadAnalysis(Type assessor)
        {
            AssessmentManager   manager             = new AssessmentManager(config, assessor, currentPos.PossibilitySize);
            SymmetryEnvironment symmetryEnvironment = new SymmetryEnvironment(currentPos);
            ResultSet           resultSet           = new ResultSet(symmetryEnvironment, config);

            Parallel.For(short.MinValue, short.MinValue + config.combinations, m => {
                MoveNode testMove = currentPos.addTemporarySubMove((short)m);
                PossibilityDivisionAssessor assess = manager.getSetAssessor();
                if (!resultSet.symmetryEnvironment.checkSymmetry(testMove))
                {
                    return;
                }
                for (int i = 0; i < resultSet.config.grades; i++)
                {
                    MoveNode.GradeNode tempGrade = testMove.addSubGrade(i);
                    if (tempGrade.PossibilitySize == 0)
                    {
                        tempGrade.unregister();
                        continue;
                    }
                    assess.updateNextIndividual(tempGrade.PossibilitySize);
                    if (!assess.check(resultSet.config.grades - i - 1))
                    {
                        return;
                    }
                }
                lock (resultSet)
                {
                    if (!assess.check(0))
                    {
                        return;
                    }
                    assess.updateBestValue();
                    testMove.AssessmentValue = assess.CurrentSetValue;
                    resultSet.BestMove       = testMove;
                }
            });

            currentPos.addSubNode(resultSet.BestMove);
            return(resultSet.BestMove);
        }