static ICrossBoard GenerateFirstCrossWord(ICrossBoard board, ICrossDictionary dictionary) { var gen = new CrossGenerator(dictionary, board); board.Preprocess(dictionary); return gen.Generate().FirstOrDefault(); }
static ICrossBoard GenerateFirstCrossWord(ICrossBoard board, ICrossDictionary dictionary) { var gen = new CrossGenerator(dictionary, board); board.Preprocess(dictionary); return(gen.Generate().FirstOrDefault()); }
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); } } }