6
retoor
323d

Working on a poker card simulator. Currently benchmarking the hands by giving them a rating (high card value, pair).

In the simulation there are three players. The first player who get the hand cards first seems to have advantage. Does this make sense?

Comments
  • 0
  • 1
    yep, they all know the arrangement, but the 1st have the privilege to 'shuffle' the cards ;}
  • 0
    timing issues perhaps?
  • 0
    @we3d this is the source for getting a card from the staple:

    public Card PickCard(){

    Random random = new Random();

    int index = random.Next(0, this.cards.Count);

    Card result = result = this.cards[index];

    this.cards.Remove(result);

    return result;

    }

    I don't think that this code can deliver an advantage resulting in high cards.
  • 4
    hmm, that feels a bit magical, why u draw random cards from d deck. shouldn't u shuffle them and draw them in a sequence to be more realistic?
  • 1
    plus u can track the shuffle method and see if the first r always the good ones ;)
  • 1
    @We3D You're right. I now changed it that the deck is shuffled and the PickCard always returns top of staple.

    Result after 100 games it is still:

    Wons: 36 Losses: 64 Success Rate: 0.36%

    Wons: 33 Losses: 67 Success Rate: 0.33%

    Wons: 31 Losses: 69 Success Rate: 0.31%

    The first player wins almost every time when I execute the project.
  • 1
    @retoor change the random
  • 0
    @We3D I did. As random as it can get:

    this.cards = this.cards.OrderBy(a => Guid.NewGuid()).ToList();
  • 3
    take a photo of a lava lamp. make script to calc random num based on the pixels of the photo shuffle that times the deck with similar rnd method and u'll get a pretty random deck each time =]
  • 2
    @We3D haha, this project goes over his budget by buying a lava lamp.

    Now I sort three times based on random uid before very round and simulate the game 100000 times.

    These values are almost consistent after every run:

    Wons: 37504 Losses: 62496 Success Rate: 0.37504%

    Wons: 33428 Losses: 66572 Success Rate: 0.33428%

    Wons: 29068 Losses: 70932 Success Rate: 0.29068%

    Player 1 always wins, Player 2 is second, Player 3 is third.
  • 1
    u can also try random sleep periods between the shuffles since most rnd generators r based on d time it may change the result a bit...
  • 1
    @We3D Hmm, how the cards are initially generated does already not make sense (which is good). I think I just have to live with this. There is just advantage in position of receiving cards.

    a. cards are never in good order to start with

    b. tried various random methods

    c. execute random methods multiple times

    That good cards reach top doesn't make sense because for the computer a card is a card. There is no magic regarding worth of a card.
  • 1
    unless the card is a number, which the cpu much can recognize and sort the big to the top or smth similar?
  • 4
    @We3D I found it - if players have same rating for hand, my code for determine who've won says that the first with same rating (Mostly player 1) is considered winner. I changed a > with >= and the result is with same values but inversed now. Now player three always wins.
  • 2
    @retoor yay, progress at last ^,^
  • 3
    @We3D YEAH, that's what we want:

    Wons: 37344 Losses: 62656 Success Rate: 0.37344%

    Wons: 37580 Losses: 62420 Success Rate: 0.3758%

    Wons: 37373 Losses: 62627 Success Rate: 0.37373%

    It looks weird because 3 * 37 > 100 (percent) but a tie is a win. The money gets devided over tied players.
  • 2
    @retoor maybe if the winning player shares the same score with another one, discard this round and don‘t count is as a win or loss.
  • 1
    @We3D If I execute a million times now the success rates all started with 0.374*****.

    So handling the ties was the solution. The sort algorithm was always ok probably.
  • 1
    @retoor it's usually a small change that leads to the win... one just needs to find it ;}
  • 0
    @Lensflare hmm, not counting a tie is not good for statistics either. All values together will not be 100%. Since the tie people receive money I see it as a win. It's just a choice / preference.
  • 2
    @retoor yes I agree, it depends on what you want to achieve. I just see it as a way to make it so that it adds up to 100%. Because you could make matches and discard ties until you have your desired amount of valid matches (100) and then the percent values for the winners should add up to 100% exactly.
    But if you want to divide the money between players when there is a tie, then of course you can‘t discard them.
  • 2
    @Lensflare heh, online poker became legal in NL. Now I want to register to such sites, they ask to upload your passport. Damn. I have no idea for which site I will write the bot.
  • 1
    @retoor I think what you plan to do is illegal.
  • 1
    @Lensflare it wouldn't be fun otherwise ;}
  • 3
    @Lensflare doesn't have to be. The application gives me enough insights to become a decent player myself. Maybe I won't build a bot. But I actually don't like to play it. I just like the project a lot. At the beginning I wanted to do this with AI. I think it doesn't make sense to do that because it's easy calculatible. Weirdly enough some group of professors are working on poker AI. I think it's BS
  • 3
    Dont forget to initialize your rng.
    Some libraries produce the same sequences or outputs for testing purposes, if they arent initialized first.
  • 1
    You might want to look at Flopzilla Poker analysis software for No Limit Holdem' (NLH). It will give you a sense of the kind of range analysis that is feasible for you. "An Empirical Test of the Relative State Model with Texas Holdem Poker Scenarios" by Jeffrey Paul Deminchuk examines this tool.
  • 3
    @retoor

    I think the main point of failure here is that the value of starting hands varies based on your position on the table.

    Not the same being the blind, the button, etc. The ranges change. They also change based on number of players left.

    Afraid I can't point you to specific resources, since this all comes from actual playing experience.

    Also, for a more accurate simulation, you'd need to model player mood and style. Whether they are bluffers, slow players, etc, how much and how hard they tilt, etc.
  • 1
    What you building it in anyway? Language? Framework? Tools?
  • 1
    @Wisecrack C#.net core on Linux. Just for fun. I like it a lot but I think I do the names wrong. Will fix later
  • 1
    @CoreFusionX the project runs nice now. It does all the stuff (straightFlush, flush, etc) and shows the communityCards.

    What I have now is a working simulator.

    For example Simulator. Predict("DA,SA") gives 86% of winning based on thousand simulations. Also it gives info about the hand given like 'sequence, high cards, same kind, pair etc'. Same kind can be informational for second round same if cards are following up.

    In the end it still became a bit AI thingy
  • 1
    @retoor when u get rich by its fruits don't forget to drop few cents here ;]
  • 2
    @We3D I have not a website yet were I can play for money as a Dutch guy. Maybe it's time for a credit card.

    I have a terminal poker game and I win on hard mode using my apps advice.

    Of you want to try a bot search for pokerbot github. It even works for PokerStars. Don't know if he's any good
  • 1
    @retoor I play such games only for fun, meaning w/o real money involved =]
  • 0
    @bigmonsterlover what do you mean?
  • 3
    @retoor

    By the way, going back to OP.

    First player getting dealt poses a conditional probability.

    They have a better chance at high ranges, but if they do not draw them, subsequent players have higher chance because there's two less low value cards in the deck, and so on.

    Do use Bayes theorem. Probability is not intuitive.
  • 0
    @CoreFusionX came to ask the same thing about bayes.
  • 2
    @Wisecrack

    Basically, first card is random to be a range suitable card (depends on position and number of players, but let's assume), around 16/52.

    But the second card being suitable is contingent on the first card, and it's therefore a conditional probability. (Getting an ace matters not if you got a 6u first, or if you get a 10 first, the only suitable cards are a 10 or suited connectors, which is 10/51). Of course the denominator keeps going down as more cards are dealt.

    Bayes theorem serves to calculate conditional probabilities, which are not just multiplying the probability of each event.
  • 1
    @bigmonsterlover should not be hard to make. At this moment all players do nothing than receiving cards and just win / lose after the community cards. I'm creating probability stats with this. It's fun. Rewrote it in c++ and it gained 60% performance increase. 300msec/1000 simulations. C# took a second.
  • 1
    @retoor now do it in ASM to see the real performace spike ;}
  • 1
    @We3D I doubt if that would be. C++ does many ASM optimizations right? Since you lost your job, you can now build a bot too for an income 😁 I've learned so much about poker, damn. This project is so much fun.
  • 1
    @retoor I still have about a month to tinish this and that ( max 5-6 days )

    then not sure what will do ( will wait eventual questions about my work... if any )

    and yep, there is a lot of asm optimzatins in C, but still remaking it in ASM u can control every aspect of the loops and who knows, maybe u can find 1-2 optimizations and shortcuts via the registers and the stack which will speed up the calcs even further...

    but then again I'm sure ur solution is fast enough and ( as u said ) already giving fruits and another but for the oposite : it's not that much of a codebase ( or is it ) so could be fun to think it in ASM for the mental excersize alone =}
  • 1
    @We3D making the actual bot that reacts on raises and other actions is the hardest part that would make the code base grow. You have to parse all actions and values from a screenshot. On top of that comes that it would only work for a specific website. Sad to put so much energy in it. But I'm getting quite good myself, in that case it's more fun walking regularly in a casino. Great life.

    The code base is small but a lot of business rules. For so far it doesn't have any hacks.

    I have this optimization to do: sort all cards everywhere to speed up the calculation process. The functions would return earlier. On thousand * players * 10 calculations per run it can spare quite a bit.

    Do you've ever remember to have won with a highcard? I did many times but it seems that chance is 2% of winning.
  • 1
    @retoor now w/ all that details I can agree is quite a big project for ASM for sure.

    The poker is not all stats. If you become really good u can win with pretty low cards and good play ( as they say, u have to have the poker face 4 dat and it works only on live play, couse u have to read coreectly all the little emotions on the other faces too ;} )
  • 2
    @We3D

    Please do not fall for this.

    No one *ever* wins high stakes poker with just a p-p-p-poker face.

    All pro players have immense knowledge on statistics and ranges, beside their natural intuition.
  • 1
    @CoreFusionX I'm now learning when to raise - I was playing, winning but still losing money. Of you never raise but they do - there you go. Playing full safe is losing apparently.

    Damn, fun stuff.

    Respect for the guy who made a terminal poker app but the card checks are WRONG. I'll make my own terminal poker with hookers and blackjack. I'll unit test the f outa it
  • 2
    @retoor

    I find it best to think of raises as putting a price tag on the next card.

    When you have a reasonably strong hand, and particularly if the flop leads to drawing plays, you do not let the other players draw that hand for free.

    When you *know* you have the best hand, you always raise, but the amount differs. If there's no drawing hands, raise just a bit to increase pot without scaring away other players.

    If there's drawing cards, go in big, make them pay for that draw, and beat them after.
  • 1
    @CoreFusionX "you need luck to see useful cards appearing on the board" according some websites. I would call that skill. I wrote a program to train myself in it. Beautiful ascii art cards. It's cool to be educated by own software
  • 0
    @CoreFusionX "you need luck to see useful cards appearing on the board" according some websites. I would call that skill. I wrote a program to train myself in it. Beautiful ascii art cards. It's cool to be educated by own software
  • 1
  • 1
    @We3D cool. Love Harry Potter. He, how dobby looks
  • 1
    @We3D this is for you, an insight into Dutch life: https://youtu.be/5wC_HQTMGrM
  • 1
    didn't understood a word, but I got that he said in d end the clasic : I'm ok guys
  • 1
    @retoor that didn't stoppng it to be funny. if there was even the broken auto translatad captions I bet is even funnier !]
Add Comment