Closed wom-bat closed 2 years ago
Please note, it appears that the fill()
method does not work if there are unchecked lights.
Simplest test case:
from blacksquare import *
xw = Crossword(3)
xw[(1,1)] = BLACK
xw.fill().pprint()
Without the changes yields a grid full of J; with the changes yields a python backtrace.
The latest commit fixes the fill() backtrace. The remaining problem is that sometimes words are repeated in the grid.
Please note, it appears that the fill() method does not work if there are unchecked lights. Simplest test case:
from blacksquare import * xw = Crossword(3) xw[(1,1)] = BLACK xw.fill().pprint()
This case now works, but repeats the word 'Wax'
The latest commit prevents word reuse.
Thanks for the contribution! This gets to a bigger distinction though: the differences between cryptic and non-cryptic crosswords. Because they have different rules and expected structure, I think it would be preferable to have this behavior controlled via either a property of the Crossword class (cryptic=True
) or by subclassing the Crossword class.
It's not just cryptic crosswords. Any crossword can have black squares anywhere. In British parlance, a non-cryptic crossword is a 'quick' crossword --- see, e.g., https://www.theguardian.com/crosswords/quick/16314
Please note --- grids with all lights checked will still work. There's no change in behaviour there.
Any crossword can have black squares anywhere.
This is not true of American crosswords; they require that all words are at least three letters and all cells are checked. In any case, I agree this numbering logic is compatible with those as well. More work may be needed if/when grid validation is implemented.
Thanks for the contribution. Feel free to merge!
The algorithm used to look for black squares to the left or above a possible word. This patch checks that the resulting word is longer than one character.
This fixes bug #12
Signed-off-by: Peter Chubb peter@chubb.wattle.id.au