Example #1
0
        private void FillEmbeddedRowFromInfo(DataRow row, UciInfoResponse info)
        {
            row["Move"] = Lan.LanToMoveWithSan(info.Fen, info.PV.Or(new List <string>()).FirstOrDefault());
            row["D/SD"] = new KeyValuePair <int, int>(info.Depth.Or(0), info.SelDepth.Or(0));
            var score = info.Score.Or(new UciScore(0, UciScoreType.Cp, UciScoreBoundType.Exact));

            row["Score"]    = score;
            row["ScoreInt"] = score.ToInteger() * GetSideToMoveScoreMultiplier();
            row["Time"]     = TimeSpan.FromSeconds(info.Time.Or(0) / 1000);
            row["Nodes"]    = info.Nodes.Or(0);
            row["NPS"]      = info.Nps.Or(0);
            row["MultiPV"]  = info.MultiPV.Or(0);
            row["TBHits"]   = info.TBHits.Or(0);
        }
Example #2
0
        private void ReceiveMessage(Object sender, DataReceivedEventArgs e)
        {
            if (e.Data == null)
            {
                return;
            }

            System.Diagnostics.Debug.WriteLine("Received: " + e.Data);

            if (UciInfoHandler != null && e.Data.StartsWith("info"))
            {
                var infoResponse = new UciInfoResponse(Fen, e.Data);
                if (infoResponse.IsLegal())
                {
                    try
                    {
                        UciInfoHandler.Invoke(infoResponse);
                    }
                    catch (Exception)
                    {
                        MessageQueue.Clear();
                    }
                }
            }
            else if (e.Data.StartsWith("option"))
            {
                AddOption(e.Data);
            }
            else if (e.Data.StartsWith("id"))
            {
                SetId(e.Data);
            }
            else
            {
                MessageQueue.Enqueue(e.Data);
            }
        }
Example #3
0
 private void OnInfoResponse(UciInfoResponse info)
 {
     PendingInfoResponses.Enqueue(info);
 }