def verify_words(self, board): ''' Check if the gameboard has corret words @param board: the gameboard with the words ''' words = " " #verify if the rows have correct words for i in range(0,board.get_size()): for j in range(0, board.get_size()): word += str(board.get_value_at(i, j)) list_words = words.split() for word in list_words: if not utility.search_word(word, dictionary): return False words = " " #verify if the cols have correct words for j in range(0, board.get_size()): for i in range(0, board.get_size()): words += str(board.get_value_at(i, j)) list_words = words.split() for word in list_word: if not utility.search_word(word, dictionary): return False words = " " return True
def is_valid(self, dictionary): ''' Check whether this move is valid, that is form the word and look if it exists in the dictionary @param dictionary: the dictionary @return: True if the move is valid, otherwise False ''' word = self.word_to_play() if self.is_horizontal() or self.is_vertical(): if utility.search_word(word, dictionary): if self.has_common_tile(len(word), board): if verify_words(board): return True else return False else return True else return False else return False