Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Data-driven letter valuation for word games
CoffeeScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
scrabble
src
.gitignore
README.md
package.json

README.md

Valett

Valett is a Node module for determining the appropriate letter valuations in word games. Valett analyzes the corpus of a game's legal plays and provides point values for the letters in the game based on a desired weighting of their frequency, frequency by length and the entropy of their transition probabilities.

An example script for determining appropriate letter values for Scrabble is in the scrabble/ directory. To run it, navigate to scrabble/ and run (with CoffeeScript installed globally):

coffee scrabble.coffee

One could also use Valett to calculate board difficulty in a game like Boggle (boards with neighboring letters that have a low probability of transitioning to each other are harder).

Installation

Install via NPM:

npm install valett

Usage

valett = require 'valett'

From the Scrabble example (CoffeeScript):

valett.init words, letters

weights = {frequency: .34, frequencyByLength: .33, entropy: .33}
frequencyByLengthWeights = [0, 50, 25, 5, 2.5, 1.25, 0.625, 25, 12.5, 2.5, 1.25, 0, 0, 0, 0]
entropyWeights = [.5, .5]

valett.analyze 10, weights, frequencyByLengthWeights, entropyWeights

console.log "#{letter}: #{valett.values[valett.hash[letter]]}" for letter in letters

Words is an array of acceptable words and letters is a sorted (to your preference) array of the unique letters in the corpus. Valett stores a hash from letters to array indices in valett.hash, and stores the computed corpus statistics in valett.metadata after valett.init. The computed values are in valett.values after valett.analyze:

valett.analyze maxValue, weights, frequencyByLengthWeights, entropyWeights
  • maxValue is a scaling term for determining the highest possible letter value.

  • weights is an object whose fields determine the relative weighting of frequency, frequency by length, and entropy when calculating letter values. The fields should sum to 1.

  • frequencyByLengthWeights should be the length of the longest word in the corpus, and reflects the relative value of a letter's occurrence in words of different length. For example, in Scrabble it is particularly valuable for a letter to appear in 2, 3, 7 and 8 length words.

  • entropyWeights should be length 2, and reflects the relative value of the ease of transitioning into a letter (how evenly the transition probabilities toward a letter are distributed) and out of a letter. For example, Q has a low entropy out since its transition probability distribution is highly peaked at U.

Contact

Contact Joshua Lewis with comments and suggestions. The code is MIT licensed and pull requests with analyses for other games or new corpus metadata are welcome!

Something went wrong with that request. Please try again.