goldfire / pokersolver

Javascript poker hand solver.
MIT License
373 stars 93 forks source link

Winner #13

Closed ghost closed 6 years ago

ghost commented 6 years ago

How do you output which hand is a winner? If I get two hands that are both A-high, the description doesn't include the kicker. How do I know which won?

goldfire commented 6 years ago

You know which won with the winners method: https://github.com/goldfire/pokersolver#winnershands

ghost commented 6 years ago

var hand1 = Hand.solve(['6d', 'Jc', 'Tc', '2c', 'Ac', 'Ah', '3h']);
var hand2 = Hand.solve(['6d', 'Jc', 'Tc', '2c', 'Ac', 'Ad', '4d']);
var winner = Hand.winners([hand1,hand2]);

console.log(winner.length);

Who won? Hand 1? Hand 2? What about two Full Houses? If the winners array includes just one hand, how do you know which hand is in there?

goldfire commented 6 years ago

In the example you gave there is no winner because they both have the same hand. But, if there was a single winner, the winners array passes back the hand(s) that won, so you can compare by reference: hand1 === winner[0].

ghost commented 6 years ago

Thank you.