Пример #1
0
 public bool IsValidMove(int index)
 {
     if (PreviousPiece == 0)
     {
         return(MoveList.Any(items => items.SpaceFrom == index));
     }
     return(MoveList.Any(items => items.SpaceTo == index)); //i think this simple.  hopefully does not have to allow any move (?)
 }
Пример #2
0
        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();
            }
        }
Пример #3
0
 public bool IsValidMove(int index) //done now.
 {
     return(MoveList.Any(items => items.SpaceFrom == index));
 }