Exemple #1
0
        private static bool IsOpen(LineEnumerable line)
        {
            bool[] runs = new bool[] { true, true };
            for (int run = 0; run < 2; run++)
            {
                int     i     = 0;
                SquareT match = SquareT.Empty;
                foreach (var item in line)
                {
                    if (run == 0 ? i == 0 : i == Board.SideLen - 1)
                    {
                        i++;
                        continue;
                    }

                    if (item != SquareT.Empty && match == SquareT.Empty)
                    {
                        match = item;
                    }

                    if (item != SquareT.Empty && item != match)
                    {
                        runs[run] = false;
                        break;
                    }

                    i++;
                }
            }
            return(runs[0] || runs[1]);
        }
Exemple #2
0
        private static int RunLen(LineEnumerable line)
        {
            var t   = MainRun(line);
            int ret = 0;

            foreach (var item in line)
            {
                if (item == t)
                {
                    ret++;
                }
            }
            return(ret);
        }
Exemple #3
0
        private static SquareT MainRun(LineEnumerable line)
        {
            int x = 0, o = 0;

            foreach (var item in line)
            {
                if (item == SquareT.X)
                {
                    x++;
                }
                else if (item == SquareT.O)
                {
                    o++;
                }
            }
            return(x > o ? SquareT.X : SquareT.O);
        }