public string GetMove(int rnd) { CEmoList emoList = GetEmoList(); if (emoList.Count == 0) { return(String.Empty); } CRec rec = new CRec(); rec.hash = GetHash(); int mat = -emoList[0].mat; if (mat > 0) { mat--; } rec.mat = (sbyte)mat; recList.RecUpdate(rec); CEmo bst = emoList.GetRnd(rnd); string umo = Chess.EmoToUmo(bst.emo); int mate = MatToMate(bst.mat); Console.WriteLine($"info string book {umo} {mate:+#;-#;0} ({emoList.Count})"); return(umo); }
public CEmoList GetEmoList() { CEmoList emoList = new CEmoList(); List <int> moves = Chess.GenerateValidMoves(out _, true); foreach (int m in moves) { Chess.MakeMove(m); ulong hash = GetHash(); CRec rec = recList.GetRec(hash); if (rec != null) { CEmo emo = new CEmo { emo = m, mat = rec.mat, age = rec.age }; emoList.Add(emo); } Chess.UnmakeMove(m); } emoList.SortMat(); return(emoList); }