void bonanza_ReceivedCommand(object sender, BonanzaReceivedCommandEventArgs e) { try { // Bonanzaのコマンドは同じものが2回くることがあるため、 // 重複を避けています。 if (this.parsedCommandList.IndexOf(e.Command) >= 0) { return; } if (this.parsedCommandList.Count() >= 3) { this.parsedCommandList.RemoveAt(0); } this.parsedCommandList.Add(e.Command); Log.Debug("< {0}", e.Command); BonanzaCommandParser.Parse(e.Command); } catch (Exception ex) { Util.ThrowIfFatal(ex); Log.ErrorException(ex, "{0}: コマンドの解析に失敗しました。", e.Command); } }
void bonanza_ReceivedCommand(object sender, BonanzaReceivedCommandEventArgs e) { var m = MoveRegex.Match(e.Command); if (m.Success) { var move = CsaMove.Parse(m.Groups[1].Value); if (move == null) { return; } var nback = int.Parse(m.Groups[2].Value); while (nback > 0 && MoveList.Any()) { MoveList.RemoveAt(MoveList.Count - 1); } MoveList.Add(move); // 奇数手目は先手側の手です。 PonderMove = ((MoveList.Count & 1) == 1 ? move : null); } m = VariationRegex.Match(e.Command); if (m.Success) { var variation = VariationInfo.Create( double.Parse(m.Groups[1].Value), e.Command.Substring(m.Length)); if (variation == null) { return; } if (VariationList.Count > 5) { VariationList.RemoveAt(0); } VariationList.Add(variation); } m = CpuRegex.Match(e.Command); if (m.Success) { CpuUsage = double.Parse(m.Groups[2].Value); Nps = double.Parse(m.Groups[3].Value); VariationList.Clear(); } }