public static List<Result> Calc(TPC[] tpcs) { var results = new List<Result>(); if (tpcs == null || tpcs.Length == 0) return results; //var get111_results = tpcs.Get111(); //foreach (var tps in get111_results) //{ // var groups = new List<Group>(); // groups.Add(new Group(tps, CheckTypes.Get111)); // var left = tpcs.Remove(tps); // if (left != null && left.Length > 0) // Calc(results, groups, left); // else // results.Add(new Result(groups, left)); //} //var get123_results = tpcs.Get123(); //foreach (var tps in get123_results) //{ // var groups = new List<Group>(); // groups.Add(new Group(tps, CheckTypes.Get123)); // var left = tpcs.Remove(tps); // if (left != null && left.Length > 0) // Calc(results, groups, left); // else // results.Add(new Result(groups, left)); //} var get11_results = tpcs.Get11(); //获取牌组中成对出现的牌 foreach (var tps in get11_results) //迭代之 { var groups = new List<Group>(); groups.Add(new Group(tps, CheckTypes.Get11)); //转换牌的集合为Group对象并添加的List<Group>中 var left = tpcs.Remove(tps); //通过Remove方法把已经转换为牌组的对象从中删除,得出剩余的牌 if (left != null && left.Length > 0) //如果有剩余的牌 Calc(results, groups, left); //该方法的意思是??? else results.Add(new Result(groups, left)); // } if ( //get111_results.Length == 0 && //get123_results.Length == 0 && get11_results.Length == 0 ) { results.Add(new Result(new List<Group>(), tpcs)); } return results; }
public Result(List<Group> groups, TPC[] left) { this.Gs = groups; this.LeftTPs = left.GetTPs(); if (groups != null && groups.Count > 0) { this.Rank = groups.Sum(o => (int)o.CheckType); } else this.Rank = 0; if (left == null || left.Length == 0) this.Rank += 1000; // const 1000 }
public static void Calc(List<Result> results, List<Group> groups, TPC[] leftTPCs) { var get111_results = leftTPCs.Get111(); //得到三张相连牌组 if (get111_results != null) foreach (var tps in get111_results) { var new_groups = new List<Group>(groups); new_groups.Add(new Group(tps, CheckTypes.Get111)); new_groups.SortByCT(); if (results.CheckExists(new_groups)) return; var left = leftTPCs.Remove(tps); if (left != null && left.Length > 0) Calc(results, new_groups, left); else results.Add(new Result(new_groups, left)); } var get123_results = leftTPCs.Get123(); if (get123_results != null) foreach (var tps in get123_results) { var new_groups = new List<Group>(groups); new_groups.Add(new Group(tps, CheckTypes.Get123)); new_groups.SortByCT(); if (results.CheckExists(new_groups)) return; //todo 看到这里了... var left = leftTPCs.Remove(tps); if (left != null && left.Length > 0) Calc(results, new_groups, left); else results.Add(new Result(new_groups, left)); } //var get11_results = leftTPCs.Get11(); //if (get11_results != null) foreach (var tps in get11_results) // { // var new_groups = new List<Group>(groups); // new_groups.Add(new Group(tps, CheckTypes.Get11)); // new_groups.SortByCT(); // if (results.CheckExists(new_groups)) return; // var left = leftTPCs.Remove(tps); // if (left != null && left.Length > 0) // Calc(results, new_groups, left); // else // results.Add(new Result(new_groups, left)); // } if ( get111_results.Length == 0 && get123_results.Length == 0// && //get11_results.Length == 0 ) { results.Add(new Result(new List<Group>(groups), leftTPCs)); return; } }