Exemple #1
0
def test_muncher__resolves_invalid_bias():
    res2 = munch('doo', fraction=0.5, vowel_bias=0)
    assert count_chars(res2, '_') == 2
    assert res2[0] == '_'

    res2 = munch('you', fraction=0.5, vowel_bias=0)
    assert count_chars(res2, '_') == 2
Exemple #2
0
def test_muncher__honors_vowel_fraction():
    res1 = munch('abc', fraction=0, vowel_bias=1)
    assert count_chars(res1, '_') == 1
    assert res1[0] == '_'

    res2 = munch('abc', fraction=0, vowel_bias=0)
    assert count_chars(res2, '_') == 1
    assert res2[0] == 'a'

    res2 = munch('doo', fraction=0, vowel_bias=0)
    assert count_chars(res2, '_') == 1
    assert res2[0] == '_'

    res2 = munch('doo', fraction=0, vowel_bias=1)
    assert count_chars(res2, '_') == 1
    assert res2[0] == 'd'

    res2 = munch('doo', fraction=0.5, vowel_bias=1)
    assert count_chars(res2, '_') == 2
    assert res2[0] == 'd'
Exemple #3
0
print(figlet_slant.renderText('Welcome to'))
print(colored(figlet_standard.renderText('SPELL TO ME!'), 'green'))
print()
print('THE GAME WITH WORDS AND SPELLING BUT NO BEES...')
print('-----------------------------------------------')
play(f'welcome.wav')
input('Press enter to continue...')
print()

for i, word in enumerate(word_list):
    for guess_num in range(3):
        if guess_num == 0:
            play('spelltome.wav')
        else:
            play('tryagain.wav')
        play(f'words/{word}.wav', wait=False)
        munched_word = munch(word, fraction=0.2, vowel_bias=0.8)
        print(f'Word #{i+1}: {munched_word}')
        guess = input('Spell this word: ')
        if guess == word:
            score = score + len(word) - guess_num
            print(colored(figlet_standard.renderText('Good Job!'), 'green'))
            print(colored(f'{score=}\n', 'blue'))
            play(f'good.wav')
            break
        else:
            print(colored('\tNot quite, please try again... :(', 'red'))
            play(f'bad.wav')

play(f'end.wav')
Exemple #4
0
def test_muncher__returns_list():
    assert isinstance(munch('a'), list)
Exemple #5
0
def test_muncher__honors_fraction():
    assert count_chars(munch('abc', fraction=0), '_') == 1
    assert count_chars(munch('abc', fraction=0.49), '_') == 1
    assert count_chars(munch('abc', fraction=0.50), '_') == 2
    assert count_chars(munch('abc', fraction=0.99), '_') == 2
    assert count_chars(munch('abc', fraction=1), '_') == 3
Exemple #6
0
def test_muncher__always_munches_at_least_one_letter():
    assert count_chars(munch('a'), '_') > 0
    assert count_chars(munch('abc', fraction=0), '_') > 0
    assert count_chars(munch('abc', fraction=0.1), '_') > 0
    assert count_chars(munch('abc', fraction=-1), '_') > 0
    assert count_chars(munch('abc', fraction=10), '_') > 0