public static void Reset()
        {
            Board           = new SampleBoard();
            SpaceChecker    = new SampleSpaceChecker();
            PiecePosition   = new SamplePiecePosition();
            PieceConnection = new PieceConnection();
            PointerInput    = new SamplePointerInput();

            PieceObjectFactory    = null;
            InitialPieceGenerator = new SampleInitialPieceGenerator();
            PoppedPieceGenerator  = new SamplePoppedPieceGenerator();
            UserRankCalculator    = null;

            ScoreCalculator = null;
            BonusCalculator = null;

            StartEffect = null;
            BonusEffect = null;

            Combinations.Clear();
            Combinations.Add(new SameColorCombination());
            CombinationsViewer = new SampleCombinationsViewer();
            BonusSpaceChecker  = new SampleBonusSpaceChecker();
            BonusSpaceInfo     = new SampleBonusSpaceInfo();
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the cases.
        /// </summary>
        public void FillCases()
        {
            if (_loadCombinations == null)
            {
                return;
            }
            _loadCombinations.GetCaseList(Name,
                                          out var caseComboTypes,
                                          out var caseComboNames,
                                          out var scaleFactors);

            for (int i = 0; i < scaleFactors.Length; i++)
            {
                switch (caseComboTypes[i])
                {
                case eCaseComboType.LoadCase:
                    LoadCase loadCase = LoadCase.Factory(caseComboNames[i]);
                    Cases.Add(new LoadTuple <LoadCase>(loadCase, scaleFactors[i]));
                    break;

                case eCaseComboType.LoadCombo:
                    LoadCombination loadCombo = Factory(caseComboNames[i]);
                    Combinations.Add(new LoadTuple <LoadCombination>(loadCombo, scaleFactors[i]));
                    break;

                default:
                    break;
                }
            }
        }
Esempio n. 3
0
 private void addCombinationNr(double totalCombinations)
 {
     if (Combinations.LastOrDefault() != totalCombinations)
     {
         Combinations.Add(totalCombinations);
     }
 }
Esempio n. 4
0
 public ParameterInteraction(ParameterInteraction interaction)
 {
     this.parameters = new List <int>(interaction.Parameters);
     foreach (var combination in interaction.Combinations)
     {
         var newCombination = new ValueCombination(combination);
         Combinations.Add(newCombination);
     }
 }
 /// <summary> Generates all stock quantity combinations and stores the best ones. </summary>
 public void GenerateCombinations()
 {
     Combinations.Clear(); // Clear list if running again.
     Parallel.For(0, (long)NumberOfPossibleCombinations, (id) =>
     {
         // It is much faster to get a combination cost than the combination itself.
         if (IsCostInRange(GetCombinationCostById((ulong)id)))
         {
             Combinations.Add(GetCombinationById((ulong)id));
         }
     });
 }
 /// <summary>
 /// Adds or modifies one response combination in the list of cases included in the load combination.
 /// </summary>
 /// <param name="loadCombination">The load combination included within the load combination.</param>
 /// <param name="scaleFactor">The scale factor multiplying the combination.</param>
 public void SetComboList(
     LoadCombination loadCombination,
     double scaleFactor)
 {
     if (Combinations.Any(c => c.Load == loadCombination))
     {
         var combinations = new List <LoadTuple <LoadCombination> >(Combinations.Where(c => c.Load == loadCombination));
         combinations[0].Scale = scaleFactor;
     }
     else
     {
         Combinations.Add(new LoadTuple <LoadCombination>(loadCombination, scaleFactor));
     }
 }
 /// <summary>
 /// Adds or modifies one response combination in the list of cases included in the load combination.
 /// </summary>
 /// <param name="loadCombination">The load combination included within the load combination.</param>
 /// <param name="scaleFactor">The scale factor multiplying the combination.</param>
 /// <exception cref="CSiException"><see cref="CSiApiBase.API_DEFAULT_ERROR_CODE" /></exception>
 public void SetComboList(
     LoadCombination loadCombination,
     double scaleFactor)
 {
     _apiLoadCombinations.SetCaseList(Name, eCaseComboType.LoadCombo, loadCombination.Name, scaleFactor);
     if (Combinations.Any(c => c.Load == loadCombination))
     {
         var combinations = new List <LoadTuple <LoadCombination> >(Combinations.Where(c => c.Load == loadCombination));
         combinations[0].Scale = scaleFactor;
     }
     else
     {
         Combinations.Add(new LoadTuple <LoadCombination>(loadCombination, scaleFactor));
     }
 }
Esempio n. 8
0
        /// <summary>
        /// Генерирование комбинаций приоритетов операторов
        /// </summary>
        public void MakePermutation()
        {
            List <int> combination = new List <int>();

            for (int i = 0; i < Operators.Count; i++)
            {
                combination.Add(0); // особенность алгоритма =), TODO: заменить на нормальный алгоритм сознания перестановок
            }
            while (true)
            {
                var size = this.Operators.Count;
                if (size == 0)
                {
                    Combinations.Clear();
                    Combinations.Add(new List <int>(combination));
                    return;
                }

                if (combination.Distinct().Count() == size)
                {
                    Combinations.Add(new List <int>(combination));
                }

                combination[0]++;
                if (combination[0] == size)
                {
                    for (int i = 0; i < size; i++)
                    {
                        if (combination[size - 1] == size)
                        {
                            return;
                        }
                        if (combination[i] == size)
                        {
                            combination[i + 1]++;
                            combination[i] -= size;
                        }
                    }
                }
            }
        }
Esempio n. 9
0
 public LeetCodeDecoder()
 {
     No_of_ways = 0;
     Combinations.Add("");
 }
Esempio n. 10
0
        public void Solve()
        {
            ensureDataLoaded();
            Boards.Clear();
            Solutions.Clear();
            var level = 1;

            MaxLevelReached = 1;
            Combinations.Clear();
            var totalCombinations = GetTotalCombinations();

            Combinations.Add(totalCombinations);
            var prevCombinations = totalCombinations;
            var boardSize        = Math.Max(_data.Width, _data.Height);

            while (true)
            {
                // get all possible combinations of nr+1 indexes, so that we can filter the possibilities away
                // nr=0 means the possible combinations are just one of each perpendicular rows or columns
                // nr=1 means possibilities are weighed against every combination in any two perpendicular rows or columns,etc
                var piRows = getAllPossibleIndexes(_data.Height, level);
                filterPossibilities(_colPossibilities, _rowPossibilities, piRows); // filter column possibilities by rows
                totalCombinations = GetTotalCombinations();
                addCombinationNr(totalCombinations);
                generateBoard(); // generates a board with partial results

                if (prevCombinations != totalCombinations)
                {
                    level = 1;
                }
                Debug.WriteLine($"Combinations so far: {totalCombinations}, level: {level}, max level reached: {MaxLevelReached}");
                Console.WriteLine($"Combinations so far: {totalCombinations}, level: {level}, max level reached: {MaxLevelReached}");

                var piCols = getAllPossibleIndexes(_data.Width, level);
                filterPossibilities(_rowPossibilities, _colPossibilities, piCols); // filter row possibilities by columns
                totalCombinations = GetTotalCombinations();
                if (totalCombinations <= 1)
                {
                    break;
                }
                addCombinationNr(totalCombinations);
                generateBoard(); // generates a board with partial results

                if (prevCombinations == totalCombinations)
                {
                    if (level <= boardSize && level < MaxPuzzleLevel)
                    {
                        level++;
                        if (level > MaxLevelReached)
                        {
                            MaxLevelReached = level;
                        }
                    }
                    else
                    {
                        Debug.WriteLine("Maximum puzzle level reached");
                        Console.WriteLine("Maximum puzzle level reached. Starting brute force (it will take a while, please wait...)");
                        break;
                    }
                }
                else
                {
                    level = 1;
                }
                Debug.WriteLine($"Combinations so far: {totalCombinations}, level: {level}, max level reached: {MaxLevelReached}");
                Console.WriteLine($"Combinations so far: {totalCombinations}, level: {level}, max level reached: {MaxLevelReached}");

                prevCombinations = totalCombinations;
            }
            // fill all possible solutions from the remaining column and row possibilities
            generateSolutions();
        }