Exemplo n.º 1
0
def solve_from_letters(letters):
    from wordsmush import game_utils
    from wordsmush.ai import WordsmushAIPlayer

    ai = WordsmushAIPlayer()
    board = game_utils.get_board(letters)
    words = ai.solve_board(board)
    words_by_len = groupby(words, key=len)
    for length, words in words_by_len:
        if length > 2:
            print "%d letter words: " % length
            print (", ".join(words)).upper()
Exemplo n.º 2
0
class TestAI(unittest.TestCase):

    def setUp(self):
        self.ai = WordsmushAIPlayer() 
    
    def test_solve_board(self):
        game = game_utils.get_board(
            'espro'
            'lishm'
            'tabdi'
            'entsi'
            'xfgmn')

        solved_game = self.ai.solve_board(game)
        words = ['establish', 'sadism', 'establishment', 'disestablishment',
                 'stab', 'stand', 'spasm', 'stream', 'espresso']

        for word in words:
            self.assertTrue(word in solved_game) 
Exemplo n.º 3
0
 def setUp(self):
     self.ai = WordsmushAIPlayer()