forked from jheidel/scrabble-opencv
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscoring.py
More file actions
85 lines (72 loc) · 2.47 KB
/
Copy pathscoring.py
File metadata and controls
85 lines (72 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
class Blank:
def __init__(self, l):
#The letter that this blank has been assigned
self.letter = l
def __str__(self):
return str(self.letter)
letter_points = {'a': 1,
'b': 3,
'c': 3,
'd': 2,
'e': 1,
'f': 4,
'g': 2,
'h': 4,
'i': 1,
'j': 8,
'k': 5,
'l': 1,
'm': 3,
'n': 1,
'o': 1,
'p': 3,
'q': 10,
'r': 1,
's': 1,
't': 1,
'u': 1,
'v': 4,
'w': 4,
'x': 8,
'y': 4,
'z': 10}
def get_letter_points(c):
if isinstance(c, Blank):
return 0 #Blanks are 0 points
if c not in letter_points:
raise ValueError
return letter_points[c]
letter_mult= [[1,1,1,2,1,1,1,1,1,1,1,2,1,1,1],
[1,1,1,1,1,3,1,1,1,3,1,1,1,1,1],
[1,1,1,1,1,1,2,1,2,1,1,1,1,1,1],
[2,1,1,1,1,1,1,2,1,1,1,1,1,1,2],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[1,3,1,1,1,3,1,1,1,3,1,1,1,3,1],
[1,1,2,1,1,1,2,1,2,1,1,1,2,1,1],
[1,1,1,2,1,1,1,1,1,1,1,2,1,1,1],
[1,1,2,1,1,1,2,1,2,1,1,1,2,1,1],
[1,3,1,1,1,3,1,1,1,3,1,1,1,3,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[2,1,1,1,1,1,1,2,1,1,1,1,1,1,2],
[1,1,1,1,1,1,2,1,2,1,1,1,1,1,1],
[1,1,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