If random.uniform(0, 1) (self.x+self.y)/random.choice(xrange(2,5)):
#Choose whether to stop here or continue for a longer word If location_y = len(matching_word_list)-1: Ignore_limit = kwargs.get('ignore', False) > WordSearch(5, 10).get_coordinate(57, ignore=True) Set to True and it can return a coordinate that doesn't exist in the grid. If the maximum Y value should be ignored when checking if the number is in range. Only needs the X grid value to calculate, the Y value checks it is within range. Print ' '.join(str(i+count).zfill(max_len) for i in range(self.x))ĭef get_coordinate(self, id=0, **kwargs): While len(word_list) > WordSearch(4, 4).debug_grid() If all(new_coordinate in (old_coordinate+j for j in xrange(-1, 2)) for i in xrange(2)) and 0 > ed(1234)
New_coordinate = self.get_coordinate(new_location) New_location = inital_location+direction_move Old_coordinate = self.get_coordinate(inital_location) > WordSearch(5, 10).direction_coordinate(47, 6)ĭirections = -directions > WordSearch(5, 10).direction_coordinate(57, 6) Returns None if out of range, otherwise return the new coordinate ID. """Calculate the new coordinate ID based on a direction.įor visual feedback of this in action, use WordSearch().debug_grid(). """Generate rules for the difficulty level.ĭef direction_coordinate(self, inital_location, direction): Self.difficulty_level = kwargs.get('difficulty', 5) See WordSearch().get_difficulty() for what each level contains. Ws.generate(iterations, words=input_words) Input_words = ws.format_input_list(filename=f) """Generate a word search using any input strings. The last thing I did apparently had too many comments so I tried to keep them to only the basic ones this time round.
WORD SEARCH PUZZLE MAKER WITH DIACRITICS PLUS
Words: ados, amps, amyl, cabs, chink, comet, dens, else, embodier, fens, foot, idyl, image, kike, kung, lilts, lips, maker, mewing, mixt, moat, mony, myopia, pals, raga, reborn, ruin, sated, sure, toys, trash, tsked, unasked, unsold, wife, yale, yawn, yeggįeedback on the style of writing and documentation would be useful since I'm still trying to improve, plus if you notice anything I've done really badly let me know. Words: awful, berg, diag, fink, gyve, inky, insulter, medal, ozone, psycheġ4x14 output with 200 iterations (also in debug mode): Same as above but with difficulty 1 instead of 5: Words: bulkily, cloves, dust, enrobe, lawn, lumps, pines, reteach, stickles, stymy Words: celt, mohair, rationals, ruers, uncombinedġ4x14 output with 20 iterations (in debug mode to remove extra letters):
Instead of storing the values in a 2d grid, I stored them in a list, and used a separate function to calculate the next index when given an index and direction, and it checks that it's still on the grid and not gone off the side.Įxamples (with using a list with all the english words): 14x14 output with 10 iterations: testing could also generate tesing, temtin, test, stin etc). It'll also generate similar words based on the words added to the search, to throw the user off a little (eg. I'm not sure how proper ones run, but my one kind of works through the brute force method, where it'll place a letter in one spot (the first letter of a random word), and branch out in all directions while narrowing down the list of matching words until it finds a match (although if there's remaining words, there's a chance it'll continue as to not end up with all the shortest words).Įach attempt is an iteration, so obviously the more iterations, the more chance the grid will be filled with words.
Last night I thought a word search would be fairly interesting to try.