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.