Пример #1
0
        static void Main(string[] args)
        {
            // var path = (@"C:\Users\ferit.ozcan\Desktop\wordbender\PuzzleGenerator\PuzzleGenerator\PuzzleGenerator\allwords.txt");
            var path = (@"/Users/feritozcan/Desktop/wordbender/PuzzleGeneratorC#/PuzzleGenerator/PuzzleGenerator/allwords.txt");

            //var path = (@"C:\Users\beytullah\Desktop\WordBender\PuzzleGenerator\PuzzleGenerator\PuzzleGenerator\allwords.txt");
            try
            {
                var options = new PuzzleOptions
                {
                    Rows             = 4,
                    Columns          = 4,
                    MaxCharLength    = 12,
                    MinimumWordCount = 150,
                    MinCharLength    = 3,
                    WordFilePath     = path
                };

                PuzzleCreator puzzleCreator = new PuzzleCreator(options);
                var           actions       = new List <Action>();
                var           listt         = new List <int>();
                for (int a = 0; a < 10000; a++)
                {
                    var puzzle = puzzleCreator.CreatePuzzle(options);
                    puzzle.PrintPuzzle();
                    Console.ReadLine();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Ex: " + e.ToString());
            }
        }
Пример #2
0
        static void Create(PuzzleCreator puzzleCreator, int index, PuzzleOptions options)
        {
            int a      = index;
            var puzzle = puzzleCreator.CreatePuzzle(options);


            string jsonString = "someString";

            try
            {
                var          json   = puzzle.ToString();
                var          tmpObj = JsonValue.Parse(json);
                StreamWriter sw     = new StreamWriter(@"/Users/feritozcan/Desktop/wordbender/PuzzleGeneratorC#/PuzzleGenerator/PuzzleGenerator/puzzles/puzzle_" + a + ".txt");
                sw.WriteLine(json);
                sw.Close();
            }
            catch (FormatException fex)
            {
                //Invalid json format
                Console.WriteLine(fex);
            }
            catch (Exception ex) //some other exception
            {
                Console.WriteLine(ex.ToString());
            }
        }
Пример #3
0
 public PuzzleCreator(PuzzleOptions options)
 {
     _dataSet         = new WordDataSet(options);
     _options         = options;
     _rows            = options.Rows;
     _columns         = options.Columns;
     _puzzleValidator = new PuzzleValidator(options, _dataSet);
     _rand            = new Random();
 }
Пример #4
0
        public Puzzle CreatePuzzle(PuzzleOptions options)
        {
            Puzzle puzzle;
            bool   status = false;

            do
            {
                puzzle = new Puzzle
                {
                    Rows       = options.Rows,
                    Columns    = options.Columns,
                    PuzzleGrid = new char[options.Rows, options.Columns],
                    Words      = new List <WordData>()
                };

                status = CreatePuzzleRecursively(puzzle, _options.MaxCharLength + 1);

                var watch = new Stopwatch();
            } while (!status || !_puzzleValidator.ValidatePuzzle(puzzle));
            return(puzzle);
        }
Пример #5
0
        static void Main(string[] _)
        {
            //Helpers.PuzzleDay.GeneratePuzzles.Generate(2021);

            PuzzleOptions.RunOnly(2021, 22);

            var iterations = 1;

            //iterations = 5;

            if (iterations == 1)
            {
                PuzzleOptions.Iterations = 1;
                var sw = Stopwatch.StartNew();
                AllPuzzles();
                Console.WriteLine($"Elapsed: {sw.ElapsedMilliseconds} ms");
            }
            else
            {
                //PuzzleOptions.OnlyRunForInputs = true;
                PuzzleOptions.Silent     = true;
                PuzzleOptions.Iterations = 1;
                AllPuzzles();
                PuzzleOptions.Silent     = false;
                PuzzleOptions.Iterations = iterations;
                var sw = Stopwatch.StartNew();
                AllPuzzles();
                var elapsedMsec = 1000.0 * sw.ElapsedTicks / Stopwatch.Frequency;
                Console.WriteLine($"Elapsed: {elapsedMsec / iterations:F2} ms");
            }

            //if (Debugger.IsAttached)
            //{
            //	Console.Write("Press any key to close ");
            //	Console.ReadKey();
            //}
        }
Пример #6
0
 public PuzzleValidator(PuzzleOptions options, WordDataSet dataSet)
 {
     _options = options;
     _dataSet = dataSet;
 }
Пример #7
0
 public WordDataSet(PuzzleOptions options)
 {
     _options = options;
     InitDataStructures();
     GenerateDataSet();
 }