Skip to content

Commit

Permalink
fix: use correct longest and shortest words when generating asymmetri…
Browse files Browse the repository at this point in the history
…cal board (#550)
  • Loading branch information
jsgalarraga authored Jun 4, 2024
1 parent 0225eae commit 4e2b6ac
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ void main({void Function(String) log = print}) {

final generator = AsymmetricalCrosswordGenerator(
pool: wordPool,
crossword: Crossword(bounds: Bounds.square(size: 78)),
crossword: Crossword(
bounds: Bounds.square(size: 78),
largestWordLength: wordPool.longestWordLength,
shortestWordLength: wordPool.shortestWordLength,
),
);

final crossword = generator.populate();
Expand All @@ -49,7 +53,7 @@ void main({void Function(String) log = print}) {

final notUsedWords = wordsList.where((w) => !wordsString.contains(w.word));

log('Unused words: ${notUsedWords.length}');
log('Unused words: ${notUsedWords.map((w) => w.word).toList()}');

File('board_asymmetrical.txt')
.writeAsStringSync(const ListToCsvConverter().convert(list));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AsymmetricalCrosswordGenerator extends CrosswordGenerator {
invalidLengths: {},
start: Location.zero,
direction: Direction.across,
constraints: {0: 'a'},
constraints: {0: 'e'},
);
final word = pool.firstMatch(constraints)!;
final entry = WordEntry(
Expand Down
4 changes: 2 additions & 2 deletions packages/board_uploader/lib/src/crossword_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CrosswordRepository {

/// Adds a map of word id: answer to the database.
Future<void> addAnswers(List<Answer> answers) async {
const size = 100;
const size = 10;
final maps = answers.slices(size);

await Future.wait(maps.map(_addAnswers));
Expand All @@ -29,7 +29,7 @@ class CrosswordRepository {

/// Adds a list of sections to the database.
Future<void> addSections(List<BoardSection> sections) async {
const size = 50;
const size = 1;
final maps = sections.slices(size);

await Future.wait(maps.map(_addSections));
Expand Down

0 comments on commit 4e2b6ac

Please sign in to comment.