Ejemplo n.º 1
0
        public bool WinningMove(TicTacToe t)
        {
            MoveCount n = x;

            if (n.player != t.CurrentPlayer())
            {
                return(false);
            }
            for (int i = 0; i < win; i++)
            {
                if (n.columns[i] == (win - 1))
                {
                    for (int j = 0; j < win; j++)
                    {
                        if (t.ValInBoard(j, i) == '\0')
                        {
                            t.Insert(n.player, j, i);
                            return(true);
                        }
                    }
                }
                if (n.rows[i] == (win - 1))
                {
                    for (int j = 0; j < win; j++)
                    {
                        if (t.ValInBoard(i, j) == '\0')
                        {
                            t.Insert(n.player, i, j);
                            return(true);
                        }
                    }
                }
            }
            if (n.diagonals[0] == (win - 1))
            {
                for (int j = 0; j < win; j++)
                {
                    if (t.ValInBoard(j, j) == '\0')
                    {
                        t.Insert(n.player, j, j);
                        return(true);
                    }
                }
            }
            else if (n.diagonals[1] == (win - 1))
            {
                for (int j = 0; j < win; j++)
                {
                    if (t.ValInBoard(j, (size - 1 - j)) == '\0')
                    {
                        t.Insert(n.player, j, (size - 1 - j));
                        return(true);
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
        public override int GetHashCode()
        {
            int hashCode = 409305774;

            hashCode = hashCode * -1521134295 + base.GetHashCode();
            hashCode = hashCode * -1521134295 + CurrentPosition.GetHashCode();
            hashCode = hashCode * -1521134295 + Player.GetHashCode();
            hashCode = hashCode * -1521134295 + MoveCount.GetHashCode();
            hashCode = hashCode * -1521134295 + MoveDirection.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Name);

            return(hashCode);
        }