Exemple #1
0
        public bool Analyze(Template template, Action <ThoughtProgress> progress = null)
        {
            TotalPositions = 0;
            FixerWonAllNearlyColorableBoards = true;

            EnsureSwapAnalyzerExistence();

            var minimumColorCount = Math.Max(MinPot, template.Sizes.Max());
            var maximumColorCount = Math.Min(MaxPot, template.Sizes.Sum());

            var foundAtLeastOneBoard = false;

            foreach (var colorCount in MetaKnowledge.Interval(minimumColorCount, maximumColorCount))
            {
                if (progress != null)
                {
                    progress(new ThoughtProgress()
                    {
                        IsInitialThought = true
                    });
                }

                var boards = GenerateAllBoards(template, colorCount, progress).ToList();
                if (foundAtLeastOneBoard && boards.Count <= 0)
                {
                    break;
                }

                TotalPositions      += boards.Count;
                foundAtLeastOneBoard = true;

                var breakerWin = !Analyze(boards, progress);
                if (breakerWin && StopAnalysisOnBreakerWin)
                {
                    return(false);
                }

                Knowledge[template].Promote(colorCount);
            }

            return(Knowledge[template].LostBoards.Count() <= 0);
        }