private void FindPossibleMatch(int row)
        {
            if (this.hasAddedFixtureMatches || this.hasFoundAllCombinations)
            {
                return;
            }

            if (row == this.size)
            {
                this.CheckAllComminations();

                return;
            }

            int col    = 0;
            int maxCol = row - 1;

            while (col <= maxCol)
            {
                if (this.IsMatchAvailable(row, col))
                {
                    var match = new RoundMatch(row, col, this.round);
                    this.tempMatches.Push(match);
                    this.occupiedRowsAndCols[row] = true;
                    this.occupiedRowsAndCols[col] = true;
                    this.tempBoard[row, col]      = true;

                    if (this.tempMatches.Count == this.tempMatchesMaxCount)
                    {
                        this.AddTempOpponetsToFinalList();
                        this.hasAddedFixtureMatches = true;
                    }

                    this.FindPossibleMatch(row + 1);

                    if (this.hasAddedFixtureMatches || this.hasFoundAllCombinations)
                    {
                        return;
                    }

                    this.tempMatches.Pop();
                    this.occupiedRowsAndCols[row] = false;
                    this.occupiedRowsAndCols[col] = false;
                    this.tempBoard[row, col]      = false;
                }

                col++;
            }

            this.FindPossibleMatch(row + 1);
        }
        public IList <RoundMatch> GenerateRoundsMatches()
        {
            if (this.size <= 1)
            {
                return(null);
            }
            else if (this.size == 2)
            {
                var firstMatch = new RoundMatch(1, 0, 0);
                this.matches.Add(firstMatch);
                this.board[1, 0] = true;

                // var secondMatch = new RoundMatch(0, 1, 1);
                // this.matches.Add(secondMatch);
                return(this.matches);
            }

            int row = 1;

            while (row < this.size)
            {
                var match = new RoundMatch(row, 0, this.round);
                this.tempMatches = new Stack <RoundMatch>();
                this.tempMatches.Push(match);
                this.tempBoard                = new bool[this.size, this.size];
                this.tempBoard[row, 0]        = true;
                this.occupiedRowsAndCols      = new bool[this.size];
                this.occupiedRowsAndCols[row] = true;
                this.occupiedRowsAndCols[0]   = true;
                this.hasAddedFixtureMatches   = false;
                this.board[row, 0]            = true;
                this.FindPossibleMatch(2);
                row++;
            }

            return(this.matches);
        }
        public IList<RoundMatch> GenerateRoundsMatches()
        {
            if (this.size <= 1)
            {
                return null;
            }
            else if (this.size == 2)
            {
                var firstMatch = new RoundMatch(1, 0, 0);
                this.matches.Add(firstMatch);
                this.board[1, 0] = true;

                // var secondMatch = new RoundMatch(0, 1, 1);
                // this.matches.Add(secondMatch);
                return this.matches;
            }

            int row = 1;
            while (row < this.size)
            {
                var match = new RoundMatch(row, 0, this.round);
                this.tempMatches = new Stack<RoundMatch>();
                this.tempMatches.Push(match);
                this.tempBoard = new bool[this.size, this.size];
                this.tempBoard[row, 0] = true;
                this.occupiedRowsAndCols = new bool[this.size];
                this.occupiedRowsAndCols[row] = true;
                this.occupiedRowsAndCols[0] = true;
                this.hasAddedFixtureMatches = false;
                this.board[row, 0] = true;
                this.FindPossibleMatch(2);
                row++;
            }

            return this.matches;
        }
        private void FindPossibleMatch(int row)
        {
            if (this.hasAddedFixtureMatches || this.hasFoundAllCombinations)
            {
                return;
            }

            if (row == this.size)
            {
                this.CheckAllComminations();

                return;
            }

            int col = 0;
            int maxCol = row - 1;
            while (col <= maxCol)
            {
                if (this.IsMatchAvailable(row, col))
                {
                    var match = new RoundMatch(row, col, this.round);
                    this.tempMatches.Push(match);
                    this.occupiedRowsAndCols[row] = true;
                    this.occupiedRowsAndCols[col] = true;
                    this.tempBoard[row, col] = true;

                    if (this.tempMatches.Count == this.tempMatchesMaxCount)
                    {
                        this.AddTempOpponetsToFinalList();
                        this.hasAddedFixtureMatches = true;
                    }

                    this.FindPossibleMatch(row + 1);

                    if (this.hasAddedFixtureMatches || this.hasFoundAllCombinations)
                    {
                        return;
                    }

                    this.tempMatches.Pop();
                    this.occupiedRowsAndCols[row] = false;
                    this.occupiedRowsAndCols[col] = false;
                    this.tempBoard[row, col] = false;
                }

                col++;
            }

            this.FindPossibleMatch(row + 1);
        }