Saturday, January 7, 2012

Scrabby, the Awesome Scrabble Player

This morning my brother sent me a text:
him: "Do you have the scrabble app on your iphone?"
me: "No. Installing it now."

Soon we were playing a game of Scrabble against each other. After a few turns, he sent another text:
him: "After u play click on that teacher tile to see how bad u are."
me: "Teacher says I played the best word."
him: "Yea u get lucky now and then."
The teacher tile reveals the best word that was possible from your previous rack of tiles.

What my brother didn't know is that I fired up my old Scrabble solver program, affectionately called "Scrabby." I wrote Scrabby about two years ago after my wife started playing Scrabble on the Internet. After I played a couple of games against her, I quickly realized that it would be more fun to write a Scrabble program than to actually play Scrabble. Given a Scrabble game board and a rack of tiles, Scrabby reveals the best possible word to play. So, "teacher" and Scrabby should always be in agreement. That means I'll get "lucky" more than "now and then."

A few turns later, I placed two tiles worth over 20 points. "I can see you have played this game before," said the next text. *Grin.* Once the end of the game is near, Scrabby can also tell me what tiles are on my opponent's rack. Imagine his surprise when I started telling him what his best word was.

It's not cheating if I wrote the solver, right?

Scrabby is a console program written in Python with a command-line interface. Perhaps I'll give it a prettier interface some day. Here is a sample of Scrabby in action. If you're reading this from a mobile device, the pre-formatted text below may not display properly.
>>>> rack uaarrct
Searching... (\) 5% complete.
5 1 N v RIATA
5 1 N v TIARA
8 1 N h AA
8 1 N h AR
8 1 N h AT
8 1 N h TA
Searching... (-) 7% complete.
10 2 C h CURARI
Searching... (|) 8% complete.
14 2 F h CRIT
Searching... (|) 17% complete.
14 1 K v ENACT
Searching... (-) 18% complete.
16 2 M v DATURA
16 2 M v DUCAT
Searching... (/) 33% complete.
21 6 B v CURARA
Searching... (\) 99% complete.
A B C D E F G H I J K L M N O | 21 : 6 B v CURARA
################################# | 16 : 2 M v DATURA
1 # * . . # . . . L U R E X . . * # 1 | 16 : 2 M v DUCAT
2 # . $ . . . % . I . % N I D I . # 2 | 16 : 6 F h FARO
3 # . . $ . . . # T # . . . $ . . # 3 | 16 : 1 H v LITHER
4 # # . . $ . P . H . . . $ . . # # 4 | 14 : 2 F h CRIT
5 # . . . . J U B E S . $ . . . . # 5 | 14 : 1 K v ENACT
6 # . % . . . F A . O % . . . % . # 6 | 14 : 2 M v DUCT
7 # . . # . . F A . Y . . . # . . # 7 | 14 : 6 J v RAT
8 # * . . G A S E S . . . # . . * # 8 | 14 : 7 B v CRURA
9 # . . # L . . D . # . . . # . . # 9 | 13 : 7 J v ACTA
10# . % . O . W . . . % . . . % . #10 | 13 : 8 B v ACTA
11# . . T O N E . . . . $ . . . . #11 | 12 : 2 M v DURRA
12# # . A M I N . # . . . $ . . # #12 | 12 : 7 J v AURAR
13# . . V . E D # . # . . . $ . . #13 | 12 : 14 A h AA
14# . $ . . c % . . . % . . . $ . #14 | 12 : 14 A h TA
15# A G G I E . . * . . . # . . * #15 | 11 : 6 I h OCA
################################# | 11 : 7 J v AURA
A B C D E F G H I J K L M N O | 11 : 8 B v AURA
>>>> word 6 B v CURARA

A B C D E F G H I J K L M N O | 21 : 6 B v CURARA
################################# | 16 : 2 M v DATURA
1 # * . . # . . . L U R E X . . * # 1 | 16 : 2 M v DUCAT
2 # . $ . . . % . I . % N I D I . # 2 | 16 : 6 F h FARO
3 # . . $ . . . # T # . . . $ . . # 3 | 16 : 1 H v LITHER
4 # # . . $ . P . H . . . $ . . # # 4 | 14 : 2 F h CRIT
5 # . . . . J U B E S . $ . . . . # 5 | 14 : 1 K v ENACT
6 # . C . . . F A . O % . . . % . # 6 | 14 : 2 M v DUCT
7 # . U # . . F A . Y . . . # . . # 7 | 14 : 6 J v RAT
8 # * R . G A S E S . . . # . . * # 8 | 14 : 7 B v CRURA
9 # . A # L . . D . # . . . # . . # 9 | 13 : 7 J v ACTA
10# . R . O . W . . . % . . . % . #10 | 13 : 8 B v ACTA
11# . A T O N E . . . . $ . . . . #11 | 12 : 2 M v DURRA
12# # . A M I N . # . . . $ . . # #12 | 12 : 7 J v AURAR
13# . . V . E D # . # . . . $ . . #13 | 12 : 14 A h AA
14# . $ . . c % . . . % . . . $ . #14 | 12 : 14 A h TA
15# A G G I E . . * . . . # . . * #15 | 11 : 6 I h OCA
################################# | 11 : 7 J v AURA
A B C D E F G H I J K L M N O | 11 : 8 B v AURA
>>>> word 2 m v DEHORN

