Ejemplo n.º 1
0
        private void ChessRecognize_ChessRecognized(object sender, ChessRecongizedEventArgs e)
        {
            Console.WriteLine("-------------------" + DateTime.Now.ToString() + "-------------------");
            //判断棋盘是否有误
            //有效:黑子数量=白子数量
            //有效:黑子数量=白子数量+1
            //使用LINQ进行操作

            var blackCount = (from r in e.ChessPointList
                              where r.Item3 == 1
                              select r).Count();
            var whiteCount = (from r in e.ChessPointList
                              where r.Item3 == 2
                              select r).Count();

            if ((blackCount == whiteCount || blackCount == whiteCount + 1) == false)
            {
                Console.WriteLine($"识图有误!blackCount={blackCount},whiteCount={whiteCount}");
                //如果执行到这里,则需要人工参与
            }
            else
            {
                //正常处理
                foreach (var item in e.ChessPointList)
                {
                    Console.WriteLine($"{item.Item1},{item.Item2},{item.Item3}");
                }
            }
        }
Ejemplo n.º 2
0
 private void ChessRecognize_ChessRecognized(object sender, ChessRecongizedEventArgs e)
 {
     Console.WriteLine("-------------------" + DateTime.Now.ToString() + "-------------------");
     foreach (var item in e.ChessPointList)
     {
         Console.WriteLine($"{item.Item1},{item.Item2},{item.Item3}");
     }
 }