Ejemplo n.º 1
0
 internal IMetaKey Add(ICombination combination, KeyEvent keyEvent, KeyCommand command,
                       string stateTree = KeyStateTrees.Default)
 {
     return(Add(new List <ICombination> {
         combination
     }, keyEvent, command, stateTree));
 }
Ejemplo n.º 2
0
 public Draw(IList <IData> rawData, ICombination <int> model)
 {
     _model     = model;
     BallsArray = rawData.OfType <BaseData <int> >().Select(y => y.Data).ToArray();
     DrawDate   = DateData(rawData).Data;
     _dataForm.AddRange(rawData);
 }
Ejemplo n.º 3
0
        public IEnumerable <ICombination> ExtractSheetCombinations(DataTable sheet)
        {
            var combinations = new List <ICombination>();

            foreach (DataRow row in sheet.Rows)
            {
                bool canLoad = false;
                for (int i = 0; i < row.ItemArray.Length; i++)
                {
                    var item = row.ItemArray[i];
                    if (!(item is DBNull) && (item is DateTime))
                    {
                        canLoad = true;
                    }

                    if (canLoad)
                    {
                        ICombination combination = CombinationBuilder.CreateCombination(row.ItemArray, i + 1);
                        combinations.Add(combination);
                        break;
                    }
                }
            }

            return(combinations.Where(combination => combination.Columns.Count() > 0 && combination.Stars.Count() > 0));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// See <see cref="ICalculateCostService.Calculate(ICombination, IEnumerable{IEffect})"/>.
        /// </summary>
        public CombinationCostResult Calculate(ICombination combination, IEnumerable <IEffect> effects)
        {
            ArgumentChecks.AssertNotNull(combination, nameof(combination));
            ArgumentChecks.AssertNotNull(effects, nameof(effects));

            var totalDelayInDays = 0m;
            var totalCostOfDelay = 0m;

            var featureCostResults = new List <FeatureCostResult>();

            foreach (var feature in combination.Features)
            {
                var absoluteCostOfDelay = this._costCalculationHelper.CalculateAbsoluteCostOfDelayForFeature(
                    feature,
                    totalDelayInDays);

                // TODO: add effects....

                featureCostResults.Add(new FeatureCostResult(feature, absoluteCostOfDelay));

                totalDelayInDays += feature.DevelopmentDurationInDays;
                totalCostOfDelay += absoluteCostOfDelay;
            }

            return(new CombinationCostResult(
                       combination,
                       featureCostResults,
                       totalCostOfDelay));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// See <see cref="IContraintValidator.IsValid(ICombination)"/>.
        /// </summary>
        public bool IsValid(ICombination combination)
        {
            ArgumentChecks.AssertNotNull(combination, nameof(combination));

            // Special case: if the blocking feature isn't in the list at all, the
            // constraint is not relevant. Otherwise the constraint would block all
            // combinations.
            if (!combination.Features.Contains(this._constraint.BlockingFeature))
            {
                return(true);
            }

            foreach (var feature in combination.Features)
            {
                // If the blocked feature comes first...
                if (feature == this._constraint.BlockedFeature)
                {
                    return(false);
                }

                // If the blocking feature comes first...
                if (feature == this._constraint.BlockingFeature)
                {
                    return(true);
                }
            }

            // If neither the blocking nor the blocked feature is the list, the
            // constraint is not relevant.
            return(true);
        }
Ejemplo n.º 6
0
        public int VortexDegree(int[] balls, ICombination <int> model)
        {
            long index  = (long)model.GetIndexOf(balls, Comparer <int> .Default);
            long circle = model.TotalCombinations < 360 ? index / 9 : index / 360;


            return((int)(index - (circle * GetMax(model.TotalCombinations))));
        }
Ejemplo n.º 7
0
 private string GetCount(string primePattern, ICombination <int> model)
 {
     if (model is IMulitCombination <int> )
     {
         return(GetMultiCount(primePattern, model as IMulitCombination <int>));
     }
     return(primePattern.Count(x => x == 'Y').ToString());
 }
Ejemplo n.º 8
0
        public int VortexCircleLevel(int[] balls, ICombination <int> model)
        {
            long index = (long)model.GetIndexOf(balls, Comparer <int> .Default);

            long circle = index / GetMax(model.TotalCombinations);


            return((int)circle);
        }
Ejemplo n.º 9
0
 public Lottery(ILotterySpec spec)
 {
     Model             = spec.CreateModel();
     TotalBalls        = Model.TotalElements;
     BallsCount        = Model.ChosenElements;
     GameOdds          = 1 / (double)Model.TotalCombinations;
     TotalCombinations = Model.TotalCombinations;
     StartDay          = spec.BeginDay;
     PlayedWeekDay     = StartDay.DayOfWeek;
 }
Ejemplo n.º 10
0
        public SumIndex(ICombination <int> model, IFeaturesFactory featuresManager)
        {
            var model1 = model;

            _featuresManager = featuresManager;
            _minSum          = _featuresManager.SumOfBalls(_featuresManager.CreateDraw(model1.Element(0), model1));
            var maxSum = _featuresManager.SumOfBalls(_featuresManager.CreateDraw(model1.Element(model1.TotalCombinations - 1), model1));

            _factor = maxSum / _minSum;
        }
Ejemplo n.º 11
0
        public static IEnumerable <ICombination <T> > CompleteCombination <T>(ICombination <T> initialCombination,
                                                                              IEnumerable <T> newItems,
                                                                              IItemUtils <T> itemMethods,
                                                                              Length totalLength)
        {
            var sortedItems = newItems.SelectMany(item => item.ToSequence(itemMethods.getItemMaxCount(item))).ToSortedList();

            var optimalValues = new Dictionary <(int, Length), double>();

            sortedItems.ToList().ForEach(item => ComputeOptimalValues(item, itemMethods, optimalValues, totalLength));

            return(GetCombinationFromTable(initialCombination, optimalValues, sortedItems, itemMethods.getItemLength).ToSequence());
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CombinationCostResult"/> class.
        /// </summary>
        public CombinationCostResult(
            ICombination combination,
            IReadOnlyList <FeatureCostResult> featureCostResults,
            decimal aTotalCostOfDelay)
        {
            ArgumentChecks.AssertNotNull(combination, nameof(combination));
            ArgumentChecks.AssertNotNull(featureCostResults, nameof(featureCostResults));
            ArgumentChecks.AssertNotNegative(aTotalCostOfDelay, nameof(aTotalCostOfDelay));

            this.Combination        = combination;
            this.FeatureCostResults = featureCostResults;
            this.TotalCostOfDelay   = aTotalCostOfDelay;
        }
Ejemplo n.º 13
0
        private IData CreateDraw(int[] drawBalls, ICombination <int> model, DateTime drawDate)
        {
            List <IData> balls = new List <IData>
            {
                new BaseData <DateTime>(drawDate, "Date")
            };

            for (int i = 0; i < drawBalls.Length; i++)
            {
                balls.Add(new BaseData <int>(drawBalls[i], "Ball" + (i + 1)));
            }

            return(new Draw(balls, model));
        }
Ejemplo n.º 14
0
        private IData CreateDraw(List <int> drawBalls, ICombination <int> configModel, DateTime drawDate)
        {
            List <IData> balls = new List <IData>
            {
                new BaseData <DateTime>(drawDate, "Date")
            };

            for (int i = 0; i < drawBalls.Count; i++)
            {
                balls.Add(new BaseData <int>(drawBalls[i], "Ball" + (i + 1)));
            }

            return(new Draw(balls, configModel));
        }
Ejemplo n.º 15
0
        public List <IData> ToPatternMatches(BaseData <int>[] toArray, ICombination <int> model)
        {
            decimal index = model.GetIndexOf(toArray.Select(x => x.Data).ToArray(), Comparer <int> .Default);

            int[] actual = model.Element(index);
            Dictionary <string, string> patterns =
                new Dictionary <string, string>
            {
                { FeatureNames.FiboPattern, GetFiboPattern(actual) },
                { FeatureNames.PrimePattern, GetPrimePattern(actual) },
                { FeatureNames.PrimeCount, GetCount(GetPrimePattern(actual), model) },
                { FeatureNames.FiboCount, GetCount(GetFiboPattern(actual), model) }
            };

            return(patterns.Select(x => new FeatureData <string>(x.Key, x.Value) as IData).ToList());
        }
Ejemplo n.º 16
0
        public string Demo(ICombination combination)
        {
            bool combinationChecked = false;

            foreach (var combinationChecker in _checkers)
            {
                combinationChecked = combinationChecker.CheckCombination(combination);

                if (combinationChecked == true)
                {
                    return("Combination checked");
                }
            }

            return("No checker was able to process combination");
        }
Ejemplo n.º 17
0
        public IKey HardMap(ICombination source, ICombination target,
                            Predicate <IKeyEventArgs> predicate = null)
        {
            var handled = false;

            return(new KeyTokens()
            {
                source.Down(e =>
                {
                    handled = true;
                    e.Handled = true;
                    e.NoFurtherProcess = true;

                    InputSimu.Inst.Keyboard.ModifiedKeyDown(
                        target.Chord.Cast <VirtualKeyCode>(),
                        (VirtualKeyCode)(Keys)target.TriggerKey);
                }, predicate, "", KeyStateTrees.HardMap),
                source.Up(e =>
                {
                    handled = false;

                    e.Handled = true;
                    e.NoFurtherProcess = true;

                    InputSimu.Inst.Keyboard.ModifiedKeyUp(target.Chord.Cast <VirtualKeyCode>(),
                                                          (VirtualKeyCode)(Keys)target.TriggerKey);
                }, e =>
                {
                    if (!handled)
                    {
                        Console.WriteLine("\t/!Handling:false");
                        return false;
                    }

                    if (predicate != null && !predicate(e))
                    {
                        Console.WriteLine("\t/!predicate(e):false");
                        return false;
                    }

                    return true;
                }, "", KeyStateTrees.HardMap)
            });
        }
Ejemplo n.º 18
0
        /// <summary>
        /// down up happened successively
        /// </summary>
        internal IKey Hit(ICombination combination, Action <IKeyEventArgs> execute,
                          Predicate <IKeyEventArgs> canExecute = null, string description = "", string stateTree = KeyStateTrees.Default)
        {
            var           handling     = false;
            IKeyEventArgs keyDownEvent = null;
            var           token        = new KeyTokens
            {
                combination.Down(e =>
                {
                    handling     = true;
                    keyDownEvent = e;
                }, canExecute, description, stateTree),

                combination.Up(e =>
                {
                    if (!handling)
                    {
                        Console.WriteLine($"\t{combination}_Hit Down CanExecute:false");
                        return;
                    }

                    handling = false;

                    if (keyDownEvent == e.LastKeyDownEvent)
                    {
                        e.BeginInvoke(() => execute(e));
                    }
                    else
                    {
                        Console.WriteLine($"\t{combination}_Hit: last down event is not from me, Not Execute!");
                    }
                }, canExecute, description, stateTree)
            };

            return(token);
        }
Ejemplo n.º 19
0
 public VortexCircle(ICombination <int> model, IFeaturesFactory featuresManager)
 {
     _featuresManager = featuresManager;
     _model           = model;
 }
Ejemplo n.º 20
0
 public VortexCircle(ICombination <int> model) : this(model, new FeaturesFactory())
 {
 }
Ejemplo n.º 21
0
 public void Print(ICombination combination)
 {
     Console.WriteLine("Burge meal selected");
     combination.AddOn();
 }
Ejemplo n.º 22
0
 static bool choosePredicate(ICombination <T> _) => true;
Ejemplo n.º 23
0
 public PatternMatcher(ICombination <int> model, IFeaturesFactory featuresManager)
 {
     _featuresManager = featuresManager;
     _model           = model;
 }
Ejemplo n.º 24
0
 public static IKey  MapOnHit(this ISequenceUnit key, ICombination target,
                              Predicate <IKeyEventArgs> canExecute = null, bool allUp = true)
 {
     return(Keyboard.MapOnHit(key.ToCombination(), target, canExecute, allUp));
 }
Ejemplo n.º 25
0
 public SubIndex(ICombination <int> model, Choice choice) : base(model)
 {
     _model  = model;
     _choice = choice;
 }
Ejemplo n.º 26
0
 public SubIndex(ICombination <int> model, IFeaturesFactory featuresManager) : base(model, featuresManager)
 {
 }
Ejemplo n.º 27
0
 public Index(ICombination <int> model) : this(model, new FeaturesFactory())
 {
 }
Ejemplo n.º 28
0
 public Index(ICombination <int> model, IFeaturesFactory featuresManager)
 {
     _featuresManager = featuresManager;
     _model           = model;
 }
Ejemplo n.º 29
0
 public IMetaKey Add(ICombination combination, KeyEventCommand command)
 {
     return(Add(new List <ICombination> {
         combination
     }, command));
 }
 public void Print(ICombination combination)
 {
     Console.WriteLine("Popcorn chicken meal selected");
     combination.AddOn();
 }
Ejemplo n.º 31
0
 public void Print(ICombination combination)
 {
     Console.WriteLine("Variety meal selected");
     combination.AddOn();
 }
Ejemplo n.º 32
0
 public static IKey  Map(this ISequenceUnit key, ICombination target,
                         Predicate <IKeyEventArgs> canExecute = null, int repeat = 1)
 {
     return(Keyboard.Map(key.ToCombination(), target, canExecute, repeat));
 }