Skip to content

Commit

Permalink
PyPoker-Eval compiled version for Py2.7 x64
Browse files Browse the repository at this point in the history
  • Loading branch information
Mudr0x authored Apr 18, 2023
1 parent c65b85c commit fc1f069
Show file tree
Hide file tree
Showing 41 changed files with 1,999 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packaging/windows/pypoker-eval-x64/CHANGES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Changes
=======

0.1.0 (2014-01-09)
------------------

- Package for pip installation (thanks Jim Kelly!)
- Package is called pokereval (thanks Jim Kelly!)
- Additional Card docs added (thanks Jim Kelly!)

0.0.2 (2012-12-02)
------------------

- Fix bug in 2-card hand evaluator
- Add quickstart (thanks arslr!)
- Support Python 2.6 (thanks again arslr!)
- Quick Start docs added (thanks again arslr!)

0.0.1 (2011-01-27)
------------------

- Nothing changed yet; initial public release
- We weren't even versioning at this point, ha
13 changes: 13 additions & 0 deletions packaging/windows/pypoker-eval-x64/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright (c) 2014 Alvin Liang

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
2 changes: 2 additions & 0 deletions packaging/windows/pypoker-eval-x64/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include *.txt
include *.rst
87 changes: 87 additions & 0 deletions packaging/windows/pypoker-eval-x64/PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
Metadata-Version: 1.0
Name: pokereval
Version: 0.2.0
Summary: A pure python poker hand evaluator for 5, 6, 7 cards
Home-page: https://github.com/aliang/pokerhand-eval
Author: Alvin Liang
Author-email: ayliang@gmail.com
License: Apache, see LICENSE.txt
Description: Poker Hand Evaluator
====================

In pure python

27 January 2011, Alvin Liang

Introduction
------------

This is a pure python library to calculate the rank of the best poker
hand out of 5, 6, or 7 cards. It does not run the board for you, or
calculate winning percentage, EV, or anything like that. But if you give
it two hands and the same board, you will be able to tell which hand
wins.

It is nowhere near as fast as pypoker-eval, but it works if you can't
use C for some reason (the early stages of the first MIT pokerbot
competition come to mind). The core algorithm is slower, and you
obviously don't have the speed of C.

Quick Start
-----------

.. code:: python

from pokereval.card import Card
from pokereval.hand_evaluator import HandEvaluator

hole = [Card(2, 1), Card(2, 2)]
board = []
score = HandEvaluator.evaluate_hand(hole, board)

Rank is 2-14 representing 2-A, while suit is 1-4 representing
spades, hearts, diamonds, clubs.

The Card constructor accepts two arguments, rank, and suit.

.. code:: python

aceOfSpades = Card(14, 1)
twoOfDiamonds = Card(2, 3)

Algorithm
---------

The algorithm for 5 cards is just a port of the algorithm that used to
be at the following URL. (I purposely broke the link because it now hosts
a malware site.)
httx://wwx.suffecool.net/poker/evaluator.html

I came up with the 6 and 7 card evaluators myself, using a very similar
card representation and applying some of the same ideas with prime
numbers. The idea was to strike a balance between lookup table size and
speed.

Also, I haven't included the code I used to generate the lookup tables,
but you should be able to do that with a simpler, slower algorithm.
Maybe I'll add that later as well.

There is also a two-card ranking/percentile algorithm that is unrelated
to the rest and may get cleaned up later. We used it at one point for
some pre-flop evaluation. Credit to Zach Wissner-Gross for developing
this.

Documentation is sparse at the moment, sorry about that, and obviously I
did not really bother to package it or clean it up. I may or may not
work on this in the future. Basically, I made it, so why not release it?

Contributors
------------

- Me! Go me!
- Zach Wissner-Gross (2-card algorithm)
- arslr (Fixes for other Python versions)
- Jim Kelly (Help with packaging, additional documentation)
- hwmrocker (Improvements to Card constructor, Python 3 compatibility)
- radekj (Tests, Python 3 compatibility)
Platform: UNKNOWN
78 changes: 78 additions & 0 deletions packaging/windows/pypoker-eval-x64/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
Poker Hand Evaluator
====================

In pure python

