A Musikalisches Würfelspiel (German for "musical dice game") was a system for using dice to randomly 'generate' music from precomposed options. These 'games' were quite popular throughout Western Europe in the 18th century. Several different games were devised, some that did not require dice, but merely 'choosing a random number.'
The earliest example is Johann Philipp Kirnberger's Der allezeit fertige Menuetten- und Polonaisencomponist (German for "The Ever-Ready Minuet and Polonaise Composer") (1757 [1st edition; revised 2nd 1783]). Examples by well known composers include C. P. E. Bach's Einfall, einen doppelten Contrapunct in der Octave von sechs Tacten zu machen, ohne die Regeln davon zu wissen (German for "A method for making six bars of double counterpoint at the octave without knowing the rules") (1758) and Maximilian Stadler's Table pour composer des minuets et des Trios à la infinie; avec deux dez à jouer (French for "A table for composing minuets and trios to infinity, by playing with two dice") (1780).
In the early 20th century the Kaleidacousticon System, using arbitrarily combinable playing cards, was unsuccessfully marketed in the Boston area as a parlour game.
According to Lawrence Zbikowski, "In truth, chance played little part in the success of the music produced by such games. Instead, what was required of the compilers...[was] a little knowledge about how to put the game together and an understanding of the formal design of waltzes, etc."
According to Stephen Hedges, "The 'galant' middle class in Europe was playing with mathematics. In this atmosphere of investigation and cataloguing, a systematic device that would seem to make it possible for anyone to write music was practically guaranteed popularity.
According to Leonard Meyer, "Eighteenth-century composers constructed musical dice games while nineteenth century composers did not. ... [W]hat constrained the choice of figures [in seventeenth- and eighteenth-century music] were the claims of taste, coherent expression and propriety, given the genre of work being composed, rather than the inner necessity of a gradually unfolding, underlying process [as in nineteenth century music]". See: musical development.
The way these games work may be understood in analogy to sentence construction.
1 The cow ran past the field. 2 The pig walked through the yard. 3 The sheep ran into the marsh.
One rolls one die for each word and selects the word from the appropriate column according to the number. Thus if one rolls 1 2 3 1 2 3 one is given, "The pig ran past the marsh." Each progression is essentially the same, there may be more or less choices for different slots, and the choices offered for each slot are slight variations rather than being entirely different.
The most well-known was published in 1792, by Mozart's publisher Nikolaus Simrock in Berlin (K. 294d or K. Anh. C 30.01). The game was attributed to Mozart, but this attribution has not been authenticated. The dice rolls randomly selected small sections of music, which would be patched together to create a musical piece. A 'computerized' version of the Musikalisches Würfelspiel making a MIDI file is available here. This game is capable of producing 1116 = 45,949,729,863,572,161 different yet similar waltzes. Some measures have only one possibility no matter what the roll of the dice (measure 8/16) while other measures have a different possibility for each roll (measure 1/16).
Mozart's manuscript K. 516f, written in 1787, consisting of numerous two-bar fragments of music, appears to be some kind of game or system for constructing music out of two-bar fragments, but contains no instructions and there is no evidence that dice were involved.
The titles of the supposed Mozart compositions are:
Robert Xavier Rodríguez composed his Musical Dice Game for string orchestra based on K. 516f.
The attribution of Joseph Haydn's Gioco filarmonico o sia maniera facile per comporre un infinito numero de minuetti e trio anche senza sapere il contrappunto (Italian for "The game of harmony, or an easy method for composing an infinite number of minuet-trios, without any knowledge of counterpoint") has also not been authenticated.