/// <summary> /// Combine ingredients and return the result /// </summary> /// <param name="foods"></param> /// <param name="method"></param> /// <returns></returns> public Ingredient CombineIngredients(List<Ingredient> foods, PrepMethod method) { Ingredient newIngredient; Combination former = new Combination(foods, method); Combination combo = combinations.FirstOrDefault(c => c.Equals(former)); if(combo == null) { newIngredient = failure; } else { newIngredient = combo.product; } //Clear that list of ingredients // but derpily keep them around for checks foreach(var food in foods) { food.ClearAll(); food.transform.SetParent(transform); } newIngredient = GameObject.Instantiate(newIngredient); newIngredient.formingCombination = former; return newIngredient; }
public Program() { odd = new List<Combination>(); even = new List<Combination>(); same = new List<Combination>(); seed = new List<Combination>(); for (int i = 0; i <= 9; i++) { for (int j = 0; j <= 9; j++) { Combination combo = new Combination(i, j); if (combo.IsOdd()) { odd.Add(combo); if(i != 0 && j != 0 && i <= j) { seed.Add(combo); } } else { even.Add(combo); } if(i == j) { same.Add(combo); } } } }
public static bool IsCombination(ref Combination combination) { var result = false; var three = new Three(combination); var center = three.Center; if(center.Up.IsNotNullOrEmpty() && center.Up.ChildItem.Type == three.Type && center.Down.IsNotNullOrEmpty() && center.Down.ChildItem.Type == three.Type) { three.ThreeVariants.Add(new Variant() { Cells = new Cell[] { center.Down, center, center.Up }, Orientation = Orientation.Vertical }); result = true; } if(center.Left.IsNotNullOrEmpty() && center.Left.ChildItem.Type == three.Type && center.Right.IsNotNullOrEmpty() && center.Right.ChildItem.Type == three.Type) { three.ThreeVariants.Add(new Variant() { Cells = new Cell[] { center.Left, center, center.Right }, Orientation = Orientation.Horizontal }); result = true; } if(center.Up.IsNotNullOrEmpty() && center.Up.ChildItem.Type == three.Type && center.Up.Up.IsNotNullOrEmpty() && center.Up.Up.ChildItem.Type == three.Type) { three.ThreeVariants.Add(new Variant() { Cells = new Cell[] { center, center.Up, center.Up.Up }, Orientation = Orientation.Vertical }); result = true; } if(center.Down.IsNotNullOrEmpty() && center.Down.ChildItem.Type == three.Type && center.Down.Down.IsNotNullOrEmpty() && center.Down.Down.ChildItem.Type == three.Type) { three.ThreeVariants.Add(new Variant() { Cells = new Cell[] { center.Down.Down, center.Down, center }, Orientation = Orientation.Vertical }); result = true; } if(center.Left.IsNotNullOrEmpty() && center.Left.ChildItem.Type == three.Type && center.Left.Left.IsNotNullOrEmpty() && center.Left.Left.ChildItem.Type == three.Type) { three.ThreeVariants.Add(new Variant() { Cells = new Cell[] { center.Left.Left, center.Left, center }, Orientation = Orientation.Horizontal }); result = true; } if(center.Right.IsNotNullOrEmpty() && center.Right.ChildItem.Type == three.Type && center.Right.Right.IsNotNullOrEmpty() && center.Right.Right.ChildItem.Type == three.Type) { three.ThreeVariants.Add(new Variant() { Cells = new Cell[] { center, center.Right, center.Right.Right }, Orientation = Orientation.Horizontal }); result = true; } if(result) { three.Cells = three.ThreeVariants.FirstOrDefault().Cells; combination = three; } return result; }
static void Main(string[] args) { Combination<int, string> winningCombination = new Combination<int, string>(1, 2, 3, "a", "b", "c"); Combination<int, string> newCombination = new Combination<int, string>(1, 2, 3, "a", "c", "b"); LottoGame<int, string> obj = new LottoGame<int, string>(winningCombination); obj.UserCombination(newCombination); LottoResult<int, string> obj1 = new LottoResult<int, string>(winningCombination, newCombination); }
public Hand(CardCollection cards, Combination HandType) : base(cards) { if (cards == null || cards.Count <= 0) throw new InvalidOperationException("You cannot add an empty collection of cards to a hand."); m_cmbBestCombination = HandType; base.Sort(); m_cdHighCard = base[base.Count - 1]; }
static void Main() { Console.ForegroundColor = ConsoleColor.Green; Console.Write("How many combinations will you enter: "); int numberOfCombinations = int.Parse(Console.ReadLine()); Console.WriteLine("\nA combination is comprised of 6 values. The first three values should share the same C# type(this should be the case with the second three values as well).\n"); Combination<int, string> winningCombination = new Combination<int, string>(new int[] { 1, 2, 3 }, new string[] { "pesho", "gosho", "ivan" }); LottoGame<int, string> lottoGame = new LottoGame<int, string>(winningCombination); Console.ForegroundColor = ConsoleColor.Yellow; int count = 1; while (count <= numberOfCombinations) { Console.Write("Combination {0}:\n", count); Console.Write("\tValue 1(int): "); int value1 = int.Parse(Console.ReadLine()); Console.Write("\tValue 2(int): "); int value2 = int.Parse(Console.ReadLine()); Console.Write("\tValue 3(int): "); int value3 = int.Parse(Console.ReadLine()); Console.Write("\tValue 4(string): "); string value4 = Console.ReadLine(); Console.Write("\tValue 5(string): "); string value5 = Console.ReadLine(); Console.Write("\tValue 6(string): "); string value6 = Console.ReadLine(); Combination<int, string> currentComb = new Combination<int, string>(new int[] { value1, value2, value3 }, new string[] { value4, value5, value6 }); if (lottoGame.CheckIfExists(currentComb)) { Console.WriteLine("The current combination has already been entered! Try again."); continue; } else { lottoGame.AddUserCombination(currentComb); } Console.WriteLine(); count++; } LottoResult<int, string> lottoResult = lottoGame.Validate(); if (lottoResult.IsWinning) { Console.WriteLine("Congratulations! Your best combination has {0} matching values!", lottoResult.MatchedNumbersCount); } else { Console.WriteLine("Unfortunately there are no winning combinations among the ones given."); } }
protected Combination GetRandomCombination() { /*var combos = MasterIngredientList.Instance.combinations; var r = UnityEngine.Random.Range(0, combos.Count); return combos[r];*/ int numI = UnityEngine.Random.Range(1, 3); var bases = MasterIngredientList.Instance.baseIngredients; bases = RandomArrayTool.Randomize<Ingredient>(bases.ToArray()).ToList(); var ingredients = bases.Take(numI).ToList(); Combination combo = new Combination(ingredients, (PrepMethod) UnityEngine.Random.Range(0, 2)); return combo; }
public void PopulateRecipe(Combination combination) { string instructions = combination.method.ToString() + " "; for (int i = 0; i < combination.ingredients.Count; i++) { instructions += combination.ingredients[i].ToString(); if (i != combination.ingredients.Count - 1) { instructions += ", "; } } text.text = instructions; }
static void Main(string[] args) { List<Combination<int, string>> comboList = new List<Combination<int, string>>(); Combination<int, string> combo1 = new Combination<int, string>(1, 2, 6, "a", "b", "v"); Combination<int, string> combo2 = new Combination<int, string>(1, 2, 6, "a", "b", "v"); Combination<int, string> combo3 = new Combination<int, string>(1, 5, 3, "lotto", "totto", "v"); Combination<int, string> combo4 = new Combination<int, string>(3, 4, 5, "toto", "lotto", "game"); Combination<int, string> combo5 = new Combination<int, string>(1, 2, 6, "a", "b", "v"); comboList.Add(combo1); comboList.Add(combo2); comboList.Add(combo3); comboList.Add(combo4); comboList.Add(combo5); Combination<int, string>[] comboArray = comboList.ToArray(); LottoGame<int, string> lotto = new LottoGame<int, string>(comboArray); lotto.Validate(); }
public void SetCombination() { combination = GetRandomCombination(); //actual ingredient doesn't matter var newIngredient = MasterIngredientList.Instance.baseIngredients[0]; newIngredient = (Ingredient)GameObject.Instantiate(newIngredient); newIngredient.transform.SetParent(transform); newIngredient.gameObject.SetActive(false); newIngredient.formingCombination = combination; combination.product = newIngredient; //Populate recipe text PopulateRecipe(combination); }
public static void Main() { Combination<int, string> winning = new Combination<int, string>(1, 2, 3, "ivan", "pesho", "gosho"); LottoGame<int,string> game = new LottoGame<int,string>(winning); while (true) { string[] input = Console.ReadLine().Split(' '); Combination<int, string> combination = new Combination<int, string>(int.Parse(input[0]),int.Parse(input[1]),int.Parse(input[2]),input[3],input[4],input[5]); game.Add(combination); var result = game.Validate(); Console.WriteLine("isWinning: {0}, MatchValues: {1}", result.isWinning,result.MatchedNumbersCount); if (input[0] == "stop") { break; } } }
private List<Combination> GeneratePermutations(Combination numbers) { List<Combination> permutations = new List<Combination>(); if (1 == numbers.Length) { permutations.Add (numbers); return permutations; } for (var i=0; i<numbers.Length; i++) { List<Combination> subPerm = GeneratePermutations (numbers.GetSubCombination(i, numbers.Step+1)); foreach (var sub in subPerm) { var newNumbers = new int[numbers.Length]; newNumbers [0] = numbers [i]; var length = sub.Length; Array.Copy (sub.Numbers, 0, newNumbers, 1, length); permutations.Add (new Combination(newNumbers, sub.Step)); } } return permutations; }
public int GetSortOperations() { Queue<Combination> combinations = new Queue<Combination> (); combinations.Enqueue (StartNumbers); int combinationsCount = 0; while (combinations.Count > 0) { Combination current = combinations.Dequeue (); if (IsSorted (current.Numbers)) { if( 0 == current.Step % ReorderCount ) { return current.Step / ReorderCount; } } combinationsCount++; var next = new Combination(current.Numbers, current.Step+1); List<Combination> permutations = GeneratePermutations( next ); foreach (var perm in permutations) { if (!PermutationExists (perm.Numbers)) { combinations.Enqueue (perm); } } } return -1; }
//保存方案数据 public static void SaveData(RuleInfo[] ruleList, string fileName) { List<int> RedBall = new List<int>(33); for (int i = 0; i <33 ; i++) RedBall.Add (i +1); int[][] Red = new Combination(RedBall.Count , 6).Rows.Select (n => Combination.Permute(n, RedBall ).ToArray()).ToArray(); LotTickData[] res = Red.Select (n=>new LotTickData (n )).ToArray (); Dictionary<int, string> filterInfos = new Dictionary<int,string> (); LotTickData[] data = FilterByRules(res ,ruleList , out filterInfos); //方案保存不涉及最高优先级的杀号,因此可以直接进行过滤操作 if (!File.Exists(fileName)) throw new Exception("文件不存在"); NewLife.Serialization.BinaryWriterX binX = new NewLife.Serialization.BinaryWriterX(); FileStream fs = new FileStream(fileName, FileMode.Create); binX.Writer = new BinaryWriter(fs); binX.WriteObject (ruleList,typeof (LotTickData[]),null ); }
static void Main(string[] args) { CardMask cm1 = new CardMask(CardMaskRank.Ace, null); CardMask cm2 = new CardMask(CardMaskRank.HighCard, null); CardMask cm3 = new CardMask(CardMaskRank.Ace, CardMaskSuit.Trump); CardMask cm4 = new CardMask(CardMaskRank.HighCard, CardMaskSuit.Trump); CardsSetMask csm1 = new CardsSetMask(new CardMask[] { cm4, cm2, cm2, cm1 }); CardsSetMask csm2 = new CardsSetMask(new CardMask[] { cm2, cm2, cm2, cm3 }); Combination[] combinations = new Combination[] { new Combination("Москва", new CardsSetMask[] { csm1, csm2 }) }; CombinationsChecker combinationsChecker = new CombinationsChecker(combinations); Suit trump = Suit.Spades; Card[] cards = new Card[] { new Card(Rank.Ten, trump), new Card(Rank.Ten, Suit.Hearts), new Card(Rank.Six, Suit.Hearts), new Card(Rank.Jack, Suit.Diamonds) }; var res = combinationsChecker.GetRealizedCombinations(cards, trump); int sjk = 489; /*bool dsf = MatrixUtils.HasFullDiagonal(new bool[][] { new bool[] { true , true, true }, * new bool[] { true, true , true }, * new bool[] { false, true , false } }); * * int count = 3; * * Card[] ac = new Card[count]; * Card[] dc = new Card[count]; * * bool[][] b = new bool[count][]; * for (int i = 0; i < count; i++) * b[i] = new bool[count]; * * Random r = new Random(); * do * { * Suit trump = (Suit)r.Next(4); * * for (int i = 0; i < count; i++) * { * Card tc; * * do * { * tc = new Card((Rank)r.Next(6, 15), (Suit)r.Next(4)); * } * while (dc.Contains(tc) || ac.Contains(tc)); * ac[i] = tc; * * do * { * tc = new Card((Rank)r.Next(6, 15), (Suit)r.Next(4)); * } * while (dc.Contains(tc) || ac.Contains(tc)); * dc[i] = tc; * } * * for (int i = 0; i < count; i++) * { * for (int j = 0; j < count; j++) * { * b[i][j] = Card.CanBeat(dc[j], ac[i], trump); * } * } * * string log = $"Trump={trump}\n"; * for (int i = -1; i < count; i++) * { * for (int j = -1; j < count; j++) * { * if (i == -1 && j == -1) log += string.Format("{0,17}|", " "); * * if (i == -1 && j != -1) * log += $"{dc[j],17}|"; * * if (j == -1 && i != -1) * log += $"{ac[i],17}|"; * * if (i != -1 && j != -1) * log += string.Format("{0,17}|", b[i][j]); * } * log += "\n"; * } * log += $"does it beat? {MatrixUtils.HasFullDiagonal(b)}\n\n\n"; * * Console.WriteLine(log); * } * while (Console.ReadKey().KeyChar != 'q');*/ }
private void BenchmarkBinCoeffMultiple(int[] numElemArray, int[] numGroupArray) { // This method benchmarks the n choose k tests for many subcases & ranks, and compares the performance against the Combination class methods. // The first benchmark compares the performance of single methods. This one attempts a more "real-life" analysis and calls GetRank and // GetComboFromRank 1,000 times for all the subcases for each test case. // int numItems, groupSize, caseLoop; int[] kIndexes = new int[40]; ulong rankSum = 1; int kLoop; bool overflow; BinCoeffL bcl; long ticks, ticksAlt, ticksSum = 0, ticksSumAlt = 0; ulong numCombos, rank, startRank, endRank, rankCount = 1000, rankLoop; double d; Stopwatch sw; // Benchmark all the specified n choose k test cases. for (caseLoop = 0; caseLoop < numElemArray.Length; caseLoop++) { GC.Collect(); numItems = numElemArray[caseLoop]; groupSize = numGroupArray[caseLoop]; sw = Stopwatch.StartNew(); bcl = new BinCoeffL(numItems, groupSize); // Benchmark the subcases > 1,000 combinations. for (kLoop = groupSize; kLoop > 3; kLoop--) { numCombos = bcl.GetNumCombos(numItems, kLoop); rankSum += numCombos; startRank = (numCombos / 2) - (rankCount / 2); endRank = startRank + rankCount; for (rankLoop = startRank; rankLoop < endRank; rankLoop++) { bcl.GetCombFromRank(rankLoop, kIndexes, numItems, kLoop); rank = bcl.GetRank(true, kIndexes, out overflow, kLoop); rankSum += rank; } } sw.Stop(); ticks = sw.ElapsedTicks; // Benchmark the combination class using the same code as above. sw = Stopwatch.StartNew(); for (kLoop = groupSize; kLoop > 3; kLoop--) { numCombos = Combination.GetNumCombos(numItems, kLoop); rankSum += numCombos; startRank = (numCombos / 2) - (rankCount / 2); endRank = startRank + rankCount; for (rankLoop = startRank; rankLoop < endRank; rankLoop++) { Combination.GetCombFromRankLong(rankLoop, kIndexes, numItems, kLoop); rank = Combination.GetRank(kIndexes, out overflow, numItems, kLoop); rankSum += rank; } } sw.Stop(); ticksAlt = sw.ElapsedTicks; // Display the results. d = (double)ticksAlt / (double)ticks; d = Math.Round(d, 2); Console.WriteLine($"Multiple methods benchmark for {numItems} choose {groupSize} & subcases .vs. Combination class ratio = {d} to 1."); ticksSum += ticks; ticksSumAlt += ticksAlt; } d = (double)ticksSumAlt / (double)ticksSum; d = Math.Round(d, 2); Console.WriteLine($"Average for all n choose k cases & subcases .vs. Combination class ratio = {d} to 1."); Console.WriteLine(); // Looking at the sum of the return values makes sure that the compiler does not optimize the code away. if (rankSum == 0) { Console.WriteLine("Error - rankSum = 0?"); } }
private void GenerateAllPossibilities(List <string> solutions, Stack <char> currentSolution, Combination combination) { for (int i = combination.MinimumDigit; i <= combination.MaximumDigit; i++) { currentSolution.Push((char)(48 + i)); if (currentSolution.Count == combination.Length) { solutions.Add(new String(currentSolution.ToArray())); } else { // Once the maximum length has been reached, add the solution to // the list of all possible solutions. GenerateAllPossibilities(solutions, currentSolution, combination); } currentSolution.Pop(); } }
// Start is called before the first frame update void Start() { combination = new Combination(); ResetButtonEntries(); }
public void BuildCombination(Combination vcom) => meal.Combination = vcom;
public MyCombinationUiPure(Combination combination) : base(combination) { }
public CombinedCondition(Combination type, Condition[] conditions) { this.type = type; this.conditions = conditions; }
public void AddCombinationRule(Combination combination, Func <CardCollection, bool> predicate) { _combinationsDict.Add(combination, predicate); }
public string DoIteration(Scanner input, Output output) { int jackets = input.NextInt(), pants = input.NextInt(), shirts = input.NextInt(), max2combo = input.NextInt(); List <Combination> result1 = new List <Combination>(); List <Combination> result2 = new List <Combination>(); int results = 0; for (int jacket_c = 1; jacket_c <= jackets; jacket_c++) { for (int pant_c = 1; pant_c <= pants; pant_c++) { for (int i = 0; i < Math.Min(max2combo, shirts); i++) { var c = new Combination(); c.jacket = jacket_c; c.pant = pant_c; c.shirt = 0; result1.Add(c); } } } int shirt_c = 0, shirt_start = 0, shirt_done = 0; for (int i = 0; i < result1.Count; i++) { int jacket_m = result1[i].jacket, pant_m = result1[i].pant; int shirt_m = ++shirt_c; shirt_done++; shirt_m %= shirts; if (shirt_m == 0) { shirt_m = shirts; } if ((jackets * pants) % shirts == 0) { if (shirt_done == shirts) { shirt_start++; shirt_c = shirt_start; shirt_done = 0; } } Debug.WriteLine("We try {0} {1} {2}", jacket_m, pant_m, shirt_m); var combsSoFar1 = result2.Where(c => (shirt_m == c.shirt) && (pant_m == c.pant)).Count(); var combsSoFar2 = result2.Where(c => (jacket_m == c.jacket) && (pant_m == c.pant)).Count(); var combsSoFar3 = result2.Where(c => (shirt_m == c.shirt) && (jacket_m == c.jacket)).Count(); if (combsSoFar1 < max2combo && combsSoFar2 < max2combo && combsSoFar3 < max2combo) { var c = new Combination(); c.jacket = jacket_m; c.pant = pant_m; c.shirt = shirt_m; result2.Add(c); } } StringBuilder str = new StringBuilder(); for (int i = 0; i < result2.Count; i++) { str.AppendFormat("\r\n{0} {1} {2}", result2[i].jacket, result2[i].pant, result2[i].shirt); } return(result2.Count + str.ToString()); }
public int CheckBettingOrderMoney(List <Sports_AnteCodeInfo> codeList, string gameCode, string gameType, string playType, int amount, decimal schemeTotalMoney, DateTime stopTime, bool isAllow = false, string userId = "") { //验证投注号码 if (stopTime < DateTime.Now) { throw new Exception("投注结束时间不能小于当前时间"); } //验证投注内容是否合法,或是否重复 foreach (var item in codeList) { var oneCodeArray = item.AnteCode.Split(','); if (oneCodeArray.Distinct().Count() != oneCodeArray.Length) { throw new Exception(string.Format("投注号码{0}中包括重复的内容", item.AnteCode)); } BettingHelper.CheckSportAnteCode(gameCode, string.IsNullOrEmpty(item.GameType) ? gameType : item.GameType.ToUpper(), oneCodeArray); } var tmp = playType.Split('|'); var totalMoney = 0M; var totalCount = 0; var c = new Combination(); foreach (var chuan in tmp) { var chuanArray = chuan.Split('_'); if (chuanArray.Length != 2) { continue; } var m = int.Parse(chuanArray[0]); var n = int.Parse(chuanArray[1]); //串关包括的真实串数 var countList = SportAnalyzer.AnalyzeChuan(m, n); if (n > 1) { //3_3类型 c.Calculate(codeList.ToArray(), m, (arr) => { //m场比赛 if (arr.Select(p => p.MatchId).Distinct().Count() == m) { foreach (var count in countList) { //M串1 c.Calculate(arr, count, (a1) => { var cCount = 1; foreach (var t in a1) { cCount *= t.AnteCode.Split(',').Length; } totalCount += cCount; }); } } }); } else { var ac = new ArrayCombination(); var danList = codeList.Where(a => a.IsDan).ToList(); //var tuoList = codeList.Where(a => !a.IsDan).ToList(); var totalCodeList = new List <Sports_AnteCodeInfo[]>(); foreach (var g in codeList.GroupBy(p => p.MatchId)) { totalCodeList.Add(codeList.Where(p => p.MatchId == g.Key).ToArray()); } //3_1类型 foreach (var count in countList) { //c.Calculate(totalCodeList.ToArray(), count - danList.Count, (arr2) => c.Calculate(totalCodeList.ToArray(), count, (arr2) => { ac.Calculate(arr2, (tuoArr) => { #region 拆分组合票 var isContainsDan = true; foreach (var dan in danList) { var con = tuoArr.FirstOrDefault(p => p.MatchId == dan.MatchId); if (con == null) { isContainsDan = false; break; } } if (isContainsDan) { var cCount = 1; foreach (var t in tuoArr) { cCount *= t.AnteCode.Split(',').Length; } totalCount += cCount; //if (!isAllow && BusinessHelper.IsSiteLimit(gameCode)) //{ // if (!string.IsNullOrEmpty(userId) && !BusinessHelper.IsSpecificUser(userId))//如果是特定用户,则不限制投注 // { // if ((cCount * amount * 2M) < 50) // throw new Exception("您好,根据您投注的内容将产生多张彩票,每张彩票金额不足50元,请您增加倍数以达到出票条件。"); // } //} } #endregion }); }); } } } totalMoney = totalCount * amount * 2M; if (totalMoney != schemeTotalMoney) { throw new ArgumentException(string.Format("订单金额不正确,应该为:{0};实际为:{1}。", totalMoney, schemeTotalMoney)); } return(totalCount); }
public CombinationUi(Combination combination) : base(combination) { }
public Hand() { m_cdHighCard = new Card(Rank.Unassigned, Suit.Unassigned); m_cmbBestCombination = Combination.Unassigned; }
public new void Clear() { m_cmbBestCombination = Combination.Unassigned; base.Clear(); }
public int GetWidth() { return(Combination.GetWidth()); }
//adds a recipe public void addCombination(Combination r) { GlobalVars.RECIPES.Add(r); myCombinations.Add(r); }
private void btnStep_Click(object sender, EventArgs e) { if (first) { simulator.Initialize(); graphics = panel.CreateGraphics(); lblStep.Text = "Step " + simulator.Time; var pos = simulator.GetPositions(); players = new Player[pos.Length]; for (int i = 0; i < players.Length; i++) { players[i] = new Player(i, pos[i]); } Draw(); _root = new ElementNode(simulator.Show.Element, Combination.Range(0, players.Length - 1), Combination.Range(0, players.Length - 1)); tvElements.Nodes.Add(_root); tvElements.Refresh(); first = false; return; } GoToStep(simulator.Time + 1); }
public static void OpenRequest( ClientGuidType clientGuidType, PathNameType pathNameType, CreateType createType, ShareType shareType, AppInstanceIdType appInstanceIdType) { Condition.IsTrue(State == ModelState.Connected); Condition.IsNotNull(Open); // Isolate below params to limite the expanded test cases. Combination.Isolated(clientGuidType == ClientGuidType.SameClientGuid); Combination.Isolated(pathNameType == PathNameType.DifferentPathName); Combination.Isolated(shareType == ShareType.DifferentShareDifferentLocal); Combination.Isolated(shareType == ShareType.DifferentShareSameLocal); Combination.Isolated(appInstanceIdType == AppInstanceIdType.InvalidAppInstanceId); Combination.Isolated(appInstanceIdType == AppInstanceIdType.NoAppInstanceId); // "AppInstanceId is zero" is only applicable for the first Create Request. // For the second Create Request, only valid/notvalid/none make sense. Condition.IsFalse(appInstanceIdType == AppInstanceIdType.AppInstanceIdIsZero); // CreateDurableThenDisconnect is only applicable for the first Create Request. Condition.IsFalse(createType == CreateType.CreateDurableThenDisconnect); // If the client doesn't disconnect from the server after sending the first Create Request, // then the second Create Request does not need to contain reconnect context. // And vice versa. Condition.IfThen(Open.CreateTypeWhenPrepare != CreateType.CreateDurableThenDisconnect, createType != CreateType.ReconnectDurable); Condition.IfThen(Open.CreateTypeWhenPrepare == CreateType.CreateDurableThenDisconnect, createType == CreateType.ReconnectDurable); if (createType == CreateType.ReconnectDurable) { ModelHelper.Log(LogType.Requirement, "3.3.5.9.13: If the create request also includes the SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 create context, " + "the server MUST process the SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 create context as specified in section 3.3.5.9.12, " + "and this section MUST be skipped."); ModelHelper.Log(LogType.TestInfo, "SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 create context is included."); return; } if (!ModelUtility.IsSmb3xFamily(MaxSmbVersionSupported)) { ModelHelper.Log(LogType.Requirement, "2.2.13.2.13: The SMB2_CREATE_APP_INSTANCE_ID context is valid only for the SMB 3.x dialect family."); ModelHelper.Log(LogType.TestInfo, "The dialect version of the server is {0}.", MaxSmbVersionSupported); return; } if (appInstanceIdType == AppInstanceIdType.ValidAppInstanceId && Open.AppInstanceId != AppInstanceIdType.NoAppInstanceId && pathNameType == PathNameType.SamePathName && shareType == ShareType.SameShare && clientGuidType == ClientGuidType.DifferentClientGuid) { ModelHelper.Log(LogType.Requirement, "3.3.5.9.13: The server MUST attempt to locate an Open in GlobalOpenTable where:"); ModelHelper.Log(LogType.Requirement, "\tAppInstanceId in the request is equal to Open.AppInstanceId."); ModelHelper.Log(LogType.Requirement, "\tTarget path name is equal to Open.PathName."); ModelHelper.Log(LogType.Requirement, "\tOpen.TreeConnect.Share is equal to TreeConnect.Share."); ModelHelper.Log(LogType.Requirement, "\tOpen.Session.Connection.ClientGuid is not equal to the current Connection.ClientGuid."); ModelHelper.Log(LogType.TestInfo, "All the above conditions are met."); ModelHelper.Log(LogType.Requirement, "If an Open is found, the server MUST calculate the maximal access that the user, " + "identified by Session.SecurityContext, has on the file being opened<277>. " + "If the maximal access includes GENERIC_READ access, the server MUST close the open as specified in 3.3.4.17."); // The user used in this model is administrator, so maximal access always includes GENERIC_READ access. ModelHelper.Log(LogType.TestInfo, "The maximal access includes GENERIC_READ access. So open is closed."); // close open Open = null; } else { ModelHelper.Log(LogType.TestInfo, "appInstanceIdType is {0}.", appInstanceIdType.ToString()); ModelHelper.Log(LogType.TestInfo, "pathNameType is {0}.", pathNameType.ToString()); ModelHelper.Log(LogType.TestInfo, "shareType is {0}.", shareType.ToString()); ModelHelper.Log(LogType.TestInfo, "clientGuidType is {0}.", clientGuidType.ToString()); ModelHelper.Log(LogType.TestInfo, "All the above conditions do not match the requirement, so open will not be closed."); ModelHelper.Log(LogType.TestTag, TestTag.UnexpectedFields); } }
private void Form1_Load(object sender, EventArgs e) { var elements = new BasicElements(1); var formation = new RowsFormation(12, 5); Show baseProgram = new Show(Combination.Concatenate("Pflichtprogramm", elements.MoveForward("Vorwärts", formation, 24), elements.Wait("Halt im klingenden Spiel", formation, 8), elements.MoveForward("Vorwärts", formation, 16), elements.Schwenkung("Schwenkung", formation, toRight: true), elements.MoveForward("Vorwärts", formation, 8), //TODO add abfallen/aufmarschieren elements.GrosseWendeComplete("Große Wende", formation))); /*Show show = new Show(Combination.Concatenate("Show", * Combination.Parallel("", * trans.MoveForward("v", formation, 8), * trans.BreiteFormation("wide", formation)), * trans.Schwenkung("Schwenkung", formation, toRight: false), * trans.Schwenkung("Schwenkung", formation, toRight: true), * trans.BreiteFormation("wide", formation, sideMarginFactor: 0.5), * trans.Schwenkung("Schwenkung 2", formation, toRight: true), * trans.Schwenkung("Schwenkung 2", formation, toRight: true), * trans.Schwenkung("Schwenkung 2", formation, toRight: true), * trans.Schwenkung("Schwenkung 2", formation, toRight: true), * trans.Schwenkung("Schwenkung 2", formation, toRight: true), * trans.Schwenkung("Schwenkung 2", formation, toRight: true), * trans.Schwenkung("Schwenkung 2", formation, toRight: true), * trans.Schwenkung("Schwenkung 2", formation, toRight: true), * trans.Schwenkung("Schwenkung 2", formation, toRight: true), * trans.Schwenkung("Schwenkung 3", formation, toRight: true) * ));*/ Show show = new Show(elements.GrosseWendeComplete("Große Wende", formation)); Show rotTest = new Show(Combination.Concatenate("show", new Element { Name = "sfd", StartFormation = formation, GroupActions = new GroupAction[] { GroupActions.MoveForward(4), GroupActions.Rotate(90, delay: 4, duration: 2), GroupActions.MoveForward(4, delay: 6), GroupActions.Rotate(90, delay: 10, duration: 2), GroupActions.MoveForward(4, delay: 12), GroupActions.Rotate(90, delay: 16, duration: 2), GroupActions.MoveForward(4, delay: 18), GroupActions.Rotate(90, delay: 22, duration: 2), } }, new Element { Name = "sfd", StartFormation = formation, GroupActions = new GroupAction[] { GroupActions.MoveForward(4), GroupActions.Rotate(-90, delay: 4, duration: 2), GroupActions.MoveForward(4, delay: 6), GroupActions.Rotate(-90, delay: 10, duration: 2), GroupActions.MoveForward(4, delay: 12), GroupActions.Rotate(-90, delay: 16, duration: 2), GroupActions.MoveForward(4, delay: 18), GroupActions.Rotate(-90, delay: 22, duration: 2), } } )); var x = baseProgram.ToJSON(); var formationTypes = new List <Formation> { new BasicFormation(), new RowsFormation() }; Show s = Data.Show.FromJSON(x, formationTypes); simulator = new ShowSimulator(s); }
//тест на рояль флеш public void Test_1() { var Player_1 = new List <Card>(); var Table = new List <Card>(); var tmpDeck = new List <string>(); var TableWithOutFlashRoyal = new List <string>(); Random rnd = new Random(); bool f = false; int k = 0; string[] pwdRanc = new string[13] { "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A" }; string[] pwdSuit = new string[4] { "C", "D", "H", "S" }; string[] FlashRoyal = new string[5] { "C10", "CJ", "CQ", "CK", "CA" }; string str; for (var i = 0; i < 4; i++) { for (var j = 0; j < 13; j++) { str = pwdSuit[i] + pwdRanc[j]; tmpDeck.Add(str); } } TableWithOutFlashRoyal.AddRange(tmpDeck); for (int i = 0; i < 5; i++) { var find = TableWithOutFlashRoyal.FindIndex(tmp => tmp == FlashRoyal[i]); TableWithOutFlashRoyal.RemoveAt(find); } foreach (var CurCard in FlashRoyal) { Table.Add(Card.Get(CurCard)); } StreamWriter sw = new StreamWriter("OutPut.txt", false, System.Text.Encoding.Default); foreach (var FirstCard in TableWithOutFlashRoyal) { foreach (var SecondCard in TableWithOutFlashRoyal) { if (FirstCard == SecondCard) { continue; } Player_1.Clear(); Player_1.Add(Card.Get(FirstCard)); Player_1.Add(Card.Get(SecondCard)); Combination combination = CombinationChecker.DetermineCombination(Player_1, Table); { if (combination != Combination.RoyalFlush) { sw.WriteLine(combination); sw.WriteLine("Player card :" + Player_1[0].ToString() + " " + Player_1[1].ToString()); sw.WriteLine("Table card :" + Table[0].ToString() + " " + Table[1].ToString() + " " + Table[2].ToString() + " " + Table[3].ToString() + " " + Table[4].ToString()); } }; } } }
public Three(Combination combination) : base(combination) { }
public static bool GetContainingSphere(out Vector3 center, out float radius, params Vector3[] points) { center = Vector3.Empty; radius = float.MaxValue; bool found = false; foreach (var indices in Combination.EnumerateCombinations(points.Length, 4)) { Vector3 tmpCenter; float tmpRadius = 0; if (GetCircumscribedSphere(points[indices[0]], points[indices[1]], points[indices[2]], points[indices[3]], out tmpCenter)) { for (int i = 0; i < points.Length; i++) { float tmpTmpRadius = (tmpCenter - points[i]).Length(); if (tmpTmpRadius > tmpRadius) { tmpRadius = tmpTmpRadius; } } } if (tmpRadius < radius) { radius = tmpRadius; center = tmpCenter; found = true; } } foreach (var indices in Combination.EnumerateCombinations(points.Length, 3)) { Vector3 tmpCenter; float tmpRadius = 0; if (GetCircumscribedCircle(points[indices[0]], points[indices[1]], points[indices[2]], out tmpCenter)) { for (int i = 0; i < points.Length; i++) { float tmpTmpRadius = (tmpCenter - points[i]).Length(); if (tmpTmpRadius > tmpRadius) { tmpRadius = tmpTmpRadius; } } } if (tmpRadius < radius) { radius = tmpRadius; center = tmpCenter; found = true; } } foreach (var indices in Combination.EnumerateCombinations(points.Length, 2)) { Vector3 tmpCenter = Vector3.Lerp(points[indices[0]], points[indices[1]], 0.5f); float tmpRadius = 0; for (int i = 0; i < points.Length; i++) { float tmpTmpRadius = (tmpCenter - points[i]).Length(); if (tmpTmpRadius > tmpRadius) { tmpRadius = tmpTmpRadius; } } if (tmpRadius < radius) { radius = tmpRadius; center = tmpCenter; found = true; } } return(found); }
public static void Main() { int height = 100; int width = 100; float[] input = new float[height * width]; for (int i = 0; i < input.Length; i++) { input[i] = .5f; } Random rnd = new Random(); InOutPair[] IO = new InOutPair[1]; float[] toAdd = new float[height * width]; for (int i = 0; i < height * width; i++) { toAdd[i] = 1f / i; } IO[0] = new InOutPair(toAdd, new float[] { .1f, .5f, -.1f }); Epoch Ep = new Epoch(IO, 1000, true); NeuralNetwork NN = new NeuralNetwork(9, rnd, .01f, 1, 10, 200); NN.AddLayer(5, "HypTan"); NN.AddLayer(5, "HypTan"); NN.AddLayer(5, "HypTan"); NN.AddLayer(3, "HypTan"); Convolution CC = new Convolution(height, width); CC.AddLayer(5, 5, 5); CC.AddLayer(2, 2, 1, new HyperbolicTangent()); CC.AddLayer(6, 6, 1); CC.AddLayer(2, 2, 2, true); CC.AddLayer(2, 2, 1, new HyperbolicTangent()); CC.AddLayer(2, 2, 2, true); Combination C = new Combination(CC, NN); float[] layerOut = C.Run(input); for (int i = 0; i < layerOut.Length; i++) { Console.WriteLine(layerOut[i]); } C.Train(Ep); Console.WriteLine(); layerOut = C.Run(input); for (int i = 0; i < layerOut.Length; i++) { Console.WriteLine(layerOut[i]); } }
public static string ToAnteString_LiangCai(this Antecode ante, string gameCode, string gameType) { if (gameCode.Equals("SSQ", StringComparison.OrdinalIgnoreCase) && ante.GameType.Equals("DS", StringComparison.OrdinalIgnoreCase)) { return(ante.AnteNumber.Replace("|", "-").Replace(",", " ")); } else if (gameCode.Equals("SSQ", StringComparison.OrdinalIgnoreCase) && ante.GameType.Equals("FS", StringComparison.OrdinalIgnoreCase)) { var hong = ante.AnteNumber.Split('|')[0]; var lan = ante.AnteNumber.Split('|')[1]; if (lan.Length > 35) { var lan1 = ante.AnteNumber.Split('|')[1].Substring(0, 17); var lan2 = ante.AnteNumber.Split('|')[1].Substring(18); return(hong.Replace(",", " ") + "-" + lan1.Replace(",", " ") + ";" + hong.Replace(",", " ") + "-" + lan2.Replace(",", " ")); } return(ante.AnteNumber.Replace("|", "-").Replace(",", " ")); } else if (gameCode.Equals("SSQ", StringComparison.OrdinalIgnoreCase) && ante.GameType.Equals("DT", StringComparison.OrdinalIgnoreCase)) { var tmp = ante.AnteNumber.Split('|'); if (tmp.Length != 3) { throw new ArgumentException("大乐透胆拖玩法号码错误 - " + ante.AnteNumber); } var hongdan = tmp[0]; var hongtuo = tmp[1]; var lan = tmp[2]; if (lan.Length > 35) { var lan1 = lan.Substring(0, 17); var lan2 = lan.Substring(18); return(hongdan.Replace(",", " ") + "$" + hongtuo.Replace(",", " ") + "-" + lan1.Replace(",", " ") + ";" + hongdan.Replace(",", " ") + "$" + hongtuo.Replace(",", " ") + "-" + lan2.Replace(",", " ")); } return(string.Format("{0}${1}-{2}", hongdan.Replace(",", " "), hongtuo.Replace(",", " "), lan.Replace(",", " "))); } else if (gameCode.Equals("DLT", StringComparison.OrdinalIgnoreCase) && (ante.GameType.Equals("DS", StringComparison.OrdinalIgnoreCase) || ante.GameType.Equals("FS", StringComparison.OrdinalIgnoreCase))) { return(ante.AnteNumber.Replace("|", "-").Replace(",", " ")); } else if (gameCode.Equals("DLT", StringComparison.OrdinalIgnoreCase) && ante.GameType.Equals("DT", StringComparison.OrdinalIgnoreCase)) { var tmp = ante.AnteNumber.Replace(",", " ").Split('|'); if (tmp.Length != 4) { throw new ArgumentException("大乐透胆拖玩法号码错误 - " + ante.AnteNumber); } //05,06,07,08|01,02,03,04,09|01|02,03 //(05,06,07,08),01,02,03,04,09+(01),02,03 var hongdan = tmp[0]; var hongtuo = tmp[1]; var landan = tmp[2]; var lantuo = tmp[3]; return(string.Format("{0}${1}-{2}${3}", hongdan, hongtuo, landan, lantuo)); } else if (gameCode.Equals("CTZQ", StringComparison.OrdinalIgnoreCase)) { switch (ante.GameType.ToUpper()) { case "T14C": if (ante.AnteNumber.Replace(",", "").Length > 38) { throw new ArgumentException("传统足球14场玩法号码错误 - " + ante.AnteNumber); } return(ante.AnteNumber); case "TR9": if (ante.AnteNumber.Replace(",", "").Length > 27) { throw new ArgumentException("传统足球任选9场玩法号码错误 - " + ante.AnteNumber); } return(ante.AnteNumber.Replace("*", "#")); case "T6BQC": if (ante.AnteNumber.Replace(",", "").Length > 32) { throw new ArgumentException("传统足球6场半全场玩法号码错误 - " + ante.AnteNumber); } return(ante.AnteNumber); case "T4CJQ": if (ante.AnteNumber.Replace(",", "").Length > 32) { throw new ArgumentException("传统足球4场进球玩法号码错误 - " + ante.AnteNumber); } return(ante.AnteNumber); default: return(ante.AnteNumber); } } #region 重庆时时彩 else if (gameCode.Equals("CQSSC", StringComparison.OrdinalIgnoreCase)) { var touzhu = string.Empty; switch (ante.GameType.ToLower()) { case "1xdx": var dx1xL = ante.AnteNumber.Replace("-,-,-,-,", ""); if (dx1xL.Length > 5) { return(ConvertGameType(gameCode, gameType) + "|" + "-,-,-,-," + dx1xL.Substring(0, 5) + ";" + ConvertGameType(gameCode, gameType) + "|" + "-,-,-,-," + dx1xL.Substring(5)); } return(ConvertGameType(gameCode, gameType) + "|" + ante.AnteNumber); case "2xdx": var dx2xL = ante.AnteNumber.Replace("-,-,-,", "").Split(','); if ((dx2xL[0].Length + dx2xL[1].Length) > 12) { var list = new List <char[]>(); list.Add(dx2xL[0].ToArray()); list.Add(dx2xL[1].ToArray()); var strL = new List <string>(); var c = new ArrayCombination(); c.Calculate(list.ToArray(), (a) => { strL.Add(ConvertGameType(gameCode, gameType) + "|" + "-,-,-," + string.Join(",", a)); }); return(string.Join(";", strL)); } return(ConvertGameType(gameCode, gameType) + "|" + ante.AnteNumber); case "3xdx": var dx3xL = ante.AnteNumber.Replace("-,-,", "").Split(','); if ((dx3xL[0].Length + dx3xL[1].Length + dx3xL[2].Length) > 24) { var list = new List <char[]>(); list.Add(dx3xL[0].ToArray()); list.Add(dx3xL[1].ToArray()); list.Add(dx3xL[2].ToArray()); var strL = new List <string>(); var c = new ArrayCombination(); c.Calculate(list.ToArray(), (a) => { strL.Add(ConvertGameType(gameCode, gameType) + "|" + "-,-," + string.Join(",", a)); }); return(string.Join(";", strL)); } return(ConvertGameType(gameCode, gameType) + "|" + ante.AnteNumber); case "5xdx": var dx5xL = ante.AnteNumber.Split(','); if (ante.AnteNumber.Replace(",", "").Length > 45) { var list = new List <char[]>(); list.Add(dx5xL[0].ToArray()); list.Add(dx5xL[1].ToArray()); list.Add(dx5xL[2].ToArray()); list.Add(dx5xL[3].ToArray()); list.Add(dx5xL[4].ToArray()); var strL = new List <string>(); var c = new ArrayCombination(); c.Calculate(list.ToArray(), (a) => { strL.Add(ConvertGameType(gameCode, gameType) + "|" + string.Join(",", a)); }); return(string.Join(";", strL)); } return(ConvertGameType(gameCode, gameType) + "|" + ante.AnteNumber); case "2xzxfs": return(ConvertGameType(gameCode, gameType) + "|" + ante.AnteNumber.Replace(",", "")); case "5xtx": return(ConvertGameType(gameCode, gameType) + "|" + ante.AnteNumber); case "dxds": return(ConvertGameType(gameCode, gameType) + "|" + ante.AnteNumber.Replace(",", "")); default: return(ante.AnteNumber); } } #endregion #region 江西11选5 else if (gameCode.Equals("JX11X5", StringComparison.OrdinalIgnoreCase)) { switch (ante.GameType.ToLower()) { case "rx2": case "rx3": case "rx4": case "rx5": case "rx6": case "rx7": case "q2zux": case "q3zux": return(ConvertGameType(gameCode, gameType) + "|" + ante.AnteNumber.Replace(",", " ")); case "q2zhix": if (ante.AnteNumber.Replace(",", " ").Split(' ').Length > 11) { var q2zhix = ante.AnteNumber.Replace(" ", "-").Split(','); var list = new List <string[]>(); list.Add(q2zhix[0].Split('-')); list.Add(q2zhix[1].Split('-')); var strL = new List <string>(); var c = new ArrayCombination(); c.Calculate(list.ToArray(), (a) => { if (a[0] != a[1]) { strL.Add(ConvertGameType(gameCode, gameType) + "|" + string.Join(",", a)); } }); return(string.Join(";", strL)); } return(ConvertGameType(gameCode, gameType) + "|" + ante.AnteNumber); case "q3zhix": if (ante.AnteNumber.Replace(",", " ").Split(' ').Length > 3) { var q3zhix = ante.AnteNumber.Replace(" ", "-").Split(','); var list = new List <string[]>(); list.Add(q3zhix[0].Split('-')); list.Add(q3zhix[1].Split('-')); list.Add(q3zhix[2].Split('-')); var strL = new List <string>(); var c = new ArrayCombination(); c.Calculate(list.ToArray(), (a) => { if (a.Distinct().ToArray().Length == 3) { strL.Add(ConvertGameType(gameCode, gameType) + "|" + string.Join(",", a)); } }); return(string.Join(";", strL)); } return(ConvertGameType(gameCode, gameType) + "|" + ante.AnteNumber); default: return(ante.AnteNumber); } } #endregion #region 排列三、福彩3D else if (gameCode.Equals("PL3", StringComparison.OrdinalIgnoreCase) || gameCode.Equals("FC3D", StringComparison.OrdinalIgnoreCase)) { switch (ante.GameType.ToLower()) { case "ds": case "fs": var pl = ante.AnteNumber.Replace(",", ""); if (pl.Length > 24) { var pl3fs = ante.AnteNumber.Split(','); var list = new List <char[]>(); list.Add(pl3fs[0].ToArray()); list.Add(pl3fs[1].ToArray()); list.Add(pl3fs[2].ToArray()); var strL = new List <string>(); var c = new ArrayCombination(); c.Calculate(list.ToArray(), (a) => { strL.Add(ConvertGameType(gameCode, gameType) + "|" + string.Join(",", a)); }); return(string.Join(";", strL)); } return(ConvertGameType(gameCode, gameType) + "|" + ante.AnteNumber); case "hz": return(ConvertGameType(gameCode, gameType) + "|" + ante.AnteNumber); case "zx3ds": return(ConvertGameType(gameCode, gameType) + "|" + ante.AnteNumber); case "zx6": if (ante.AnteNumber.Replace(",", "").Length > 3) { var num = ante.AnteNumber.Replace(",", ""); var c = new Combination(); var strL = new List <string>(); c.Calculate(num.ToArray(), 3, (a) => { strL.Add(ConvertGameType(gameCode, gameType) + "|" + string.Join(",", a)); }); return(string.Join(";", strL)); } return(ConvertGameType(gameCode, gameType) + "|" + ante.AnteNumber); case "zx3fs": return(ConvertGameType(gameCode, gameType) + "|" + ante.AnteNumber.Replace(",", "")); default: return(ante.AnteNumber); } } #endregion else { return(ante.AnteNumber); } }
public void SaveToFile() { int i = 0; StringBuilder sb = new StringBuilder(lineSize * 200000, maxLineSize * maxRecords); foreach (PreOutfit po in this.outfits) { Combination pc = po.Combination; StringBuilder lb = new StringBuilder(lineSize, maxLineSize); // Add Closet & Flavor lb.Append(this.Closet.Id); lb.Append(","); lb.Append(pc.FashionFlavor.Id); int used = 2; // Let's setup in the correct order to avoid duplicates. Garment[] arrItems = new Garment[13]; foreach (Garment g in po.ToList()) { // Always use first silouhette to position int pos = OutfitValidationService.GetClosetOutfitPosition(g); arrItems[pos] = g; } foreach (Garment g in arrItems) { if (g != null) { lb.Append(","); lb.Append(g.Id); lb.Append(","); lb.Append(g.PreGarment.Id); used++; } else { lb.Append(","); lb.Append(@"0"); lb.Append(","); lb.Append(@"0"); } } lb.Append(","); lb.Append(po.Seasons.ToString()); lb.Append(","); lb.Append(po.EventTypes.ToString()); lb.Append(","); lb.Append(pc.EditorRating); sb.AppendLine(lb.ToString()); i++; if (i == 200000) { System.IO.File.AppendAllText(Path.Combine(this.SharePath, fileName), sb.ToString()); sb = null; GC.Collect(); GC.WaitForPendingFinalizers(); sb = new StringBuilder(lineSize * maxRecords, maxLineSize * maxRecords); i = 0; } } if (i > 0) { System.IO.File.AppendAllText(Path.Combine(this.SharePath, fileName), sb.ToString()); sb = null; GC.Collect(); GC.WaitForPendingFinalizers(); } }
/// <summary> /// 获取杀号类型规则后形成的列表:适用于不是用预处理直接获取数据的情况 /// </summary> /// <param name="ruleList">杀号规则列表</param> public static LotTickData[] GetInitiaDataByNotUserPrepareData(RuleInfo[] ruleList) { List<int> RedBall = new List<int>(33); List<int> BlueBall = new List<int>(16); //初始化 for (int i = 0; i <33 ; i++) RedBall.Add (i +1); for (int i = 0; i <16 ; i++) BlueBall.Add (i +1); for (int i = 0; i < ruleList.Length ; i++) { LotTickData[] curData = new LotTickData[ruleList[i].CalcuteRows + ruleList[i].NeedRows]; if (ruleList[i].IndexSelector.ToString().Contains("红")) //杀红 RedBall =RedBall.Except(ruleList[i].IndexSelector.DeleteNumbers(curData)).ToList (); else //杀篮 BlueBall =BlueBall.Except(ruleList[i].IndexSelector.DeleteNumbers(curData)).ToList (); } //对红和蓝进行组合、迭代获取所有组合序列,并对每个序列进行判断 int[][] Red = new Combination(RedBall.Count , 6).Rows.Select (n => Combination.Permute(n, RedBall ).ToArray()).ToArray(); LotTickData[] res = new LotTickData[Red.GetLength(0) * BlueBall.Count];//总数 int count = 0; for (int i = 0; i < Red.GetLength(0); i++) { for (int j = 0; j < BlueBall.Count ; j++) { res[count] = new LotTickData();//红蓝组合 res[count].NormalData = Red[i]; res[count++].SpecialData = BlueBall[j]; } } return res ; }
public Point2d IntersectionPointC(FuncApproximation F1, FuncApproximation F2, Point2d PtCenter, bool DispB) { Point2d PtA = new Point2d(0, 0), PtB = new Point2d(PtCenter.X * 2, PtCenter.Y * 2); Point2d[] PTlst = new Point2d[9]; while (true) { Lrepeat: double xMin = Min(PtA.X, PtB.X); double xMax = Max(PtA.X, PtB.X); double yMin = Min(PtA.Y, PtB.Y); double yMax = Max(PtA.Y, PtB.Y); double xSpn = (xMax - xMin) * 0.5; double ySpn = (yMax - yMin) * 0.5; if (xSpn < 0.01 && ySpn < 0.01) { break; } WriteLine(); for (int rc = 0; rc < 9; rc++) { PTlst[rc] = new Point2d(xMin + xSpn * (rc % 3), yMin + ySpn * (rc / 3)); } int k = 0; foreach (var P in PTlst) { WriteLine("{4}: {0:000},{1:000} {2:0.00} {3:0.00}", P.X, P.Y, F1.FuncPt2F(P), F2.FuncPt2F(P), ++k); } Combination cmb = new Combination(9, 2); while (cmb.Successor()) { int s0 = cmb.Index[0], s1 = cmb.Index[1]; if (s0 / 3 == s1 / 3 || s0 % 3 == s1 % 3 || Abs((s0 / 3 - s1 / 3) * (s0 % 3 - s1 % 3)) == 4) { continue; } //int s2=s1/3*3+s0%3, s3=s0/3*3+s1%3; //WriteLine(" {0} {1} {2} {3}", s0, s1, s2, s3 ); PtA = PTlst[s0]; PtB = PTlst[s1]; if (F1.FuncPt2F(PtA) * F1.FuncPt2F(PtB) > 0.0) { continue; } if (F2.FuncPt2F(PtA) * F2.FuncPt2F(PtB) > 0.0) { continue; } int s2 = s1 / 3 * 3 + s0 % 3, s3 = s0 / 3 * 3 + s1 % 3; PtA = PTlst[s2]; PtB = PTlst[s3]; if (F1.FuncPt2F(PtA) * F1.FuncPt2F(PtB) > 0.0) { continue; } if (F2.FuncPt2F(PtA) * F2.FuncPt2F(PtB) > 0.0) { continue; } WriteLine(" {0} {1} {2} {3}", s0, s1, s2, s3); goto Lrepeat; } // WriteLine(); // foreach( var P in PTlst) WriteLine("IntersectionPoint "+P ); } return(PtB); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { tutorial = new Tutorial(Content, GAME_WIDTH, GAME_HEIGHT, GUARD_Y, sGuard, sPunch); combination = new Combination(Content, GAME_WIDTH, GAME_HEIGHT, GUARD_Y, sGuard, sPunch); startScreen = new StartScreen(GAME_HEIGHT, GAME_WIDTH, Content); if (combination != null) { combination.getFirstPunch(); } //rand = new Random(DateTime.Now.Millisecond); //currentPunch = getNextPunch(); rPunchLine = new Rectangle(0, 450, 1280, 5); graphics.PreferredBackBufferWidth = GAME_WIDTH; graphics.PreferredBackBufferHeight = GAME_HEIGHT; graphics.IsFullScreen = true; graphics.ApplyChanges(); base.Initialize(); }
public static void ValidateNegotiateInfoRequest(DialectType dialectType, CapabilitiesType capabilitiesType, SecurityModeType securityModeType, ClientGuidType clientGuidType) { Condition.IsTrue(State == ModelState.Connected); // Those four parameters don’t need to be full-mesh. Combination.Isolated(DialectType.None == dialectType); Combination.Isolated(DialectType.DialectDifferentFromNegotiate == dialectType); Combination.Isolated(capabilitiesType == CapabilitiesType.CapabilitiesDifferentFromNegotiate); Combination.Isolated(securityModeType == SecurityModeType.SecurityModeDifferentFromNegotiate); Combination.Isolated(clientGuidType == ClientGuidType.ClientGuidDifferentFromNegotiate); if (DialectType.DialectSameWithNegotiate != dialectType) { ModelHelper.Log( LogType.Requirement, "3.3.5.15.12: The server MUST determine the greatest common dialect between the dialects it implements and the Dialects array of the VALIDATE_NEGOTIATE_INFO request." + " If no dialect is matched, or if the value is not equal to Connection.Dialect, the server MUST terminate the transport connection and free the Connection object"); ModelHelper.Log( LogType.TestInfo, "No dialect is matched between the dialects it implements and the Dialects array of the VALIDATE_NEGOTIATE_INFO request, or if the value is not equal to Connection.Dialect"); ModelHelper.Log(LogType.TestTag, TestTag.UnexpectedFields); IsSameWithNegotiate = false; } if (capabilitiesType == CapabilitiesType.CapabilitiesDifferentFromNegotiate) { ModelHelper.Log( LogType.Requirement, "3.3.5.15.12: If Connection.ClientCapabilities is not equal to the Capabilities received in the VALIDATE_NEGOTIATE_INFO request structure, the server MUST terminate the transport connection and free the Connection object"); ModelHelper.Log( LogType.TestInfo, "Connection.ClientCapabilities is not equal to the Capabilities received in the VALIDATE_NEGOTIATE_INFO request"); ModelHelper.Log(LogType.TestTag, TestTag.UnexpectedFields); IsSameWithNegotiate = false; } if (securityModeType == SecurityModeType.SecurityModeDifferentFromNegotiate) { ModelHelper.Log( LogType.Requirement, "3.3.5.15.12: If the SecurityMode received in the VALIDATE_NEGOTIATE_INFO request structure is not equal to Connection.ClientSecurityMode, the server MUST terminate the transport connection and free the Connection object"); ModelHelper.Log( LogType.TestInfo, "SecurityMode received in the VALIDATE_NEGOTIATE_INFO request structure is not equal to Connection.ClientSecurityMode"); ModelHelper.Log(LogType.TestTag, TestTag.UnexpectedFields); IsSameWithNegotiate = false; } if (clientGuidType == ClientGuidType.ClientGuidDifferentFromNegotiate) { ModelHelper.Log( LogType.Requirement, "3.3.5.15.12: If the Guid received in the VALIDATE_NEGOTIATE_INFO request structure is not equal to the Connection.ClientGuid, the server MUST terminate the transport connection and free the Connection object"); ModelHelper.Log( LogType.TestInfo, "Guid received in the VALIDATE_NEGOTIATE_INFO request structure is not equal to the Connection.ClientGuid"); ModelHelper.Log(LogType.TestTag, TestTag.UnexpectedFields); IsSameWithNegotiate = false; } }
public CombinationManager(Combination combination) { this.combination = combination; }
private void LoadCombinations(string fileName) { string line; StreamReader file = new StreamReader(fileName, Encoding.Default); Combination c; char[] seperators = new char[2]{'+', '='}; if(file != null) { do { line = file.ReadLine(); if (line != null) { if(line.Length > 0) { string[] elements = line.Split(seperators); if(elements.Length == 3) { c = new Combination(); c.ObjectIdA = int.Parse(elements[0]); c.ObjectIdB = int.Parse(elements[1]); c.ObjectIdResult = int.Parse(elements[2]); db.AddCombination(c); } } } } while(line != null); } }
public SortOperations( int[] numbers, int reorder ) { StartNumbers = new Combination(numbers); ReorderCount = reorder; GeneratedPermutations = new Dictionary<string, bool> (); }
public override int Move(CellStatus[,] cells) { CellStatus target = GetTargetColor(); int nRows = cells.GetLength(0); int nCols = cells.GetLength(1); // if board is empty start in the middle if (PlayInTheMiddle(cells)) return (int)Math.Ceiling(nCols / 2.0); Combination best = new Combination() { Lenght = 0 }; for (int r = 0; r < nRows; r++) { int counter = 0; for (int c = 0; c < nCols; c++) { if (cells[r, c] != target) { if (counter > best.Lenght) { List<int> colToStop = new List<int>(); // check if the sequence can be stopped here! if (Utils.CanPlaceDiskAt(r, c, cells)) { colToStop.Add(c); } // check if the sequence can be stopped on the other end if (Utils.CanPlaceDiskAt(r, c - counter - 1, cells)) { colToStop.Add(c - counter - 1); } if (colToStop.Count > 0) { best = new Combination() { Lenght = counter, CanBeStopped = colToStop.Count > 0, ColumnsToStop = colToStop, }; } } counter = 0; } else { counter++; } } } for (int c = 0; c < nCols; c++) { int counter = 0; for (int r = 0; r < nRows; r++) { if (cells[r, c] != target) { if (counter > best.Lenght) { List<int> colToStop = new List<int>(); // check if the sequence can be stopped here! if (Utils.CanPlaceDiskAt(r, c, cells)) { colToStop.Add(c); } if (colToStop.Count > 0) { best = new Combination() { Lenght = counter, CanBeStopped = colToStop.Count > 0, ColumnsToStop = colToStop, }; } } counter = 0; } else { counter++; } } } // check diagonal backward for (int c = 3; c < nCols + 2; c++) { int counter = 0; for (int r = 0; r < nRows; r++) { int col = c - r; int row = r; if (col >= 0 && col < nCols) { if (cells[row, col] != target) { if (counter > best.Lenght) { List<int> colToStop = new List<int>(); // check if the sequence can be stopped here! if (Utils.CanPlaceDiskAt(row, col, cells)) { colToStop.Add(col); } // check if the sequence can be stopped on the other side! if (Utils.CanPlaceDiskAt(row - counter - 1, col + counter + 1, cells)) { colToStop.Add(col + counter + 1); } if (colToStop.Count > 0) { best = new Combination() { Lenght = counter, CanBeStopped = colToStop.Count > 0, ColumnsToStop = colToStop, }; } } counter = 0; } else { counter++; } } } } // check diagonal forward for (int c = -2; c < nCols -3; c++) { int counter = 0; for (int r = 0; r < nRows; r++) { int col = c + r; int row = r; if (col >= 0 && col < nCols) { if (cells[row, col] != target) { if (counter > best.Lenght) { List<int> colToStop = new List<int>(); // check if the sequence can be stopped here! if (Utils.CanPlaceDiskAt(row, col, cells)) { colToStop.Add(col); } // check if the sequence can be stopped on the other side! if (Utils.CanPlaceDiskAt(row - counter - 1, col - counter - 1, cells)) { colToStop.Add(col - counter - 1); } if (colToStop.Count > 0) { best = new Combination() { Lenght = counter, CanBeStopped = colToStop.Count > 0, ColumnsToStop = colToStop, }; } } counter = 0; } else { counter++; } } } } if (best.ColumnsToStop != null) { if (best.ColumnsToStop.Count == 1) { return best.ColumnsToStop[0]; } else { double center = nCols / 2.0; int closest = -1; double closestDistance = double.MaxValue; foreach (var col in best.ColumnsToStop) { double distance = col - center; if (distance < closestDistance) { closest = col; closestDistance = distance; } } return closest; } } else { // why does it end up here? return new Random().Next(0, nCols); } }
protected void setUp() { //test a combination from 3 elements structure = new TestCasesStructure(); Element elem1 = new Element(structure); eq11 = new EquivalenceClass(elem1); eq12 = new EquivalenceClass(elem1); eq13 = new EquivalenceClass(elem1); Element elem2 = new Element(structure); eq21 = new EquivalenceClass(elem2); eq22 = new EquivalenceClass(elem2); eq23 = new EquivalenceClass(elem2); Element elem3 = new Element(structure); eq31 = new EquivalenceClass(elem3); eq32 = new EquivalenceClass(elem3); eq33 = new EquivalenceClass(elem3); dep = new Dependency(structure); foreach (Element element in structure.Elements) { dep.AddElement(element); foreach (EquivalenceClass equivalenceClass in element.EquivalenceClasses) { dep.AddEquivalenceClass(equivalenceClass); } } combi1 = new Combination(dep); combi2 = new Combination(dep); combi3 = new Combination(dep); combi4 = new Combination(dep); combi5 = new Combination(dep); combi1.AddEquivalenceClass(eq11); combi1.AddEquivalenceClass(eq22); combi1.AddEquivalenceClass(eq33); combi2.AddEquivalenceClass(eq21); combi2.AddEquivalenceClass(eq11); combi2.AddEquivalenceClass(eq32); combi3.AddEquivalenceClass(eq13); combi3.AddEquivalenceClass(eq23); combi3.AddCombination(combi4); test1 = new TestCase(structure); test2 = new TestCase(structure); test1.AddCombination(combi1); test1.AddEquivalenceClass(eq33); test1.AddCombination(combi4); test2.AddCombination(combi3); test2.AddCombination(combi4); }
public void AddCombination(Combination c) { combinations.Add(c); }
//adds a recipe given two strings public void addCombination(string p1, string p2) { Combination r = new Combination(p1, p2, this); GlobalVars.RECIPES.Add(r); myCombinations.Add (r); }
private static decimal EvaluateDeck(List <Card> deck, out string playerHand) { deck.Sort(); SortBySuit(ref deck); playerHand = string.Empty; decimal res = 0; Combination var; var keys = new List <Card>(); if (Combination.IsStraight(deck) && Combination.IsFlush(deck)) { var = new StraightFlush(deck); playerHand = var.PlayerHand; res = var.Score; } else if (Combination.IsNofAKind(4, deck, out keys)) { var = new FourOfAKind(deck); playerHand = var.PlayerHand; res = var.Score; } else if (Combination.IsFullHouse(deck, out Card key)) { var = new FullHouse(deck); playerHand = var.PlayerHand; res = var.Score; } else if (Combination.IsFlush(deck)) { var = new Flush(deck); playerHand = var.PlayerHand; res = var.Score; } else if (Combination.IsStraight(deck)) { var = new Straight(deck); playerHand = var.PlayerHand; res = var.Score; } else if (Combination.IsNofAKind(3, deck, out keys)) { var = new ThreeOfAKind(deck); playerHand = var.PlayerHand; res = var.Score; } else if (Combination.IsTwoPairs(deck, out keys)) { var = new TwoPairs(deck); playerHand = var.PlayerHand; res = var.Score; } else if (Combination.IsNofAKind(2, deck, out keys)) { var = new Pair(deck); playerHand = var.PlayerHand; res = var.Score; } else { deck.Sort(); deck.Reverse(); var = new HighCard(deck); playerHand = var.PlayerHand; res = var.Score; } return(res); }
public IEnumerable <int[]> GetCombinations(State state, int elevatorYPos) { var previousCombinations = new List <Combination>(); var pairs = new Dictionary <int, Pair>(); for (int x = 1; x < state.Width; x += 2) { Pair p = new Pair { Generator = x, Microship = x + 1 }; pairs.Add(x, p); pairs.Add(x + 1, p); } for (int x = 1; x < state.Width; x++) { if (state.GetData(x, elevatorYPos) == string.Empty) { continue; } bool combinationAlreadyExists = false; Combination combo = new Combination(new[] { x }, state, pairs); foreach (var c in previousCombinations) { if (c.IsSameAs(combo)) { combinationAlreadyExists = true; break; } } if (!combinationAlreadyExists) { yield return(combo.Combo); previousCombinations.Add(combo); } for (int x2 = x + 1; x2 < state.Width; x2++) { if (state.GetData(x2, elevatorYPos) == string.Empty) { continue; } combinationAlreadyExists = false; combo = new Combination(new[] { x, x2 }, state, pairs); foreach (var c in previousCombinations) { if (c.IsSameAs(combo)) { combinationAlreadyExists = true; break; } } if (!combinationAlreadyExists) { previousCombinations.Add(combo); yield return(combo.Combo); } } } }
/// <summary> /// To String /// </summary> public override string ToString() { return($"{Combination.Name()} : {string.Join(" ", CombinationSet.Select(c => c.IsJoker ? "Joker" : c.ToString()))}"); }
public static Card NFIWhatToCallMethod(Hand fullHouse, Combination type) { // This method is used for finding the highest three-of-a-kind or highest // pair of a fullhouse hand. How would I name this method??..NFI? Exactly! if (fullHouse.BestCombination != Combination.FullHouse) throw new InvalidOperationException("This method is only designed to be used by Full House hands."); fullHouse.Sort(); Card highest = new Card(Rank.Unassigned, Suit.Unassigned); switch (type) { case Combination.ThreeOfAKind: { int count = 0; foreach (Card c in fullHouse) { if (c.Value == highest.Value) count++; else { highest = c; count = 1; } if (count == 3) break; } break; } case Combination.OnePair: { int count = 0; Card ignore = NFIWhatToCallMethod(fullHouse, Combination.ThreeOfAKind); foreach (Card c in fullHouse) { if (c.Value == ignore.Value) continue; else if (c.Value == highest.Value) count++; else { highest = c; count = 1; } if (count == 2) break; } break; } default: throw new InvalidOperationException("This method only accetps 'type' parameters of Combination.OnePair and Combination.ThreeOfAKind."); } return highest; }
public IList <int> CaculateBonus(string antecode, string winNumber) { string msg; if (!CheckAntecode(antecode, out msg)) { throw new AntecodeFormatException(GameCode, GameType, antecode, "投注号码格式错误 - " + msg); } var checker = AnalyzerFactory.GetWinNumberAnalyzer(GameCode, GameType); if (!checker.CheckWinNumber(winNumber, out msg)) { throw new AntecodeFormatException(GameCode, GameType, winNumber, "中奖号码格式错误 - " + msg); } var red_antecode = AnteCodeNumbers[0].Split(Spliter_Level2); var blue_antecode = AnteCodeNumbers[1].Split(Spliter_Level2); var red_winNumber = checker.WinNumbers[0].Split(Spliter_Level2); var blue_winNumber = checker.WinNumbers[1].Split(Spliter_Level2); var list = new List <int>(); var p = new Combination(); p.Calculate(red_antecode, BallNumber_First, (item_red) => { p.Calculate(blue_antecode, BallNumber_Last, (item_blue) => { var redCount = GetSameCodeCount(item_red, red_winNumber); var blueCount = GetSameCodeCount(item_blue, blue_winNumber); switch (GameCode) { case "SSQ": if (redCount == 6 && blueCount == 1) { list.Add(1); } else if (redCount == 6 && blueCount == 0) { list.Add(2); } else if (redCount == 5 && blueCount == 1) { list.Add(3); } else if ((redCount == 5 && blueCount == 0) || (redCount == 4 && blueCount == 1)) { list.Add(4); } else if ((redCount == 4 && blueCount == 0) || (redCount == 3 && blueCount == 1)) { list.Add(5); } else if (blueCount == 1) { list.Add(6); } break; case "DLT": if (redCount == 5 && blueCount == 2) { list.Add(1); } else if (redCount == 5 && blueCount == 1) { list.Add(2); } else if ((redCount == 5 && blueCount == 0) || (redCount == 4 && blueCount == 2)) { list.Add(3); } //else if (redCount == 4 && blueCount == 2) //{ // list.Add(4); //} else if ((redCount == 4 && blueCount == 1) || (redCount == 3 && blueCount == 2)) { list.Add(4); } //else if ((redCount == 4 && blueCount == 0) || (redCount == 3 && blueCount == 2)) //{ // list.Add(6); //} else if ((redCount == 4 && blueCount == 0) || (redCount == 3 && blueCount == 1) || (redCount == 2 && blueCount == 2)) { list.Add(5); } else if ((redCount == 3 && blueCount == 0) || (redCount == 1 && blueCount == 2) || (redCount == 2 && blueCount == 1) || (redCount == 0 && blueCount == 2)) { list.Add(6); } break; default: throw new ArgumentOutOfRangeException("不支持的彩种 - " + GameCode); } }); }); return(list); }
static void Main(string[] args) { Console.WriteLine("---Generic Stack Test---"); GenericStack<int> stack = new GenericStack<int>(0); stack.Push(1); stack.Push(2); stack.Push(3); while(!stack.IsEmpty()) { Console.WriteLine(stack.Contains(2)); Console.WriteLine(stack.Peek()); Console.WriteLine(stack.Pop()); } Console.WriteLine("---Generic Dequeue Test---"); GenericDequeue<int> dequeue = new GenericDequeue<int>(0); dequeue.AddToEnd(3); dequeue.AddToEnd(4); dequeue.AddToFront(2); dequeue.AddToFront(1); while (!dequeue.IsEmpty()) { Console.WriteLine(dequeue.Contains(3)); Console.WriteLine(dequeue.PeekFromEnd()); Console.WriteLine(dequeue.RemoveFromEnd()); Console.WriteLine(dequeue.Contains(3)); Console.WriteLine(dequeue.PeekFromFront()); Console.WriteLine(dequeue.RemoveFromFront()); } Console.WriteLine("---Lotto Game Test---"); LottoGame<int, string> lottoGame = new LottoGame<int, string>(new Combination<int, string>(1, 2, 3, "a", "b", "c")); var comb1 = new Combination<int, string>(5, 7, 9, "we", "asd", "rgd"); var comb2 = new Combination<int, string>(5, 7, 8, "we", "asd", "rgd"); var comb3 = new Combination<int, string>(5, 7, 9, "we", "asd", "rgd"); var comb4 = new Combination<int, string>(1, 7, 9, "we", "asd", "rgd"); var comb5 = new Combination<int, string>(5, 2, 9, "we", "b", "rgd"); if (lottoGame.AddUserCombination(comb1)) Console.WriteLine("Added combination {0}", comb1); else Console.WriteLine("Combination {0} already exists!", comb1); if (lottoGame.AddUserCombination(comb2)) Console.WriteLine("Added combination {0}", comb2); else Console.WriteLine("Combination {0} already exists!", comb2); if (lottoGame.AddUserCombination(comb3)) Console.WriteLine("Added combination {0}", comb3); else Console.WriteLine("Combination {0} already exists!", comb3); if (lottoGame.AddUserCombination(comb4)) Console.WriteLine("Added combination {0}", comb4); else Console.WriteLine("Combination {0} already exists!", comb4); if (lottoGame.AddUserCombination(comb5)) Console.WriteLine("Added combination {0}", comb5); else Console.WriteLine("Combination {0} already exists!", comb5); Console.WriteLine(); var lottoResult = lottoGame.Validate(); if (lottoResult.IsWinning) Console.WriteLine("This lotto game has a winner with {0} matching values!", lottoResult.MatchedNumbersCount); else Console.WriteLine("There is no winner in this lotto game!"); Console.ReadKey(); }
/// <summary> /// 计算单张票中,最大最小中奖金额(M串N) /// 暂只计算了JCZQ JCLQ /// </summary> public static void GetTicketMinMoneyOrMaxMoney_MN(string playType, string betContent, string betOdds, out decimal minMoney, out decimal maxMoney) { minMoney = 0M; maxMoney = 0M; //M_N var chuanArray = playType.Split('_'); if (chuanArray.Length != 2) { return; } var a = int.Parse(chuanArray[0]); var b = int.Parse(chuanArray[1]); if (b <= 1) { return; } //串关包括的M串1种类 var countList = AnalyzeChuanJC(a, b); var c = new Combination(); //var betContent = "SPF_140709001_3,1/SPF_140709052_1/BRQSPF_140709053_3,0/SPF_140709054_3"; //var betOdds = "140709001_3|1.5200,1|3.7200,0|4.9500/140709052_3|1.8300,1|3.5000,0|3.3600/140709053_3|3.2000,1|3.4500,0|1.9200/140709054_3|2.8800,1|3.5500,0|2.0000"; //拆分odds var oddstrArray = betOdds.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries); //投注内容 var betContentArray = betContent.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries); //投注的比赛 var betMatchIdList = new List <string>(); #region 查找出投注的比赛 foreach (var contentItem in betContentArray) { var matchId = string.Empty; var content = string.Empty; //140709051_2,3 //SPF_140709001_3,1 var array = contentItem.Split(new string[] { "_" }, StringSplitOptions.RemoveEmptyEntries); switch (array.Length) { case 2: matchId = array[0]; break; case 3: matchId = array[1]; break; default: break; } if (!betMatchIdList.Contains(matchId)) { betMatchIdList.Add(matchId); } } #endregion var tempMin = 0M; var tempMax = 0M; foreach (var m in countList) { c.Calculate(betMatchIdList.ToArray(), m, (arr) => { var tempBetContentList = new List <string>(); var tempBetOddsList = new List <string>(); foreach (var item in arr) { foreach (var bc in betContentArray) { if (bc.IndexOf(item) >= 0) { tempBetContentList.Add(bc); } } foreach (var bo in oddstrArray) { if (bo.IndexOf(item) >= 0) { tempBetOddsList.Add(bo); } } } var min = 0M; var max = 0M; GetTicketMinMoneyOrMaxMoney(string.Join("/", tempBetContentList.ToArray()), string.Join("/", tempBetOddsList.ToArray()), out min, out max); if (tempMin == 0M) { tempMin = min; } if (min < tempMin) { tempMin = min; } tempMax += max; }); } minMoney = tempMin; maxMoney = tempMax; }
public void FinishHand() { List<Player> winners = new List<Player>(); Combination comb = new Combination(); foreach (Player p in players) if (!p.WaitForNextHand) { p.TakeBestCards(cards); p.cards.Rebuild(); if (Combination.Compare(p.cards, comb) > 0) comb = p.cards; } foreach (Player p in players) if ((p.cards == comb) && (!p.WaitForNextHand)) winners.Add(p); int winsum = 0; if (winners.Count == 1) { foreach (Player p in winners) { if ((cards.Count == 5) && (gamelog.getMove(0).move != Movements.Fold)) { if (p.roundBet < Bank / 2) { winsum = p.roundBet * 2; p.Stack += winsum; Bank -= winsum; int k = players.IndexOf(p); if (k == 0) players[1].Stack += Bank; else players[0].Stack += Bank; } else { winsum = Bank; p.Stack += winsum; } p.OnMove(new MoveEventArgs(Movements.WinHandsUp, winsum, p)); OnHandsUp(new EventArgs()); } else { p.Stack += Bank; p.OnMove(new MoveEventArgs(Movements.Win, Bank, p)); } } } else { players[0].Stack += Bank / 2; players[1].Stack += Bank / 2; players[0].OnMove(new MoveEventArgs(Movements.WinHandsUp, Bank / 2, players[2])); players[1].OnMove(new MoveEventArgs(Movements.WinHandsUp, Bank / 2, players[1])); } Bank = 0; roundnum++; if (roundnum % 4 == 0) sblind += 2; foreach (Player p in players) { p.foldcards(); p.roundBet = 0; } cards.Clear(); if ((players[0].Stack == 0)||((players[1].Stack == 0))) { OnGameEnd(new EventArgs()); return; } NewDiller(); NewHand(); }
public void Solve() { int[] HWAB = ria(); int H = HWAB[0]; int W = HWAB[1]; int A = HWAB[2]; int B = HWAB[3]; if (A == 0) { Console.WriteLine(1); Console.ReadLine(); } // B畳の配置パターンを生成 int[] suuretsu = generateSuretsu(H * W); int[][] bHaichiss = Combination.Enumerate(suuretsu, B, withRepetition: false).ToArray(); long ans = 0; foreach (int[] bHaichs in bHaichiss) { bool[,] isTatami = new bool[H, W]; // B畳を配置 foreach (int bHaich in bHaichs) { isTatami[bHaich / H, bHaich % W] = true; } // A畳を配置 HashSet <HashSet <HashSet <Zahyo> > > aZahyoSetSetSet = new HashSet <HashSet <HashSet <Zahyo> > >(); for (int i = 0; i < 3; i++) { Console.WriteLine("-----------------------"); Console.WriteLine(aZahyoSetSetSet.Count + "パターン目"); HashSet <HashSet <Zahyo> > aZahyoSetSet = new HashSet <HashSet <Zahyo> >(); int aTatamiCnt = 0; for (int h = 0; h < H; h++) { for (int w = 0; w < W; w++) { if (isTatami[h, w]) { continue; } foreach (Dir dir in Enum.GetValues(typeof(Dir))) { int[] hwOffset = getOffset(dir); int hDir = h + hwOffset[0]; int wDir = w + hwOffset[1]; if (hDir < 0 || hDir >= H || wDir < 0 || wDir >= W || isTatami[hDir, wDir]) { continue; } isTatami[h, w] = true; isTatami[hDir, wDir] = true; HashSet <Zahyo> aZahyoSet = new HashSet <Zahyo>(); aZahyoSet.Add(new Zahyo(h, w)); aZahyoSet.Add(new Zahyo(hDir, wDir)); aZahyoSetSet.Add(aZahyoSet); Console.WriteLine(++aTatamiCnt + "枚目"); printTatamis(isTatami); break; } } } aZahyoSetSetSet.Add(aZahyoSetSet); } ans += aZahyoSetSetSet.Count(); } Console.WriteLine(ans); Console.ReadLine(); }
public Combination CardCombo(Combination cardcombo) { cardcombo = Combination.None; return cardcombo; }
public IList <int> CaculateBonus(string antecode, string winNumber) { string msg; if (!CheckAntecode(antecode, out msg)) { throw new AntecodeFormatException(GameCode, GameType, antecode, "投注号码格式错误 - " + msg); } var checker = AnalyzerFactory.GetWinNumberAnalyzer(GameCode, GameType); if (!checker.CheckWinNumber(winNumber, out msg)) { throw new AntecodeFormatException(GameCode, GameType, winNumber, "中奖号码格式错误 - " + msg); } var red_dan = AnteCodeNumbers[0].Split(Spliter_Level2); var red_tuo = AnteCodeNumbers[1].Split(Spliter_Level2); string[] blue_dan, blue_tuo; if (NeedLastDan) { blue_dan = AnteCodeNumbers[2].Split(Spliter_Level2); blue_tuo = AnteCodeNumbers[3].Split(Spliter_Level2); } else { blue_dan = new string[0]; blue_tuo = AnteCodeNumbers[2].Split(Spliter_Level2); } var red_winNumber = checker.WinNumbers[0].Split(Spliter_Level2); var blue_winNumber = checker.WinNumbers[1].Split(Spliter_Level2); var list = new List <int>(); var p = new Combination(); p.Calculate(red_tuo, BallNumber_First - red_dan.Length, (item_red) => { p.Calculate(blue_tuo, BallNumber_Last - blue_dan.Length, (item_blue) => { var redList = new List <string>(red_dan); redList.AddRange(item_red); var count_red = GetSameCodeCount(redList.ToArray(), red_winNumber); var blueList = new List <string>(blue_dan); blueList.AddRange(item_blue); var count_blue = GetSameCodeCount(blueList.ToArray(), blue_winNumber); switch (GameCode) { case "SSQ": if (count_red == 6 && count_blue == 1) { list.Add(1); } else if (count_red == 6 && count_blue == 0) { list.Add(2); } else if (count_red == 5 && count_blue == 1) { list.Add(3); } else if ((count_red == 5 && count_blue == 0) || (count_red == 4 && count_blue == 1)) { list.Add(4); } else if ((count_red == 4 && count_blue == 0) || (count_red == 3 && count_blue == 1)) { list.Add(5); } else if (count_blue == 1) { list.Add(6); } break; case "DLT": if (count_red == 5 && count_blue == 2) { list.Add(1); } else if (count_red == 5 && count_blue == 1) { list.Add(2); } else if ((count_red == 5 && count_blue == 0) || (count_red == 4 && count_blue == 2)) { list.Add(3); } //else if (count_red == 4 && count_blue == 2) //{ // list.Add(4); //} else if ((count_red == 4 && count_blue == 1) || (count_red == 3 && count_blue == 2)) { list.Add(4); } //else if ((count_red == 4 && count_blue == 0) || (count_red == 3 && count_blue == 2)) //{ // list.Add(6); //} else if ((count_red == 4 && count_blue == 0) || (count_red == 3 && count_blue == 1) || (count_red == 2 && count_blue == 2)) { list.Add(5); } else if ((count_red == 3 && count_blue == 0) || (count_red == 1 && count_blue == 2) || (count_red == 2 && count_blue == 1) || (count_red == 0 && count_blue == 2)) { list.Add(6); } break; default: throw new ArgumentOutOfRangeException("不支持的彩种 - " + GameCode); } }); }); return(list); }