Beispiel #1
0
def get_best_words(b, gutter):
    ret = []
    for i in xrange(0, b.width):
        for j in xrange(0, b.height):
            pos = (i, j)
            if pos not in b.board:
                continue
            words = words_for_pos(b, pos, board.ACROSS, lists.get_wordlist(),
                                  gutter)
            ret.extend(words)
            words = words_for_pos(b, pos, board.DOWN, lists.get_wordlist(),
                                  gutter)
            ret.extend(words)
    return sorted(ret, key=lambda w: scoring.score_word(w))
Beispiel #2
0
            else:
                return None
        def boardWasModified(self, sender):
            self.best_words = None
        def tileWasCleared(self, sender, pos):
            try:
                self.board_state.manually_delete_tile(pos)
            except KeyError:
                pass
            if pos[1] == 15:
                del self.hand[pos[0]]
                print 'deleted hand pos', pos[0]
        def letterWasInput(self, sender, letter, pos):
            self.board_state.manually_put_tile(
                board.BoardTile(pos, letter)
            )
            if pos[1] == 15:
                self.hand[pos[0]] = letter
                print 'set hand position', pos[0], 'to', letter
                print self.getHand()
        def acceptWord(self, sender, word):
            if word:
                self.board_state.put_word(word)
        def getHand(self):
            return ''.join(self.hand[i] for i in self.hand)

    game = board_ui.ScrabbleBoard(
        delegate=BoardDelegate(lists.get_wordlist(), board.BoardState(15, 15))
    )
    game.start()