A B C D E F G H I J K L M N O | 21 : 6 B v CURARA
################################# | 16 : 2 M v DATURA
1 # * . . # . . . L U R E X . . * # 1 | 16 : 2 M v DUCAT
2 # . $ . . . % . I . % N I D I . # 2 | 16 : 6 F h FARO
3 # . . $ . . . # T # . . . E . . # 3 | 16 : 1 H v LITHER
4 # # . . $ . P . H . . . $ H . # # 4 | 14 : 2 F h CRIT
5 # . . . . J U B E S . $ . O . . # 5 | 14 : 1 K v ENACT
6 # . C . . . F A . O % . . R % . # 6 | 14 : 2 M v DUCT
7 # . U # . . F A . Y . . . N . . # 7 | 14 : 6 J v RAT
8 # * R . G A S E S . . . # . . * # 8 | 14 : 7 B v CRURA
9 # . A # L . . D . # . . . # . . # 9 | 13 : 7 J v ACTA
10# . R . O . W . . . % . . . % . #10 | 13 : 8 B v ACTA
11# . A T O N E . . . . $ . . . . #11 | 12 : 2 M v DURRA
12# # . A M I N . # . . . $ . . # #12 | 12 : 7 J v AURAR
13# . . V . E D # . # . . . $ . . #13 | 12 : 14 A h AA
14# . $ . . c % . . . % . . . $ . #14 | 12 : 14 A h TA
15# A G G I E . . * . . . # . . * #15 | 11 : 6 I h OCA
################################# | 11 : 7 J v AURA
A B C D E F G H I J K L M N O | 11 : 8 B v AURA
>>>> rack tkpmnde
Searching... (\) 5% complete.
20 1 N v KITED
20 1 N v TIMED
Searching... (|) 8% complete.
20 2 F h KNIT
Searching... (/) 24% complete.
24 4 L h KHET
24 4 L h THEM
Searching... (\) 37% complete.
27 6 J v PENT
28 6 J v PEND
28 6 J v MEND
Searching... (\) 99% complete.
A B C D E F G H I J K L M N O | 28 : 6 J v PEND
################################# | 28 : 6 J v MEND
1 # * . . # . . . L U R E X . . * # 1 | 27 : 6 J v PENT
2 # . $ . . . % . I . % N I D I . # 2 | 27 : 6 J v MED
3 # . . $ . . . # T # . . . E . . # 3 | 27 : 6 J v PED
4 # # . . $ . P . H . . . $ H . # # 4 | 27 : 7 A v MEN
5 # . . . . J U B E S . $ . O . . # 5 | 27 : 7 A v MET
6 # . C . . . F A . O % . . R % . # 6 | 26 : 6 J v PET
7 # . U # . . F A . Y . . . N . . # 7 | 26 : 6 J v MEN
8 # * R . G A S E S . . . # . . * # 8 | 26 : 6 J v MET
9 # . A # L . . D . # . . . # . . # 9 | 26 : 6 J v PEN
10# . R . O . W . . . % . . . % . #10 | 25 : 6 J v ME
11# . A T O N E . . . . $ . . . . #11 | 25 : 6 J v PE
12# # . A M I N . # . . . $ . . # #12 | 24 : 4 L h KHET
13# . . V . E D # . # . . . $ . . #13 | 24 : 4 L h THEM
14# . $ . . c % . . . % . . . $ . #14 | 22 : 4 L v EM
15# A G G I E . . * . . . # . . * #15 | 22 : 7 A v ME
################################# | 22 : 8 A v EM
A B C D E F G H I J K L M N O | 21 : 6 J v DENT
>>>> word 6 J v PEND

A B C D E F G H I J K L M N O | 28 : 6 J v PEND
################################# | 28 : 6 J v MEND
1 # * . . # . . . L U R E X . . * # 1 | 27 : 6 J v PENT
2 # . $ . . . % . I . % N I D I . # 2 | 27 : 6 J v MED
3 # . . $ . . . # T # . . . E . . # 3 | 27 : 6 J v PED
4 # # . . $ . P . H . . . $ H . # # 4 | 27 : 7 A v MEN
5 # . . . . J U B E S . $ . O . . # 5 | 27 : 7 A v MET
6 # . C . . . F A . O P . . R % . # 6 | 26 : 6 J v PET
7 # . U # . . F A . Y E . . N . . # 7 | 26 : 6 J v MEN
8 # * R . G A S E S . N . # . . * # 8 | 26 : 6 J v MET
9 # . A # L . . D . # D . . # . . # 9 | 26 : 6 J v PEN
10# . R . O . W . . . % . . . % . #10 | 25 : 6 J v ME
11# . A T O N E . . . . $ . . . . #11 | 25 : 6 J v PE
12# # . A M I N . # . . . $ . . # #12 | 24 : 4 L h KHET
13# . . V . E D # . # . . . $ . . #13 | 24 : 4 L h THEM
14# . $ . . c % . . . % . . . $ . #14 | 22 : 4 L v EM
15# A G G I E . . * . . . # . . * #15 | 22 : 7 A v ME
################################# | 22 : 8 A v EM
A B C D E F G H I J K L M N O | 21 : 6 J v DENT
>>>>

No comments:

Post a Comment