Tylder / OMPEval_py_wrapper

Python wrapper for OMPEval

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OMPEval Python Wrapper

Gitter

CI status
MSVC 2015 AppVeyor
conda.recipe Conda Actions Status
pip builds Pip Actions Status
cibuildwheel Wheels Actions Status

Python wrapper for the excellent C++ Poker hand evaluator and equity calculator OMPEval https://github.com/zekyll/OMPEval

Prerequisites

On Unix (Linux, OS X)

  • A compiler with C++11 support
  • CMake >= 3.4 or Pip 10+
  • Ninja or Pip 10+

On Windows

  • Visual Studio 2015 or newer (required for all Python versions, see notes below)
  • CMake >= 3.8 (3.8 was the first version to support VS 2015) or Pip 10+

Installation

Just clone this repository and pip install. Note the --recursive option which is needed for the pybind11 submodule:

git clone --recursive https://github.com/Tylder/OMPEval_py_wrapper.git
pip install ./OMPEval_py_wrapper

With the setup.py file included in this example, the pip install command will invoke CMake and build the pybind11 module as specified in CMakeLists.txt.

Special notes for Windows

Compiler requirements

Pybind11 requires a C++11 compliant compiler, i.e Visual Studio 2015 on Windows. This applies to all Python versions, including 2.7. Unlike regular C extension modules, it's perfectly fine to compile a pybind11 module with a VS version newer than the target Python's VS version. See the FAQ for more details.

Runtime requirements

The Visual C++ 2015 redistributable packages are a runtime requirement for this project. It can be found here. If you use the Anaconda Python distribution, you can add vs2015_runtime as a platform-dependent runtime requirement for you package: see the conda.recipe/meta.yaml file in this example.

Building the documentation

Documentation for the example project is generated using Sphinx. Sphinx has the ability to automatically inspect the signatures and documentation strings in the extension module to generate beautiful documentation in a variety formats. The following command generates HTML-based reference documentation; for other formats please refer to the Sphinx manual:

  • cd OMPEval_py_wrapper/docs
  • make html

License

Pybind11 is provided under a BSD-style license that can be found in the LICENSE file. By using, distributing, or contributing to this project, you agree to the terms and conditions of this license.

Example

import ompeval

ranges = [
    ompeval.CardRange("AK"),
    ompeval.CardRange("random"),
]
board = ompeval.CardRange.getCardMask(text="")
dead = ompeval.CardRange.getCardMask(text="")

eq = ompeval.EquityCalculator()
eq.set_hand_limit(10**6) # 1 million hands
# eq.set_time_limit(0.02) # Could set a time limit as well, in seconds

eq.start(hand_ranges=ranges, board_cards=board, dead_cards=dead, enumerate_all=False)
eq.wait()

res = eq.get_results()

About

Python wrapper for OMPEval

License:Other


Languages

Language:Python 48.1%Language:C++ 42.8%Language:CMake 9.1%