The simplest algorithm for poker hand evaluation

后端 未结 12 1038
独厮守ぢ
独厮守ぢ 2020-12-04 12:39

I am thinking about poker hand (5 cards) evaluation in Java. Now I am looking for simplicity and clarity rather than performance and efficiency. I probably can

12条回答
  •  醉酒成梦
    2020-12-04 13:07

    If you just want to understand how it works here is simple algorithm:

    HandStrength(ourcards,boardcards)
    {
        ahead = tied = behind = 0
        ourrank = Rank(ourcards,boardcards)
        /* Consider all two-card combinations
        of the remaining cards. */
        for each case(oppcards)
        {
            opprank = Rank(oppcards,boardcards)
            if(ourrank>opprank)
                ahead += 1
            else if(ourrank==opprank)
                tied += 1
            else /* < */
                behind += 1
        }
        handstrength = (ahead+tied/2) / (ahead+tied+behind)
        return(handstrength)
    }
    

    It is from "ALGORITHMS AND ASSESSMENT IN COMPUTER POKER" by Darse Billings.

提交回复
热议问题