예제 #1
0
        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);
        }
예제 #2
0
 public void InfoMoves(string moves)
 {
     Chess.SetFen();
     if (!Chess.MakeMoves(moves))
     {
         Console.WriteLine("wrong moves");
     }
     else
     {
         CEmoList el = GetEmoList();
         if (el.Count == 0)
         {
             Console.WriteLine("no moves found");
         }
         else
         {
             Console.WriteLine("id move  wage age");
             Console.WriteLine();
             int i = 1;
             foreach (CEmo e in el)
             {
                 string umo = Chess.EmoToUmo(e.emo);
                 Console.WriteLine(String.Format("{0,2} {1,-4} {2,5} {3,3}", i++, umo, e.mat, e.age));
             }
         }
     }
 }
예제 #3
0
        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);
        }