goldfire / pokersolver

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

Royal Flushes Not Evaluated Correctly for Deuces Wild #19

Open woodydeck opened 4 years ago

woodydeck commented 4 years ago

console.log(Hand.solve(['2s','Kc','Jc','2d','Qc'],'deuceswild').name) evaluates to only a straight flush. Same goes for a natural royal.

If you change .name to .descr it works, but adds extra info for all the other hands. I am trying to figure out a fix, but these evaluation libraries are always convoluted to the person that didn't write them.

ericblade commented 4 years ago

I suspect that the answer to this is that technically, a royal flush is a straight flush of the highest rank. Others may have other feelings about that, though.

woodydeck commented 4 years ago

I get what you are saying if .name was meant for debug and a synonym of class, but it is not congruent with the other methods. rank and descr work after some testing. I am now just using rank and then using that number to call and array of ordered ranks, minus 1 of course.

ericblade commented 4 years ago

If .name returns straight flush, and .descr returns royal flush, then it sounds to me like it's probably intended that way. I've never actually built anything with the library, though, so I don't have any particular insight into it. :-)

woodydeck commented 4 years ago

It looks like a logic error to me persistent across games, it's not just deuceswild. The documentation doesn't hint that it should be a class, only that it is a type.

Every single library on github has issues with wrong evaluation except the ones using lookup tables, but haven't found that for wildcard games. There is no progress on the code golf side of such a library I think because ultimately if you care about speed, you just make a lookup table and enumerating one only takes once, so you don't need efficiency at any point, and it's very tedious no matter how quick you are.