Gambling is a vice. It is considered as a sin.
As far as a Kshatriya king and gambling is concerned, he should avoid it carefully as one of the vices.
MS 7.45. Let him carefully shun the ten vices, springing from love of
pleasure, and the eight, proceeding from wrath, which (all) end in
misery.
in the above verse, "He" refers to a King. Now, the ten vices which are mentioned in the following verse, includes among them, gambling.
MS 7.47. Hunting, gambling, sleeping by day, censoriousness, (excess
with) women, drunkenness, (an inordinate love for) dancing, singing,
and music, and useless travel are the tenfold set (of vices) springing
from love of pleasure.
Gambling and betting are criminal offences too and the King should punish the offenders just like he punishes the thieves.
MS 9.221. Gambling and betting let the king exclude from his realm;
those two vices cause the destruction of the kingdoms of princes.
MS 9.222. Gambling and betting amount to open theft; the king shall
always exert himself in suppressing both (of them).
MS 9.224. Let the king corporally punish all those (persons) who
either gamble and bet or afford (an opportunity for it), likewise
Sudras who assume the distinctive marks of twice-born (men).
MS 9.228. On every man who addicts himself to that (vice) either
secretly or openly, the king may inflict punishment according to his discretion
The only place where i found gambling being allowed is in the following verse:
In the middle of the assembly hall he should erect a gaming table,
sprinkle it with water, and place there dice–– they should be in
pairs, of Vibhitaka seeds,* and in adequate numbers. Aryas who are
upright and honest may gamble there. Weapons contests, dancing,
singing, and concerts should not be held without the presence of royal
officials.
AD 2.26.8
But, every where else it is mentioned as immoral, a sin, not recommended etc.
Next, sins that make people sordid: gambling; sorcery; living by
gleaning on the part of a man who has not established the sacred
fires; begging alms food by a man who has returned home from his
teacher’s, as well as his residing at his teacher’s house for more
than four months;
BD 2.2.24
As an interesting side note it can be mentioned that, as per Manu Smriti, gambling arises from the third ( and the lowest) state of Rajas ( with Sattva= Goodness, Rajas= Passion or activity, Tamas=Inertia , ignorance- the Trigunas).
MS 12.45. Ghallas, Mallas, Natas, men who subsist by despicable
occupations and those addicted to gambling and drinking (form) the
lowest (order of) conditions caused by Activity.
Abbreviations used:
MS= The Manu Smriti.
AD= Apasthambha Dharmasutras.
BD= Baudhayana Dharmasutras.