From f531aa1f83bd286c0519878bf77dcf0c48c21035 Mon Sep 17 00:00:00 2001 From: AyadLaouissi Date: Fri, 14 Jun 2024 17:50:07 +0200 Subject: [PATCH 1/2] chore: remove duplicated closed from crossword generator --- .../lib/src/generators/asymmetrical_crossword_generator.dart | 1 - .../lib/src/generators/symmetrical_crossword_generator.dart | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/board_generator_playground/lib/src/generators/asymmetrical_crossword_generator.dart b/packages/board_generator_playground/lib/src/generators/asymmetrical_crossword_generator.dart index 377003819..fb6b964e8 100644 --- a/packages/board_generator_playground/lib/src/generators/asymmetrical_crossword_generator.dart +++ b/packages/board_generator_playground/lib/src/generators/asymmetrical_crossword_generator.dart @@ -96,7 +96,6 @@ class AsymmetricalCrosswordGenerator extends CrosswordGenerator { .add(WordCandidate(start: location, direction: Direction.down)); } } - candidates.removeWhere(closed.contains); return candidates; } diff --git a/packages/board_generator_playground/lib/src/generators/symmetrical_crossword_generator.dart b/packages/board_generator_playground/lib/src/generators/symmetrical_crossword_generator.dart index e2633327e..ab6179469 100644 --- a/packages/board_generator_playground/lib/src/generators/symmetrical_crossword_generator.dart +++ b/packages/board_generator_playground/lib/src/generators/symmetrical_crossword_generator.dart @@ -203,7 +203,6 @@ class SymmetricalCrosswordGenerator extends CrosswordGenerator { .add(WordCandidate(start: location, direction: Direction.down)); } } - candidates.removeWhere(closed.contains); return candidates; } From 3041329ee49eb5250a1641dedd64af4c4cda1b65 Mon Sep 17 00:00:00 2001 From: AyadLaouissi Date: Mon, 17 Jun 2024 12:01:49 +0200 Subject: [PATCH 2/2] chore: add required shortest and longest word in crossword --- .../lib/src/crossword.dart | 4 +- .../test/src/crossword_test.dart | 15 ++++-- .../test/src/fixtures/crosswords.dart | 48 +++++++++++++++---- 3 files changed, 52 insertions(+), 15 deletions(-) diff --git a/packages/board_generator_playground/lib/src/crossword.dart b/packages/board_generator_playground/lib/src/crossword.dart index bbaae44ed..9085f61e5 100644 --- a/packages/board_generator_playground/lib/src/crossword.dart +++ b/packages/board_generator_playground/lib/src/crossword.dart @@ -11,9 +11,9 @@ typedef CharacterMap = Map; class Crossword { /// {@macro crossword} Crossword({ + required this.largestWordLength, + required this.shortestWordLength, this.bounds, - this.largestWordLength = 18, - this.shortestWordLength = 3, }); /// {@macro character_map} diff --git a/packages/board_generator_playground/test/src/crossword_test.dart b/packages/board_generator_playground/test/src/crossword_test.dart index d5e8a335b..e013288be 100644 --- a/packages/board_generator_playground/test/src/crossword_test.dart +++ b/packages/board_generator_playground/test/src/crossword_test.dart @@ -11,7 +11,10 @@ void main() { group('$Crossword', () { group('add', () { test('adds a down word to the character map', () { - final board = Crossword(); + final board = Crossword( + largestWordLength: 18, + shortestWordLength: 3, + ); final url = WordEntry( word: 'url', @@ -40,7 +43,10 @@ void main() { }); test('adds an across word to the character map', () { - final board = Crossword(); + final board = Crossword( + largestWordLength: 18, + shortestWordLength: 3, + ); final url = WordEntry( word: 'url', @@ -80,7 +86,10 @@ void main() { direction: Direction.across, ); - final board = Crossword() + final board = Crossword( + largestWordLength: 18, + shortestWordLength: 3, + ) ..add(behan) ..add(albus); diff --git a/packages/board_generator_playground/test/src/fixtures/crosswords.dart b/packages/board_generator_playground/test/src/fixtures/crosswords.dart index 466983f7c..e8a9f1769 100644 --- a/packages/board_generator_playground/test/src/fixtures/crosswords.dart +++ b/packages/board_generator_playground/test/src/fixtures/crosswords.dart @@ -16,8 +16,9 @@ import 'package:board_generator_playground/src/models/models.dart'; class Crossword1 extends Crossword { /// {@macro crossword1} Crossword1({ + super.largestWordLength = 18, + super.shortestWordLength = 3, super.bounds, - super.largestWordLength, }) { add( WordEntry( @@ -50,7 +51,10 @@ class Crossword1 extends Crossword { /// {@endtemplate} class Crossword2 extends Crossword { /// {@macro crossword2} - Crossword2() { + Crossword2({ + super.largestWordLength = 18, + super.shortestWordLength = 3, + }) { add( WordEntry( word: 'behan', @@ -89,7 +93,10 @@ class Crossword2 extends Crossword { /// {@endtemplate} class Crossword3 extends Crossword { /// {@macro crossword3} - Crossword3() { + Crossword3({ + super.largestWordLength = 18, + super.shortestWordLength = 3, + }) { add( WordEntry( word: 'behan', @@ -135,7 +142,10 @@ class Crossword3 extends Crossword { /// {@endtemplate} class Crossword4 extends Crossword { /// {@macro crossword4} - Crossword4() { + Crossword4({ + super.largestWordLength = 18, + super.shortestWordLength = 3, + }) { add( WordEntry( word: 'behan', @@ -175,7 +185,10 @@ class Crossword4 extends Crossword { /// {@endtemplate} class Crossword5 extends Crossword { /// {@macro crossword5} - Crossword5() { + Crossword5({ + super.largestWordLength = 18, + super.shortestWordLength = 3, + }) { add( WordEntry( word: 'behan', @@ -234,7 +247,10 @@ class Crossword5 extends Crossword { /// {@endtemplate} class Crossword6 extends Crossword { /// {@macro crossword6} - Crossword6() { + Crossword6({ + super.largestWordLength = 18, + super.shortestWordLength = 3, + }) { add( WordEntry( word: 'orchardbankcom', @@ -322,7 +338,10 @@ class Crossword6 extends Crossword { /// {@endtemplate} class Crossword7 extends Crossword { /// {@macro crossword7} - Crossword7() { + Crossword7({ + super.largestWordLength = 18, + super.shortestWordLength = 3, + }) { add( WordEntry( word: 'libexec', @@ -401,7 +420,10 @@ class Crossword7 extends Crossword { /// {@endtemplate} class Crossword8 extends Crossword { /// {@macro crossword8} - Crossword8() { + Crossword8({ + super.largestWordLength = 18, + super.shortestWordLength = 3, + }) { add( WordEntry( word: 'superman', @@ -446,7 +468,10 @@ class Crossword8 extends Crossword { /// {@endtemplate} class Crossword9 extends Crossword { /// {@macro crossword9} - Crossword9() { + Crossword9({ + super.largestWordLength = 18, + super.shortestWordLength = 3, + }) { add( WordEntry( word: 'interchangeability', @@ -499,7 +524,10 @@ class Crossword9 extends Crossword { /// {@endtemplate} class Crossword10 extends Crossword { /// {@macro crossword8} - Crossword10() { + Crossword10({ + super.largestWordLength = 18, + super.shortestWordLength = 3, + }) { add( WordEntry( word: 'sos',