Ejemplo n.º 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 :)")
Ejemplo n.º 2
0
board.clear()
assert len(board.board) == 0, "Board should be empty after calling clean()."

board.start()
assert type(board.get_item(1,2)) == Dice, "Should return the the 3rd item from the second row, an Dice object"

assert len(board.get_surrounds(3,3)) == 3, "Should return a list with 3 Dices, the surrounds of the dice on 4th row and 4th column."
assert len(board.get_surrounds(1,1)) == 8, "Should return a list with 8 Dices, the surrounds of the dice on 2nd row and 2nd column."
assert len(board.get_surrounds(0,2)) == 5, "Should return a list with 5 Dices, the surrounds of the dice on 1st row and 3rd column."


### Boggle tests ###
from boggle import Boggle

boggle = Boggle()
boggle.start()
assert type(boggle) == Boggle, "Should be an instance of boggle"

word = ''
word += str(boggle.get_item(0,0))
word += str(boggle.get_item(0,1))
word += str(boggle.get_item(0,2))
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)