27 January 2011, Alvin Liang

Introduction
------------

This is a pure python library to calculate the rank of the best poker
hand out of 5, 6, or 7 cards. It does not run the board for you, or
calculate winning percentage, EV, or anything like that. But if you give
it two hands and the same board, you will be able to tell which hand
wins.

It is nowhere near as fast as pypoker-eval, but it works if you can't
use C for some reason (the early stages of the first MIT pokerbot
competition come to mind). The core algorithm is slower, and you
obviously don't have the speed of C.

Quick Start
-----------

.. code:: python
from pokereval.card import Card
from pokereval.hand_evaluator import HandEvaluator
hole = [Card(2, 1), Card(2, 2)]
board = []
score = HandEvaluator.evaluate_hand(hole, board)
Rank is 2-14 representing 2-A, while suit is 1-4 representing
spades, hearts, diamonds, clubs.

The Card constructor accepts two arguments, rank, and suit.

.. code:: python
aceOfSpades = Card(14, 1)
twoOfDiamonds = Card(2, 3)
Algorithm
---------

The algorithm for 5 cards is just a port of the algorithm that used to
be at the following URL. (I purposely broke the link because it now hosts
a malware site.)
httx://wwx.suffecool.net/poker/evaluator.html

I came up with the 6 and 7 card evaluators myself, using a very similar
card representation and applying some of the same ideas with prime
numbers. The idea was to strike a balance between lookup table size and
speed.

Also, I haven't included the code I used to generate the lookup tables,
but you should be able to do that with a simpler, slower algorithm.
Maybe I'll add that later as well.

There is also a two-card ranking/percentile algorithm that is unrelated
to the rest and may get cleaned up later. We used it at one point for
some pre-flop evaluation. Credit to Zach Wissner-Gross for developing
this.

Documentation is sparse at the moment, sorry about that, and obviously I
did not really bother to package it or clean it up. I may or may not
work on this in the future. Basically, I made it, so why not release it?

Contributors
------------

- Me! Go me!
- Zach Wissner-Gross (2-card algorithm)
- arslr (Fixes for other Python versions)
- Jim Kelly (Help with packaging, additional documentation)
- hwmrocker (Improvements to Card constructor, Python 3 compatibility)
- radekj (Tests, Python 3 compatibility)
Empty file.
33 changes: 33 additions & 0 deletions packaging/windows/pypoker-eval-x64/build/lib/pokereval/bug-1823.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#
# Copyright (C) 2007, 2008 Loic Dachary <loic@dachary.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
#
# http://gna.org/support/?1823
#
import sys
sys.path.insert(0, ".")
sys.path.insert(0, ".libs")

from pokereval import PokerEval

pokereval = PokerEval()

result = pokereval.poker_eval(game = "holdem", fill_pockets = 1, pockets = [ ["As", "3s"], ["__", "__"]], dead = [], board = ["Ad", "Qs", "2c", "Ac", "Kc"])
assert result == {'info': (990, 0, 1), 'eval': [{'winlo': 0, 'tielo': 0, 'winhi': 877, 'scoop': 877, 'loselo': 0, 'ev': 903, 'losehi': 78, 'tiehi': 35}, {'winlo': 0, 'tielo': 0, 'winhi': 78, 'scoop': 78, 'loselo': 0, 'ev': 96, 'losehi': 877, 'tiehi': 35}]}

result = pokereval.poker_eval(game = "omaha8", fill_pockets = 1, pockets = [ ["As", "3s", "2s", "6s"], ["__", "__", "__", "__"]], dead = [], board = ["Ad", "Qs", "2c", "7c", "5c"])
assert result == {'info': (123410, 1, 1), 'eval': [{'winlo': 109375, 'tielo': 5361, 'winhi': 73190, 'scoop': 69661, 'loselo': 8674, 'ev': 753, 'losehi': 48978, 'tiehi': 1242}, {'winlo': 8674, 'tielo': 5361, 'winhi': 48978, 'scoop': 8674, 'loselo': 68788, 'ev': 246, 'losehi': 73190, 'tiehi': 1242}]}

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import py_compile
py_compile.compile('pokereval.py')
Loading

0 comments on commit fc1f069

Please sign in to comment.