GithubHelp home page GithubHelp logo

axross / poker Goto Github PK

View Code? Open in Web Editor NEW
14.0 2.0 4.0 365 KB

A Dart implementation of Texas Hold'em matchup simulator based on Henry Lee's Poker Hand Evaluator

Home Page: https://pub.dev/packages/poker

License: Apache License 2.0

Dart 100.00%
dart poker texas-holdem flutter poker-engine

poker's Introduction

poker's People

Contributors

axross avatar eramvn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

poker's Issues

Improvement: make MadeHand ratings for other than 7 cards.

Now only hands with exactly 7 cards can be evaluated. For other types of games an extended evaluation would be useful, where the input parameter would be the cards (could be one or even 10) and the algorithm would evaluate the best hand and also select which one is the best.

Bugs in HandRange.fromCardPairs function

Hi,

I think there is a bug in the fromCardPairs function. Here is the test code where I found the bug in version 0.10.0

Set<CardPair> test = HandRange.parse('JJ-4498s').cardPairs.toSet();
test.remove(CardPair.parse('4s4d'));
test.remove(CardPair.parse('4h4d'));
test.remove(CardPair.parse('4d4c'));
test.remove(CardPair.parse('4s4c'));
test.remove(CardPair.parse('4h4c'));
test.remove(CardPair.parse('4d4c'));
print(test);
//Output: {(Js, Jh), (Js, Jd), (Js, Jc), (Jh, Jd), (Jh, Jc), (Jd, Jc), (Ts, Th), (Ts, Td), (Ts, Tc), (Th, Td), (Th, Tc), (Td, Tc), (9s, 9h), (9s, 9d), (9s, 9c), (9h, 9d), (9h, 9c), (9d, 9c), (8s, 8h), (8s, 8d), (8s, 8c), (8h, 8d), (8h, 8c), (8d, 8c), (7s, 7h), (7s, 7d), (7s, 7c), (7h, 7d), (7h, 7c), (7d, 7c), (6s, 6h), (6s, 6d), (6s, 6c), (6h, 6d), (6h, 6c), (6d, 6c), (5s, 5h), (5s, 5d), (5s, 5c), (5h, 5d), (5h, 5c), (5d, 5c), (4s, 4h), (8s, 9s), (8h, 9h), (8d, 9d), (8c, 9c)}

HandRange parsed_test = HandRange.fromCardPairs(test);
print(parsed_test.cardPairs.toSet());
//Output:  {(Js, Jh), (Js, Jd), (Js, Jc), (Jh, Jd), (Jh, Jc), (Jd, Jc), (Ts, Th), (Ts, Td), (Ts, Tc), (Th, Td), (Th, Tc), (Td, Tc), (9s, 9h), (9s, 9d), (9s, 9c), (9h, 9d), (9h, 9c), (9d, 9c), (8s, 8h), (8s, 8d), (8s, 8c), (8h, 8d), (8h, 8c), (8d, 8c), (7s, 7h), (7s, 7d), (7s, 7c), (7h, 7d), (7h, 7c), (7d, 7c), (6s, 6h), (6s, 6d), (6s, 6c), (6h, 6d), (6h, 6c), (6d, 6c), (5s, 5h), (5s, 5d), (5s, 5c), (5h, 5d), (5h, 5c), (5d, 5c), (8s, 9s), (8h, 9h), (8d, 9d), (8c, 9c)}

Notice that we are missing (4s, 4h). I think something is wrong with HandRange.fromCardPairs() function

Thank you!

HandRange code bug

Hi,

First of all, thank you for sharing this library. I am making an app using your library, and it helps a lot. I noticed there is a bug in your function HandRange.fromString()

For example, when I run, HandRange.fromString("AJo+"), I would expect "AhQs" to be in the range, but instead, I got this. I think there is a bug somewhere

AsJh
AsJd
AsJc
AhJs
AhJd
AhJc
AdJs
AdJh
AdJc
AcJs
AcJh
AcJd

I have a simple function like below

bool checkIfInRange(String cardPair, String range) {
  HandRange cardPairParsed = HandRange.fromString(cardPair);
  HandRange rangeParsed = HandRange.fromString(range);
  return rangeParsed.contains(cardPairParsed.first);
}

and if I run it like checkIfInRange("AhQs", "AJo+"), it will return false

Screenshot from Poker Equity
image

JS support issue of MadeHand.best(): when flutter code compiled to JS to run on Chrome or Edge browser

In a flutter application, when the device selected to run (in VS Code) is Chrome or Edge browser (web-javascript), the MadeHand.best() method return is not always right. Probably due to integer is 32 bit in JavaScript in browser and 64 bit in Dart/Flutter?

When device is browser, MadeHand.best() hand evaluation result is not consistent at all. For example,

  • cards 'QdKsQsJhTd9h8c' or 'KsQsJhTd9h' evaluated to be MadeHandType.fullHouse with a hashcode of 167
  • cards '6d2s4s5h3d' evaluated to be MadeHandType.fullHouse with a hashcode of 265
  • cards '6d2s4s5h3d2hQd' evaluated to be MadeHandType.trips with a hashcode of 2270
  • cards 'Ad2s4s5h3d2h2d' evaluated to be right as MadeHandType.straight with a hashcode of 1609, yet the 5 cards straight 'Ad2s4s5h3d' evaluated to be MadeHandType.fullHouse with a hashcode of 265

However, if device selected is a Android emulator (Pixel 6 API 29), all the above cards are correctly evaluated to be MadeHandType.straight.

A little more digging and I think the issue is in ImmutableCardSet class, where the _indexUnion probably should be fixnum:Int64 to be JS safe. Though JS number can be as large as 2^53-1, however, any bit operations in JS are operated on 32 bit int. So any bit operation on integer larger than 2^32-1 inside JS would cause issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.