allow_backwards_words = False # If using a mask, specify it by a key to the apply_mask dictionary. format ( max ( nrows, ncols ))) # This flag determines whether words can be fitted backwards into the grid # (which makes the puzzle a bit harder). NMAX = 32 alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' def circle_mask ( grid ): """A circular mask to shape the grid.""" r2 = min ( ncols, nrows ) ** 2 // 4 cx, cy = ncols // 2, nrows // 2 for irow in range ( nrows ): for icol in range ( ncols ): if ( irow - cy ) ** 2 + ( icol - cx ) ** 2 > r2 : grid = '*' def squares_mask ( grid ): """A mask of overlapping squares to shape the grid.""" a = int ( 0.38 * min ( ncols, nrows )) cy = nrows // 2 cx = ncols // 2 for irow in range ( nrows ): for icol in range ( ncols ): if a cy + a : grid = '*' if a cx + a : grid = '*' def no_mask ( grid ): """The default, no mask.""" pass # A dictionary of masking functions, keyed by their name. # make_wordsearch.py import os import sys import random from copy import deepcopy # Maximum number of rows and columns.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |