Exemplo n.º 1
0
         else :
             print 'Invalid number'
             continue
     except ValueError:
         print 'Invalid number'
         continue
     
     cInput = raw_input("Add Letters\t:")
     try:
         letters = str(cInput)
         if letters.isalpha() : 
             board.addLettersWithValue(value, letters.lower())
         else:
             print 'Invalid characters'
             continue
     except ValueError:
         print 'Invalid character'
         continue   
             
 # solve
 print
 print board.getAsTable()
 
 solutions = scorer.sort(solver.solve(board.getCharacters()), board)
 currentWord = solutions[0] if len(solutions) > 0 else ''
 
 board.deleteLowestLetters(currentWord)
 board.decrement()
 
 print '\n' + currentWord + ' (' + str(len(solutions)) + ')\n' if len(currentWord) > 0 else "!!No Word found!! -> \n"
 print board.getAsTable()
Exemplo n.º 2
0
vocabulary = fillVocabulary()
solver = VocabularySolver(vocabulary)
scorer = Scorer()

# create board
board = Tokens()

random.seed(666)
charList = generateCharacterOccurance()
currentWord = '12345'
for k in range(1000):
    
    if len(currentWord) < 1:
        currentWord = '1'
    newChars = ''
    while not len(newChars) > 0 or not len(newChars) < 15 or not isPossible(board.getCharacters() + newChars, solver): 
        newChars = ''
        for i in range(len(currentWord)):
            for k in range(random.randrange(3)):
                newChars += charList[random.randrange(len(charList))]
               
    board.addLettersWithValue(5, newChars)
    # solve
    print board.getAsTable()
    
    solutions = scorer.sort(solver.solve(board.getCharacters()), board)
    currentWord = solutions[0] if len(solutions) > 0 else ''
    
    board.deleteLowestLetters(currentWord)
    board.decrement()