Jump to content

Poker AI

79wjd

I need to write an AI that can play a game of poker. It doesn't have to be good or even decent, it just has to be at least marginally better than just randomly deciding whether to bet/fold/throw away/draw cards. 

 

I was thinking of calculating which cards in your hand are worth the least (i.e. it would look at the hand, and if it has four cards that contribute to a Royal flush and a fifth card that doesn't, it would discard that fifth card). But I was wondering what other ways I could go about deciding whether to bet/fold/which cards to keep/throw away.

PSU Tier List | CoC

Gaming Build | FreeNAS Server

Spoiler

i5-4690k || Seidon 240m || GTX780 ACX || MSI Z97s SLI Plus || 8GB 2400mhz || 250GB 840 Evo || 1TB WD Blue || H440 (Black/Blue) || Windows 10 Pro || Dell P2414H & BenQ XL2411Z || Ducky Shine Mini || Logitech G502 Proteus Core

Spoiler

FreeNAS 9.3 - Stable || Xeon E3 1230v2 || Supermicro X9SCM-F || 32GB Crucial ECC DDR3 || 3x4TB WD Red (JBOD) || SYBA SI-PEX40064 sata controller || Corsair CX500m || NZXT Source 210.

Link to comment
Share on other sites

Link to post
Share on other sites

When I think of it I would make some sort of check list, I would check what I already have in hand, and I would then pick the strongest figure, and next I would check what I  can have if I change some cards and what are odds I can get it, for example If I have QQ AAA I have A as highest card, 1 pair, 2 pairs and full house, when you prioritize it you will end up that full house is the strongest, then you can check what could you get when swap card(s) so you could get four of a kind, you could get actually anywhere from there but the more card you want swap and the more card of this type you already have the less odds are you will get it.

Link to comment
Share on other sites

Link to post
Share on other sites

15 hours ago, djdwosk97 said:

I need to write an AI that can play a game of poker. It doesn't have to be good or even decent, it just has to be at least marginally better than just randomly deciding whether to bet/fold/throw away/draw cards. 

 

I was thinking of calculating which cards in your hand are worth the least (i.e. it would look at the hand, and if it has four cards that contribute to a Royal flush and a fifth card that doesn't, it would discard that fifth card). But I was wondering what other ways I could go about deciding whether to bet/fold/which cards to keep/throw away.

What style of poker? The way you'd act in 5-card stud is different than Texas Hold'em.

 

A lot of the betting strategy for AIs in poker is mostly to do with statistics, since bluffing isn't really a concept. For example, if an AI gets a three of a kind and knows nothing else about the other player's hands, it knows there's at least at least a 2% chance someone will either match it or beat it (since a three of a kind happens 2% of the time). In Texas Hold'em, it can use this heavily to its advantage since it knows something about the players as well.

 

But a lot of betting strategy also comes down to what the other players do. You can adopt typical strategies for poker into AI behavior, with a bit of RNG thrown in for flavor. For example if we were doing Texas Hold'em

  • On the pre-flop, if you don't have a high card (10, J, Q, K, A) or two of the same suit (either in general or within a certain value of each other in hopes of getting a straight), then fold unless you're a blind.
  • On the subsequent rounds:
    • If someone bets and you have nothing, fold.
    • If everyone checks and you don't have anything, check.
    • If you have a possibility, check.
    • If you have something, bet.
    • If someone bets and you have a possibility (like a chance for a straight or flush), call it.
    • If someone raises the bet before you do, unless you have a strong hand, fold. Otherwise call it or raise it depending on the strength of the hand
    • If you have a strong hand, raise the bet.
    • If you have a really strong hand and you want to be ballsy, All-in.

(I'm not a high level poker player so take this as you will).

Link to comment
Share on other sites

Link to post
Share on other sites

Best way to set this up is predefined a set of rules
 cards A,B,C,D,E = X hand name
 X hand name = < than Y hand name
(Repeat the process for each hand creating a hierarchy of circle/loop)

then when it comes to dealing the cards
say 
Spades = Ace - King
Diamonds = Ace - King
Clubs = Ace - King
Hearts = Ace - King

Then with every deal, remove a random card / Value from any of the the 4 suits so they don't get dealt again

Dealt?
Spades:
Ace = False
2 = true
3 = true
ext...

this would be the best way to setup the raw mechanics of the poker game...
Then create a separate set of rules for betting & folding

Character artist in the Games industry.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×