Beneath the glamour of flashing lights and free cocktails, casinos are carefully engineered to slowly bleed their patrons of cash. But for years mathematically inclined minds have tried to turn the tables on the rigged machines by using probability theory and game theory to exploit weaknesses in the system.

Many people believe that casinos are a bad thing for their communities because they decrease local jobs and cause gambling addictions, but they do provide a lot of tax revenue. A study conducted by the University of Nevada found that casino operations boosted state tax revenues by $1.8 billion between 1986 and 1992. In addition, casinos contribute to the economy by providing entertainment and tourist attractions. They also provide employment opportunities for residents, including security personnel and food service workers.

Gambling has been part of human culture for millennia, with the first evidence of dice showing up in China in 2300 BC and card games following shortly after. But modern casinos have taken things to a whole new level, with some offering a dazzling array of games.

Besides blackjack, which is the most popular casino game worldwide, many casinos offer traditional Far Eastern games like sic bo, fan-tan, and pai gow. American casinos are also renowned for their slot machines and video poker, which produce fast, high-volume play at stakes from five cents to a dollar. These games are often designed by teams of mathematicians who analyze house edge and variance to make sure the machines have the right balance between thrill and profitability.