protected virtual void thinkSutehai(Hai addHai) { _action.SutehaiIndex = Tehai.getJyunTehaiCount(); Tehai tehaiCopy = new Tehai(Tehai); FormatWorker.setCounterFormat(tehaiCopy, null); int maxScore = getCountFormatScore(FormatWorker); for (int i = 0; i < tehaiCopy.getJyunTehaiCount(); i++) { Hai hai = tehaiCopy.removeJyunTehaiAt(i); FormatWorker.setCounterFormat(tehaiCopy, addHai); int score = getCountFormatScore(FormatWorker); if (score > maxScore) { maxScore = score; _action.SutehaiIndex = i; } tehaiCopy.insertJyunTehai(i, hai); } }
protected virtual void thinkReach() { _action.ReachSelectIndex = 0; List <int> reachHaiIndex = _action.ReachHaiIndexList; Tehai tehaiCopy = new Tehai(Tehai); int minScore = int.MaxValue; for (int i = 0; i < reachHaiIndex.Count; i++) { Hai hai = tehaiCopy.removeJyunTehaiAt(reachHaiIndex[i]); // reachHaiIndex[i], not i List <Hai> machiiHais; if (MahjongAgent.tryGetMachiHais(tehaiCopy, out machiiHais)) { for (int m = 0; m < machiiHais.Count; m++) { Hai addHai = machiiHais[m]; FormatWorker.setCounterFormat(tehaiCopy, addHai); int score = MahjongAgent.getAgariScore(tehaiCopy, addHai, JiKaze); if (score <= minScore) { minScore = score; _action.ReachSelectIndex = i; } } } tehaiCopy.insertJyunTehai(i, hai); } }
// 打哪些牌可以立直. public bool tryGetReachHaiIndex(Tehai a_tehai, Hai tsumoHai, out List <int> haiIndexList) { haiIndexList = new List <int>(); // 鳴いている場合は、リーチできない。x //if( a_tehai.isNaki() ) // return false; /// find all reach-enabled hais in a_tehai, also the tsumoHai. _reachHaiList.Clear(); // As _jyunTehais won't sort automatically on new hais added, // so we can add tsumo hai directly to simplify the checks. Tehai tehai_copy = new Tehai(a_tehai); tehai_copy.addJyunTehai(tsumoHai); tehai_copy.Sort(); Hai[] jyunTehai = tehai_copy.getJyunTehai(); for (int i = 0; i < jyunTehai.Length; i++) { Hai haiTemp = tehai_copy.removeJyunTehaiAt(i); for (int id = Hai.ID_MIN; id <= Hai.ID_MAX; id++) { countFormat.setCounterFormat(tehai_copy, new Hai(id)); if (countFormat.calculateCombisCount(combis) > 0) { _reachHaiList.Add(new Hai(haiTemp)); break; } } tehai_copy.insertJyunTehai(i, haiTemp); } /// transfer to index list. if (_reachHaiList.Count > 0) { jyunTehai = a_tehai.getJyunTehai(); for (int i = 0; i < _reachHaiList.Count; i++) { for (int j = 0; j < jyunTehai.Length; j++) { if (jyunTehai[j].ID == _reachHaiList[i].ID && !haiIndexList.Contains(j)) { haiIndexList.Add(j); } } if (tsumoHai.ID == _reachHaiList[i].ID && !haiIndexList.Contains(jyunTehai.Length)) { haiIndexList.Add(jyunTehai.Length); } } haiIndexList.Sort(); return(true); } return(false); }