internal IMetaKey Add(ICombination combination, KeyEvent keyEvent, KeyCommand command, string stateTree = KeyStateTrees.Default) { return(Add(new List <ICombination> { combination }, keyEvent, command, stateTree)); }
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); }
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)); }
/// <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)); }
/// <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); }
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)))); }
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()); }
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); }
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; }
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; }
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()); }
/// <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; }
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)); }
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)); }
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()); }
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"); }
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) }); }
/// <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); }
public VortexCircle(ICombination <int> model, IFeaturesFactory featuresManager) { _featuresManager = featuresManager; _model = model; }
public VortexCircle(ICombination <int> model) : this(model, new FeaturesFactory()) { }
public void Print(ICombination combination) { Console.WriteLine("Burge meal selected"); combination.AddOn(); }
static bool choosePredicate(ICombination <T> _) => true;
public PatternMatcher(ICombination <int> model, IFeaturesFactory featuresManager) { _featuresManager = featuresManager; _model = model; }
public static IKey MapOnHit(this ISequenceUnit key, ICombination target, Predicate <IKeyEventArgs> canExecute = null, bool allUp = true) { return(Keyboard.MapOnHit(key.ToCombination(), target, canExecute, allUp)); }
public SubIndex(ICombination <int> model, Choice choice) : base(model) { _model = model; _choice = choice; }
public SubIndex(ICombination <int> model, IFeaturesFactory featuresManager) : base(model, featuresManager) { }
public Index(ICombination <int> model) : this(model, new FeaturesFactory()) { }
public Index(ICombination <int> model, IFeaturesFactory featuresManager) { _featuresManager = featuresManager; _model = model; }
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(); }
public void Print(ICombination combination) { Console.WriteLine("Variety meal selected"); combination.AddOn(); }
public static IKey Map(this ISequenceUnit key, ICombination target, Predicate <IKeyEventArgs> canExecute = null, int repeat = 1) { return(Keyboard.Map(key.ToCombination(), target, canExecute, repeat)); }