letterfowl/Platyrhynchos

Create an abstract class for the crossword generators

Closed this issue · 1 comments

jqdq commented
Create an abstract class for the crossword generators
jqdq commented

Okay, so maybe not an abstract class, but perhaps this should be just an entry point to the package? For example:

# direct_search.py
from ..crossword import CrosswordImprovable
from ..cruciverbalists import EnglishSimpleCruciverbalist

cruciverbalist = EnglishSimpleCruciverbalist()

def generate_crossword():
    crossword = CrosswordImprovable.make(cruciverbalist.start_word(), 10, 10)
    
    for _ in range(10):
        to_add = cruciverbalist.choose_and_fill(crossword)
        if to_add[0] is None:
            break
        crossword.add(*to_add)
    return crossword

# __init__.py
if config['runner'] == 'direct_search':
    from .direct_search import generate_crossword

# Using in Pyodide
from platyrhynchos.run import generate_crossword
crossword = generate_crossword()