2
\$\begingroup\$

DISCLAIMER: So I asked this on StackOverflow and was told it was not a good question for the community but was suggested to check here. If this question sucks or just doesn't belong here either, feel free to let me know. It seems a fair question to me, but I know it's important to maintain high standards on these sites.

So I just put the finishing touches on a poker game in JavaFX. Part of the functionality in this program is a single player mode, where you can play hands against the computer. To be transparent, this is a university project, so I'm not aiming for perfection. More, just an ai that behaves semi-intelligently for game variation and minor challenge for casuals.

So to be clear, I am aware of general poker strategy, and have found numerous articles/research papers/links on more in-depth poker AI's designed to compete against competitive players. I guess as an analogy, there's the Easy mode bots in League of Legends, then there's the deep learning AI that beat a DOTA pro in laning.

I'm definitely aiming for the former here. While I currently have a basic algorithm that works as:

if(gamestate = flush, straight, 3-pair, full-house, face card pairs)
{
     raise 1/4 pot;
}
else if(gamestate = pair, potential flush or straight, etc)
{
     check/call;
}
else
{
    fold;
}

So I already have functionality that can detect current board/hand states, but I do not have any functionality that can estimate chances at winning the hand, compare with opponent's possible hands, etc. Since the game only needs to be for casual play, the more advance algorithm's seem like massively overkill.

I guess my wishful thinking hope is that something exists similar to min-max in tic tac toe, although poker is obviously more complex. But something that can make some kind of rough approximation of hand value, that wouldn't require thousand's of if statements to cover every possible situation.

So if anyone knows of any algorithms that would be used in, for example, a poker phone game or such, I'd really appreciate some help. To reiterate, if this question is too vague, I'm happy to provide any other information about my existing research, program design, or anything in this vein.

\$\endgroup\$
1
\$\begingroup\$

Strategically, poker is a very complex game, but there's also a very limited set of actions a player can take. Count 'em: fold, call, check, raise X. So really there's countless ways you can implement even a simple AI. I would suggest you approach the problem iteratively, and adjust until you've got an acceptable AI.

As a start, you could make an AI that calls everything. It will be unbluffable, but also easy to beat because as long as you have a good hand you can raise and win everything. But it's a dead-simple algorithm with at least some chance for the player to lose.

Next you could add a call limit. The AI will be willing to bet more if their hand is good or if their chance of winning is good. This AI has the opposite weakness: it's too easy to bluff. But for fixed-limit poker, it might be fine.

As for estimating the chance to win, this can be very simple. It is simply looking at the chance that an opponent could have a higher hand than the player, out of all the cards that are not shown. For example, let's say that the only opponent has one card in their hand that the player can't see, and the only chance they can beat the player's hand is if it is an ace, and there are currently no aces in view. There are 4 aces, and suppose there are 40 cards not in view, so their chance of winning is 4/40 or 1-in-10 chance, and the player has a 9-in-10 chance.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.