示例#1
0
        public static void generateRandom(int widthIN, int heightIN, int random)
        {
            matrix m = new matrix(widthIN, heightIN);
            m.solveHead();

            int rcount = 0;
            Random RN = new Random();

            while (rcount < random)
            {
                int x = RN.Next() % width;
                int y = RN.Next() % height;
                if (m.grid[y][x] == 0)
                    continue;
                m.grid[y][x] = 0;
                rcount++;
            }

            init(widthIN, heightIN);
            deSerialise(m);
            doCheck();
        }
示例#2
0
        public static void solve()
        {
            matrix m = new matrix(width, height, matrixgrid.serialise());

            //check its possible to start with
            var test = m.checkGrid(true, true);
            if (test.Item2 == false)
            {
                MessageBox.Show("There are errors in the puzzle to start with, impossible to solve");
                return;
            }

            bool possible = m.solveHead();

            if (possible == false)
            {
                MessageBox.Show("No solutions found");
                return;
            }
            deSerialise(m);
            var check = m.checkGrid();
            applyCheck(check.Item1);
        }