Created
June 19, 2020 16:13
-
-
Save InBrewJ/b40dcc4e1af2eb9c6ea4a5a4f4bb37bd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from random import choices | |
name='Scrabble' | |
def split(word): | |
return [char for char in word] | |
score_map = { | |
"E": 1, | |
"A": 1, | |
"I": 1, | |
"O": 1, | |
"N": 1, | |
"R": 1, | |
"T": 1, | |
"L": 1, | |
"S": 1, | |
"U": 1, | |
"D": 2, | |
"G": 2, | |
"B, C, M, P": 3, | |
"F, H, V, W, Y": 4, | |
"K": 5, | |
"J, X": 8, | |
"Q, Z": 10 | |
} | |
TOTAL_WEIGHT_DENOM = 45 | |
initial_bag_state = [ | |
{ 12: ["E"] }, | |
{ 9: ["A,I"] }, | |
{ 8: ["O"] }, | |
{ 6: ["N,R,T"] }, | |
{ 4: ["L,S,U,D"] }, | |
{ 3: ["G"] }, | |
{ 2: ["B,C,M,P,F,H,V,W,Y"] }, | |
{ 1: ["K,J,X,Q,Z"] } | |
] | |
distribution = [12, 9, 8, 6, 4, 3, 2, 1] | |
def construct_bag(): | |
for distribution in initial_bag_state: | |
pass | |
def get_random_capital_letter(): | |
# return chr(random.randint(0,25)) | |
rand_int = random.randint(65,90) | |
return chr(rand_int) | |
def get_score(word): | |
word_list = split(word) | |
total_score = 0 | |
for char in word_list: | |
try: | |
score = score_map[char] | |
total_score += score | |
except: | |
return total_score | |
return total_score | |
def get_bag_of_letters(num_letters): | |
bag = [] | |
for i in range(num_letters): | |
bag.append(get_random_capital_letter()) | |
return bag | |
# get_score('GUARDIAN') | |
print(get_bag_of_letters(7)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment