예제 #1
0
        private string CalcMinShantenPai(int mypositionId, string pai, List <Tehai> tehais, List <Kawa> kawas, Field field)
        {
            var syu = new int[MJUtil.LENGTH_SYU_ALL];

            foreach (var p in tehais[mypositionId].tehai)
            {
                syu[p.PaiNumber]++;
            }
            var resultDict = new Dictionary <int, int>();

            foreach (var paiId in syu.Select((value, index) => new { value, index }))
            {
                if (paiId.value == 0)
                {
                    continue;
                }

                syu[paiId.index]--;
                resultDict.Add(paiId.index, shantenCalclator.CalcShantenWithFuro(syu, tehais[mypositionId].furos.Count));
                syu[paiId.index]++;
            }
            var bestPaiIndex = resultDict.OrderBy(e => e.Value).First().Key;
            var paiString    = tehais[mypositionId].tehai.Where(e => e.PaiNumber == bestPaiIndex).First().PaiString;


            return(paiString);
        }
예제 #2
0
파일: Tehai.cs 프로젝트: majiang/MjModel
 public int GetShanten()
 {
     syu.Initialize();
     foreach (var pai in tehai)
     {
         syu[pai.PaiNumber]++;
     }
     return(shantenCanclator.CalcShantenWithFuro(syu, furos.Count));
 }