/// <summary> /// 局面ハッシュを再計算するぜ☆(^▽^) /// </summary> /// <returns></returns> public void Tukurinaosi(Kyokumen ky) { ulong hash = 0; // 盤上 Bitboard komaBB = new Bitboard(); for (int iTai = 0; iTai < Conv_Taikyokusya.AllOptionalPhaseList.Length; iTai++) { var optionalPhase = Conv_Taikyokusya.AllOptionalPhaseList[iTai]; for (int iKs = 0; iKs < Conv_Komasyurui.Itiran.Length; iKs++) { Komasyurui ks = Conv_Komasyurui.Itiran[iKs]; Koma km = Med_Koma.KomasyuruiAndTaikyokusyaToKoma(ks, optionalPhase); ky.Shogiban.ToSet_BBKoma(km, komaBB); while (komaBB.Ref_PopNTZ(out Masu ms)) { hash ^= Util_ZobristHashing.GetBanjoKey(ms, km, ky.Sindan); } } } // 持ち駒 foreach (MotiKoma mk in Conv_MotiKoma.Itiran) { hash ^= Util_ZobristHashing.GetMotiKey(ky.Sindan, mk); } // 手番 hash ^= Util_ZobristHashing.GetTaikyokusyaKey(ky.CurrentOptionalPhase, ky.Sindan); Value = hash; }
/// <summary> /// /// </summary> /// <returns></returns> public static ulong GetTaikyokusyaKey(Option <Phase> optionalPhase, Kyokumen.Sindanyo kys) { if (Util_ZobristHashing.Dirty) { Util_ZobristHashing.Tukurinaosi(kys); } return(Util_ZobristHashing.m_tbTaikyokusya_[OptionalPhase.IndexOf(optionalPhase)]); }
/// <summary> /// /// </summary> /// <returns></returns> public static ulong GetMotiKey(Kyokumen.Sindanyo kys, MotiKoma mk) { if (Util_ZobristHashing.Dirty) { Util_ZobristHashing.Tukurinaosi(kys); } return(Util_ZobristHashing.m_motiKeys_[(int)mk][kys.CountMotikoma(mk)]); }