The Apaṇṇakasutta (MN 60) subverts the imagery of gambling by reasoning towards logical certitude in a world of apparently random chances.
Regards the key term apaṇṇaka, the Critical Pali Dictionary says the etymology is unknown, and Cone has a question mark. CPD notes:
perhaps originally a term from the game at dice (the proper sense of which had been forgotten).
It is sometimes derived from pañha with the sense “unquestionable”. Most translators lean on this derivation, with such renderings as “incontrovertible”, “unquestionable”, etc.
However, I’ve always found this a little, well, questionable, perhaps because nowhere else in Pali does pañha appear as paṇṇa. Also, there seems to be no real cognate for it in Sanskrit, forcing later Buddhists to invent a hyper-Sanskritized form. Something always felt a bit post-hoc about this explanation.
The commentaries don’t, so far as I know, support this derivation. The commentary for MN 60 says:
Apaṇṇakoti aviraddho advejjhagāmī ekaṃsagāhiko
Apaṇṇaka means unfailing, an undivided path, categorical
The Apaṇṇakajātaka (Ja 1) offers a similar explanation:
Tattha, apaṇṇakan-ti ekaṁsikaṁ aviraddhaṁ niyyānikaṁ.
In this connection, apaṇṇaka means being sure, unfailing, leading to deliverance.
Now, if we look at words that do appear as paṇṇa in Pali, we find the number five (pañca), of which paṇṇa is a common form. To understand the significance of this, we’ll have to spend a little time at the casino.
Apaṇṇaka is closely connected with the gambling term kataggāha. Both feature in MN 60 and in SN 42.13. Further, apaṇṇaka describes the throw of a “gem”, apparently a kind of die, at AN 3.118:4.6 and AN 10.217:17.1. The extended metaphor the Buddha develops in all these cases is that, while it may appear that life is but a game of chance, it is possible, using the wise application of reason, to find a path that can succeed without fail.
Gambling was a major feature of Vedic culture, with the moving tale of Rig Veda 10.34 recounting the thrill and loss of the game. The gods were invoked to ensure success (Atharvaveda 7.109). Even kings bowed to the dice (Rig Veda 10.34.8), so that the Rājasūya consecration ceremony is secured with a (loaded) game of dice (Śatapatha Brāhmaṇa 5.4.4.6, 23). Numerous tales of kings losing their realms at dice, most notably Yudhiṣṭhira in the Mahābhārata, show that the power and danger of gambling was not merely symbolic.
Deatails of the classical Vedic game of chance are obscure and would have changed over time, but it seems that a large quantity of vibhītaka (“bedda”) nuts were cast in a hollow, from which players took a handful. If the number of nuts was divisible by four, it was said to be a “perfect” (kaṭa; see Rig Veda 1.132.1, etc.). This explanation is from the Jamison/Brereton translation of Rig Veda 10.34, relying on a 1986 German article by Harry Falk, Bruderschaft und Würfelspiel: Untersuchungen zur Entwicklunsgeschichte des vedischen Opfers.
The Pali expression kaṭaggāha, often translated as “winning throw”, therefore means “perfect (kaṭa) hand (gāha)”.
Its opposite is the kaliggāha, a “losing hand”. While a set of four dice was “perfect”, the fifth “losing” (kali) die was all-powerful, since just one extra die meant you lose everything (Rig Veda 10.34.2, Śatapatha Brāhmaṇa 5.4.4.6).
Apaṇṇaka is therefore literally a “set without a fifth”, and metaphorically “unfailing”.
Of course if you really want to win at gambling “without fail”, that’s simple. Don’t play.