예제 #1
0
def main():
    welcome = """
    #############################################
    ### WELCOME TO THE SUPER BYTE BOGGLE GAME ###
    #############################################
    
    """
    print(welcome)
    try:
        npt_dice_type = int(input("Would you like to play with the classic or new dice's type? (type '1' for Classic or '2' for New): "))
        if npt_dice_type not in [1, 2]:
            raise Exception()
    except:
        print("Invalid dice type.")
        return
    
    boggle = Boggle()
    boggle.start(npt_dice_type)
    print(boggle)
    
    boggle.user_words = get_user_answers(60*3)
    
    print('Wait, as soon the intern come back with my coffe he might start checking your answers...')
    boggle.get_all_words() #save all possible words based on dictionary on boggle.word_list
    points = 0
    valid_on_board = []
    for word in boggle.user_words:
        if boggle.has_word(word):
            valid_on_board.append(word)
    valid_on_dict = set(valid_on_board).intersection(boggle.word_list)
    for word in valid_on_dict:
        point = boggle.calculate_points(word)
        points += point
        print("{} = {} points".format(word, point))
    
    print("You total score is {} points!".format(points))
    print("Those were all possible words: ")
    print(boggle.word_list)
    print("Better lucky next time :)")
예제 #2
0
print(boggle)
print(word)
assert boggle.has_word(word) == True, "Should be True as the 'word' is the first 3 letters from 1st row"

word = ''
word += str(boggle.get_item(1,1))
word += str(boggle.get_item(2,2))
word += str(boggle.get_item(3,3))
print(boggle)
print(word)
assert boggle.has_word(word) == True, "Should be True as the 'word' is a sequence of diagonal letter in the board"

word = ''
word += str(boggle.get_item(3,2))
word += str(boggle.get_item(2,2))
word += str(boggle.get_item(2,3))
word += str(boggle.get_item(2,3))
word += str(boggle.get_item(1,3))
print(boggle)
print(word)
assert boggle.has_word(word) == True, "Should be True as the 'word' is a sequence in the board"

assert boggle.calculate_points('our') == 1, "3 and 4 letters words are worth 1 point"
assert boggle.calculate_points('bike') == 1, "3 and 4 letters words are worth 1 point"
assert boggle.calculate_points('kaisa') == 2, "5 letters words are worth 2 points"
assert boggle.calculate_points('victor') == 3, "6 letters words are worth 3 points"
assert boggle.calculate_points('hackers') == 5, "7+ letters words are worth 5 points"
assert boggle.calculate_points('supercalifragilisticexpialidocious ') == 5, "7+ letters words are worth 5 points"