Beispiel #1
5
 static ICrossBoard GenerateFirstCrossWord(ICrossBoard board, ICrossDictionary dictionary)
 {
     var gen = new CrossGenerator(dictionary, board);
     board.Preprocess(dictionary);
     return gen.Generate().FirstOrDefault();
 }
Beispiel #2
0
        static ICrossBoard GenerateFirstCrossWord(ICrossBoard board, ICrossDictionary dictionary)
        {
            var gen = new CrossGenerator(dictionary, board);

            board.Preprocess(dictionary);
            return(gen.Generate().FirstOrDefault());
        }
Beispiel #3
0
        private static IEnumerable <ICrossBoard> GenerateCrossWords(ICrossBoard board, ICrossDictionary dictionary, string puzzle, CancellationToken cancellationToken)
        {
            if (puzzle != null)
            {
                var placer = new PuzzlePlacer(board, puzzle);
                foreach (var boardWithPuzzle in placer.GetAllPossiblePlacements(dictionary))
                {
                    cancellationToken.ThrowIfCancellationRequested();
                    var gen = new CrossGenerator(dictionary, boardWithPuzzle);

                    // limit
                    int generatedCount = 0;

                    var generated = gen.Generate();
                    foreach (var solution in generated)
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                        generatedCount++;

                        if (generatedCount >= MAX_GENERATOR_COUNT)
                        {
                            break;
                        }

                        yield return(solution);
                    }
                }
            }
            else
            {
                var gen = new CrossGenerator(dictionary, board);
                board.Preprocess(dictionary);

                var crosswords = gen.Generate();

                // limit
                int generatedCount = 0;

                foreach (var resultBoard in crosswords)
                {
                    cancellationToken.ThrowIfCancellationRequested();

                    generatedCount++;

                    if (generatedCount >= MAX_GENERATOR_COUNT)
                    {
                        break;
                    }

                    yield return(resultBoard);
                }
            }
        }