{ "info": { "author": "Will Drevo", "author_email": "", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "Intended Audience :: Education", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Topic :: Games/Entertainment" ], "description": "Treys\n=====\n\nA pure Python poker hand evaluation library\n\n::\n\n [ 3 \u2764 ] , [ 3 \u2660 ]\n\nInstallation\n------------\n\n::\n\n $ pip install treys\n\nImplementation notes\n--------------------\n\nTreys is a Python 3 port of\n`Deuces `__. Most of work is taken\nfrom `msaindon\u2019s `__ fork.\n\nTreys (originally Deuces) was written by `Will\nDrevo `__ for the MIT Pokerbots Competition. It\nis lightweight and fast. All lookups are done with bit arithmetic and\ndictionary lookups. That said, Treys won\u2019t beat a C implemenation (~250k\neval/s) but it is useful for situations where Python is required or\nwhere bots are allocated reasonable thinking time (human time scale).\n\nTreys handles 5, 6, and 7 card hand lookups. The 6 and 7 card lookups\nare done by combinatorially evaluating the 5 card choices.\n\nUsage\n-----\n\nTreys is easy to set up and use.\n\n.. code:: python\n\n >>> from treys import Card\n >>> card = Card.new('Qh')\n\nCard objects are represented as integers to keep Treys performant and\nlightweight.\n\nNow let\u2019s create the board and an example Texas Hold\u2019em hand:\n\n.. code:: python\n\n >>> board = [\n >>> Card.new('Ah'),\n >>> Card.new('Kd'),\n >>> Card.new('Jc')\n >>> ]\n >>> hand = [\n >>> Card.new('Qs'),\n >>> Card.new('Th')\n >>> ]\n\nPretty print card integers to the terminal:\n\n::\n\n >>> Card.print_pretty_cards(board + hand)\n [ A \u2764 ] , [ K \u2666 ] , [ J \u2663 ] , [ Q \u2660 ] , [ T \u2764 ] \n\nIf you have `termcolor `__\ninstalled, they will be colored as well.\n\nOtherwise move straight to evaluating your hand strength:\n\n.. code:: python\n\n >>> from treys import Evaluator\n >>> evaluator = Evaluator()\n >>> print(evaluator.evaluate(board, hand))\n 1600\n\nHand strength is valued on a scale of 1 to 7462, where 1 is a Royal\nFlush and 7462 is unsuited 7-5-4-3-2, as there are only 7642 distinctly\nranked hands in poker. Once again, refer to my blog post for a more\nmathematically complete explanation of why this is so.\n\nIf you want to deal out cards randomly from a deck, you can also do that\nwith Treys:\n\n.. code:: python\n\n >>> from treys import Deck\n >>> deck = Deck()\n >>> board = deck.draw(5)\n >>> player1_hand = deck.draw(2)\n >>> player2_hand = deck.draw(2)\n\nand print them:\n\n::\n\n >>> Card.print_pretty_cards(board)\n [ 4 \u2663 ] , [ A \u2660 ] , [ 5 \u2666 ] , [ K \u2663 ] , [ 2 \u2660 ]\n >>> Card.print_pretty_cards(player1_hand)\n [ 6 \u2663 ] , [ 7 \u2764 ] \n >>> Card.print_pretty_cards(player2_hand)\n [ A \u2663 ] , [ 3 \u2764 ] \n\nLet\u2019s evaluate both hands strength, and then bin them into classes, one\nfor each hand type (High Card, Pair, etc)\n\n.. code:: python\n\n >>> p1_score = evaluator.evaluate(board, player1_hand)\n >>> p2_score = evaluator.evaluate(board, player2_hand)\n >>> p1_class = evaluator.get_rank_class(p1_score)\n >>> p2_class = evaluator.get_rank_class(p2_score)\n\nor get a human-friendly string to describe the score,\n\n::\n\n >>> print(\"Player 1 hand rank = %d (%s)\\n\" % (p1_score, evaluator.class_to_string(p1_class)))\n Player 1 hand rank = 6330 (High Card)\n\n >>> print(\"Player 2 hand rank = %d (%s)\\n\" % (p2_score, evaluator.class_to_string(p2_class)))\n Player 2 hand rank = 1609 (Straight)\n\nor, coolest of all, get a blow-by-blow analysis of the stages of the\ngame with relation to hand strength:\n\n::\n\n >>> hands = [player1_hand, player2_hand]\n >>> evaluator.hand_summary(board, hands)\n\n ========== FLOP ==========\n Player 1 hand = High Card, percentage rank among all hands = 0.893192\n Player 2 hand = Pair, percentage rank among all hands = 0.474672\n Player 2 hand is currently winning.\n\n ========== TURN ==========\n Player 1 hand = High Card, percentage rank among all hands = 0.848298\n Player 2 hand = Pair, percentage rank among all hands = 0.452292\n Player 2 hand is currently winning.\n\n ========== RIVER ==========\n Player 1 hand = High Card, percentage rank among all hands = 0.848298\n Player 2 hand = Straight, percentage rank among all hands = 0.215626\n\n ========== HAND OVER ==========\n Player 2 is the winner with a Straight\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ihendley/treys", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "treys", "package_url": "https://pypi.org/project/treys/", "platform": "", "project_url": "https://pypi.org/project/treys/", "project_urls": { "Homepage": "https://github.com/ihendley/treys" }, "release_url": "https://pypi.org/project/treys/0.1.3/", "requires_dist": null, "requires_python": "", "summary": "treys is a pure Python poker hand evaluation library", "version": "0.1.3" }, "last_serial": 4190800, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "3829a8c5455c539af7102724e5a5df32", "sha256": "e193c2a2daf37a56be44bc36aec5b44018765f8d4b5d8221f551007aed66452d" }, "downloads": -1, "filename": "treys-0.1.tar.gz", "has_sig": false, "md5_digest": "3829a8c5455c539af7102724e5a5df32", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10167, "upload_time": "2017-12-11T10:11:22", "url": "https://files.pythonhosted.org/packages/98/3f/3ea770807fe37a9627d2bdca87c6c8254cac3d6694ed9d70e8597938efa3/treys-0.1.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "ccbe05f2fc6b664d133d5a80b1fcd99a", "sha256": "5e37886499b039a8fc536b7dcedbcee6fbf057bb83576cea7e214810e0eb7145" }, "downloads": -1, "filename": "treys-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "ccbe05f2fc6b664d133d5a80b1fcd99a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10786, "upload_time": "2018-08-21T02:53:25", "url": "https://files.pythonhosted.org/packages/6d/bd/62a04aa40980ff9f63eda8addcbeb75752064953111d5dbc2ed1ec386989/treys-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d871bc5aafc640a62ca41e675bafe2de", "sha256": "98a3511546cb00a7852a5114ba0754159dfa191a7b8a03fa52564933fbff7d25" }, "downloads": -1, "filename": "treys-0.1.3.tar.gz", "has_sig": false, "md5_digest": "d871bc5aafc640a62ca41e675bafe2de", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10524, "upload_time": "2018-08-21T02:53:27", "url": "https://files.pythonhosted.org/packages/8e/b9/b537686078c938e0c5d59c707d002d3ffa843f0cf1a7578a2872b56cb2cd/treys-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ccbe05f2fc6b664d133d5a80b1fcd99a", "sha256": "5e37886499b039a8fc536b7dcedbcee6fbf057bb83576cea7e214810e0eb7145" }, "downloads": -1, "filename": "treys-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "ccbe05f2fc6b664d133d5a80b1fcd99a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10786, "upload_time": "2018-08-21T02:53:25", "url": "https://files.pythonhosted.org/packages/6d/bd/62a04aa40980ff9f63eda8addcbeb75752064953111d5dbc2ed1ec386989/treys-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d871bc5aafc640a62ca41e675bafe2de", "sha256": "98a3511546cb00a7852a5114ba0754159dfa191a7b8a03fa52564933fbff7d25" }, "downloads": -1, "filename": "treys-0.1.3.tar.gz", "has_sig": false, "md5_digest": "d871bc5aafc640a62ca41e675bafe2de", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10524, "upload_time": "2018-08-21T02:53:27", "url": "https://files.pythonhosted.org/packages/8e/b9/b537686078c938e0c5d59c707d002d3ffa843f0cf1a7578a2872b56cb2cd/treys-0.1.3.tar.gz" } ] }