Beispiel #1
0
        private List<PlayHint> ParseMoveHints(string hints, int[] dice, GameState gamestate)
        {
            if (hints.StartsWith("There are no legal moves."))
                return null;

            List<PlayHint> move_hints = new List<PlayHint>();

            //string[] hs = hints.Split(new char[] { ']' });
            string[] hs = hints.Split(new string[] { ". " }, StringSplitOptions.RemoveEmptyEntries);
            string hint = "";

            // Skip the first one.
            for (int i = 1; i < hs.Length; i++)
            {
                hint = hs[i];
                int s = hint.IndexOf("-ply");
                if (s < 0)
                    continue;

                int e = hint.IndexOf("Eq.:");
                if (e < 0)
                {
                    e = hint.IndexOf("MWC");
                }
                if (e < 0)
                {
                    e = hint.IndexOf("uity");
                }

                // Parse equity.
                int eq_e = hint.IndexOfAny(new char[] { '(', '\r' }, e + 4);
                double eq = double.Parse(hint.Substring(e + 4, eq_e - (e + 4)));

                hint = hint.Substring(s + 4, e - s - 4).Trim();

                // Console.WriteLine("GnuBg: " + hint);
                string[] moves_strings = hint.Split(new char[] { ' ' });
                int count = 0;
                List<Move> moves = new List<Move>();
                foreach (string move_string in moves_strings)
                {
                    Move move = ParseMoveHint(move_string, out count, moves_strings.Length, dice, gamestate);
                    for (int c = 0; c < count; c++)
                        moves.Add(move);
                }

                PlayHint play_hint = new PlayHint(moves, eq);

                play_hint.Play.SortHiToLow();

                move_hints.Add(play_hint);
            }

            return move_hints;
        }
Beispiel #2
0
        private List <PlayHint> ParseMoveHints(string hints, int[] dice, GameState gamestate)
        {
            if (hints.StartsWith("There are no legal moves."))
            {
                return(null);
            }

            List <PlayHint> move_hints = new List <PlayHint>();

            //string[] hs = hints.Split(new char[] { ']' });
            string[] hs   = hints.Split(new string[] { ". " }, StringSplitOptions.RemoveEmptyEntries);
            string   hint = "";

            // Skip the first one.
            for (int i = 1; i < hs.Length; i++)
            {
                hint = hs[i];
                int s = hint.IndexOf("-ply");
                if (s < 0)
                {
                    continue;
                }

                int e = hint.IndexOf("Eq.:");
                if (e < 0)
                {
                    e = hint.IndexOf("MWC");
                }
                if (e < 0)
                {
                    e = hint.IndexOf("uity");
                }

                // Parse equity.
                int    eq_e = hint.IndexOfAny(new char[] { '(', '\r' }, e + 4);
                double eq   = double.Parse(hint.Substring(e + 4, eq_e - (e + 4)));

                hint = hint.Substring(s + 4, e - s - 4).Trim();

                // Console.WriteLine("GnuBg: " + hint);
                string[]    moves_strings = hint.Split(new char[] { ' ' });
                int         count         = 0;
                List <Move> moves         = new List <Move>();
                foreach (string move_string in moves_strings)
                {
                    Move move = ParseMoveHint(move_string, out count, moves_strings.Length, dice, gamestate);
                    for (int c = 0; c < count; c++)
                    {
                        moves.Add(move);
                    }
                }

                PlayHint play_hint = new PlayHint(moves, eq);

                play_hint.Play.SortHiToLow();

                move_hints.Add(play_hint);
            }

            return(move_hints);
        }