Ejemplo n.º 1
0
        public bool Analyze(IAssignment <TColorSet, TVertexSet> assignment, HashSet <IAssignment <TColorSet, TVertexSet> > targets)
        {
            for (int i = 0; i < assignment.PotSize; i++)
            {
                for (int j = i + 1; j < assignment.PotSize; j++)
                {
                    var swappable = assignment.GetSwappable(i, j);

                    var winningSwapAlwaysExists = true;
                    foreach (var breakerChoice in GetBreakerChoices(swappable))
                    {
                        var winningSwapExists = false;

                        foreach (var response in GetFixerResponses(breakerChoice))
                        {
                            var swappedAssignment = assignment.PerformSwap(i, j, response);
                            if (targets.Contains(swappedAssignment))
                            {
                                winningSwapExists = true;
                                break;
                            }
                        }

                        if (!winningSwapExists)
                        {
                            winningSwapAlwaysExists = false;
                            break;
                        }
                    }

                    if (winningSwapAlwaysExists)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }