Esempio n. 1
0
        internal void FillArray2Options(OutcomeList outcomelist, Sudokunumber sn, int[,] sudokuarray, int possibillities)
        {
            List <int[, ]> sudokuarrays       = new List <int[, ]>();
            var            possibilitiesarray = sn.Possibilitiesarray;
            List <int[, ]> sudokus            = new List <int[, ]>();

            sudokus = FillFieldsonRows(sn, sudokuarray, possibillities);
            foreach (var item in sudokus)
            {
                OutcomeList outcomes = new OutcomeList(item);
                outcomelist.OutcomesList.Add(outcomes);
            }
            sudokus = FillFieldsonColumns(sn, sudokuarray, possibillities);
            foreach (var item in sudokus)
            {
                OutcomeList outcomes = new OutcomeList(item);
                outcomelist.OutcomesList.Add(outcomes);
            }
            sudokus = FillFieldsonFields(sn, sudokuarray, possibillities);
            foreach (var item in sudokus)
            {
                OutcomeList outcomes = new OutcomeList(item);
                outcomelist.OutcomesList.Add(outcomes);
            }
        }
Esempio n. 2
0
        internal void PreFilling(OutcomeList arraylists)
        {
            Sudokunumber sn   = new Sudokunumber();
            int          size = arraylists.Outcomes.GetLength(0);

            for (int i = 1; i <= size; i++)
            {
                sn = arraylists.Sudokulist.Sudokus.Find(x => x.Number == i);
                UpdateValues(arraylists.Outcomes, sn);
                FillArray2Options(arraylists, sn, arraylists.Outcomes, 2);
            }
        }
Esempio n. 3
0
        internal void CreateList(OutcomeList arraylists)
        {
            var        size = arraylists.Outcomes.GetLength(0);
            Sudokulist sl   = new Sudokulist();

            for (int i = 1; i <= size; i++)
            {
                sl.Sudokus.Add(new Sudokunumber(i));
                for (int j = 1; j <= size; j++)
                {
                    sl.Sudokus.Find(x => x.Number == i).Rows.Add(new Row(j, size));
                    sl.Sudokus.Find(x => x.Number == i).Columns.Add(new Column(j, size));
                    sl.Sudokus.Find(x => x.Number == i).Fields.Add(new Field(j));
                }
            }
            arraylists.Sudokulist = sl;
        }
Esempio n. 4
0
        internal void Filling(OutcomeList arraylists)
        {
            var          size         = arraylists.Outcomes.GetLength(0);
            Sudokunumber sn           = new Sudokunumber();
            var          checkcounter = 0;
            var          counter      = 0;

            do
            {
                checkcounter = counter;
                counter      = 0;
                CreateList(arraylists);
                for (int j = 1; j <= size; j++)
                {
                    sn = arraylists.Sudokulist.Sudokus.Find(x => x.Number == j);
                    UpdateValues(arraylists.Outcomes, sn);

                    sn = arraylists.Sudokulist.Sudokus.Find(x => x.Number == j);
                    PossibilityFinder(arraylists.Outcomes, sn);
                    FillArray1Option(sn, arraylists.Outcomes, 1);


                    UpdateValues(arraylists.Outcomes, sn);
                }
                counter = CountZeros(arraylists.Outcomes);
            }while (counter != checkcounter && counter > 0);
            if (counter == 0)
            {
                arraylists.Solved = true;
                arraylists.Dispose();
            }
            else
            {
                arraylists.amountofZeros = CountZeros(arraylists.Outcomes);
                arraylists.Solved        = false;
            }
        }