generate crosswords using crossword algorithm

This commit is contained in:
2025-10-05 20:38:25 +02:00
parent d9cbc85678
commit bd54ce3f37
5 changed files with 102 additions and 7 deletions

View File

@ -1,6 +1,8 @@
import pytest
from multiplayer_crosswords.crossword import Crossword, Orientation, PlacedWord
from unittest.mock import MagicMock
from multiplayer_crosswords.dictionary import Dictionary
from multiplayer_crosswords.utils import load_en_dictionary, load_de_dictionary
class DummyWord:
def __init__(self, word):
@ -96,4 +98,18 @@ def test_valid_hello_world_crossword():
assert str(cw).count('O') == 1
assert str(cw).count('W') == 1
assert str(cw).count('R') == 1
assert str(cw).count('D') == 1
assert str(cw).count('D') == 1
def test_crossword_generation():
dictionary = load_de_dictionary()
crossword = Crossword.generate(15, 15, dictionary)
assert crossword is not None
# Basic checks on the generated crossword
assert len(crossword.grid) == 15
assert all(len(row) == 15 for row in crossword.grid)
assert len(crossword.placed_words) > 0
# print the crossword for visual inspection
print(crossword)