Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hickford/word-game-solver

Solves combinatorial word games
https://github.com/hickford/word-game-solver

Last synced: about 21 hours ago
JSON representation

Solves combinatorial word games

Awesome Lists containing this project

README

        

Solving a word game
==================

I love word games. One of my favourites is Squabble, also known as Anagrams or [Snatch](http://www.boardgamegeek.com/boardgame/9556/snatch). It's a good pub game because all you need is a bag of letter tiles. Any number of people can play (and join or leave throughout), and you don't need to keep score. The rules are simple:

> Place the tiles face down and take [rough] turns to turn them over until a word of three or more letters can be made. If you see and say the word first, take it. Watch out. From now on the game has 2 sides as words are made both from the centre pool of letters or snatched from other players if changed by one or more letters. So your CAT can become their CART to be snatched away as TRACK seconds later. Play on until all the letters have been turned and you agree to stop playing and start scoring.

The squabbles happen over who spoke first and whether, say 'restrainer' is a real word.

Anyway, this blog post isn't about Squabble, but another game invented† as a training game for it. It's for two players, and can be on paper or out loud (so you don't need any equipment at all). The first player says a one letter word. The second player adds a letter, and rearranges to make a new word. Play continues by turn. For example, a game might proceed:

* i
* in
* win
* wine
* wined
* winged
* welding

At this point, the next player is stuck (can't think of a word), and concedes. The player who said the last word—'welding'—wins.

†I said invented, but others have probably invented the same rules too. Nevertheless, we need a name for this 'add-letter-and-rearrange' game. Herein, I shall call it Alar. (Interestingly, 'alar' is a dictionary word meaning "pertaining to, resembling, or having wings").

Because you need to know the game well to follow this blog post, let me quickly demonstrate another game, between two players Bob and Eve. I've highlighted the letter added each move.

* Bob: a
* Eve: a**s**
* Bob: **w**as
* Eve: **l**aws
* Bob: s**u**ral [pertaining to the calf of the leg]
* Eve: **w**alrus

At this point Bob is stumped, and Eve, who had the last word, wins.

Okay, great. Now, the intent of this blog post is to solve this game Alar. But what does that mean, to *solve* a game? I mean, describe a winning strategy, that one player can use to always win, however their opponent plays. I say 'one player' because the winning strategy will only be suitable for either the first player or the second. They can't both always win.

First, observe that every game of Alar ends with a definite victory. There's no such thing as a draw, stalemate or anullment (we assume the players can agree to defer to the same dictionary in case of argument). Now we ask, does either player have a *winning strategy* for the game?

Wait, if every game has a winning strategy

Chess has stalemates. And chess is much more complicated than our game Alar.

Combinatorial game theory. Winning ways for your mathematical plays. Conway, Berlekamp, Guy. Seminal.