Jonah Scheinerman

C++ Streams | Nigel | Artwork | Résumé | Contact

Nigel

Nigel is an artificial intelligence program designed to play Hasbro's Scrabble® crossword puzzle game. It can be readily adapted to work with any number of other crossword games, such as Zynga's Words with Friends™. Nigel is a program that can help both amateur and experienced players improve their game. Nigel is built and maintained by Jonah and Daniel Scheinerman.

The Nigel repository can be found on Bitbucket. Nigel requires C++11.

History

Nigel started in the woods of Berkeley Springs, WV in December 2010. Danny and I started the project just for fun, to see if they could create a program that plays Scrabble. Both were quite familiar with the Scrabble game but were not knowledgable about the competitive Scrabble scene. The name Nigel was chosen early on and we only found out later about the Scrabble player Nigel Richards.

The original version of Nigel was a Python program that found all possible moves for a given board and rack. Then it would pick the highest scoring move and play that. The Python program was quite rudimentary and would take a minute to make a move if the rack had no blanks, six minutes if it had one blank and thirteen minutes if it had two blanks! Overall, it would take about 25 minutes to play a game (against itself). This was much slower than we wanted so we started to improve it. The next version of Nigel was in Java and used a similar move finding algorithm (though not the one we currently use), but featured a multithreading approach which split the work among a number of threads to speed up execution time. This version was much more platform dependent, but on a 4 processor computer would take about 4 minutes to play a game. The final and current version of Nigel was rewritten in C++ and features a new DAWG based algorithm (different from the one detailed in the 1988 Appel and Jacobson paper). This version can play an entire game of Scrabble in just 1.3 seconds.

Around when we started work on the Java version, we began working on more advanced strategies (rather than just playing the highest scoring word). In order to collect data on how well certain sets of letters play, we used Nigel to simulate over 800,000 games of Scrabble (this was expediated by the development of the much faster C++ version of Nigel).

Currently, Nigel exists only as a C++ library, but we hope to expand Nigel into a command line tool followed by a graphical user interface in some form or other (we're looking into making a web interface via Google NaCl).

Developing with Nigel

Simulating games with Nigel is rather easy. For example, the following plays a standard game of Scrabble and saves the result to a GCG file:

#include "nigel/Game.h"

int main() {
    nigel::Game game;
    game.AddPlayer("P1");
    game.AddPlayer("P2");
    game.QuickPlay();
    game.SaveAsGCG("path/to/result.gcg");
}

Its just as easy to create a game with a different board, lexicon, or tileset:

using namespace nigel;

Game scrabble_game(Game::Config::SCRABBLE);
Game wwf_game(Game::Config::WWF);
Game non_us_scrabble(Board::Config::SCRABBLE,
                     Alphabet::Config::ENGLISH,
                     Lexicon::Config::SOWPODS);
        

Nigel comes with the following resources builtin:

Boards: Alphabets: Lexicons:
Scrabble English TWL 98/06 (a.k.a. OCTWL/OCTWL2)
Super Scrabble English - Super Scrabble SOWPODS / CSW12
Words With Friends English - WWF Enable (WWF)
French OSPD4/5 (French)
Italian Zingarelli (Italian)
OSPD4
OSWI

In addition, new boards, alphabets and lexicons can be included in Nigel if you are looking for something that we don't have. For details on this, see the pdf on file formats in the documents folder of the repository.

By default, you may notice that the computer players will play weakly, this is because they are using the rather simple metric of always choosing the highest scoring move. A number of advanced players can be found in the Nigel.h header file. These correspond to the various version of Nigel. These are: Nigel 1 (default), Nigel 2.1, Nigel 2.2, Nigel 2.Q, Nigel 3.1, and Nigel 3.2. Among these, Nigel 2.2 is currently thought to be the best, with Nigel 3.*'s being experimental strategies. To make use of these strategy engines do the following:

#include "nigel/Game.h"
#include "nigel/Player.h"
#include "nigel/Nigel.h"

int main() {
    nigel::Game game;
    game.AddPlayer("P1")->set_strategy< nigel::Nigel2_2 >();
    game.AddPlayer("P2")->set_strategy< nigel::Nigel2_Q >();
    game.QuickPlay();
    game.SaveAsGCG("path/to/result.gcg");
}