Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Introduction

Open PQL is a high-performance Rust implementation of the Poker Query Language (PQL), enabling SQL-like queries for poker probability analysis. It is a spiritual successor to the original Java implementation that powers Odds Oracle and propokertools.com.

⚠️ Work in Progress: this project is under active development. Public APIs, syntax, and supported features may change.

What is PQL?

PQL lets you ask poker questions in a declarative, SQL-like syntax:

select avg(equity(hero))
from   game='holdem', hero='AwAx', villain='*'

Read it as: “compute hero’s average all-in equity holding any pair of aces against a random hand in Hold’em.”

PQL is intended for people with a decent level of poker and technical sophistication who want to explore probability questions without writing custom programs.

What kinds of questions can PQL answer?

A few examples to give you the flavour:

Hero’s equity on a known flop against a tight range:

select equity(hero)
from   game='holdem', hero='AhKh', villain='QQ+', board='Ah9s2c'

How often hero flops a set with a small pair, given villain has any two cards:

select count(flopHandCategory(hero) = flopset) as pct_set
from   game='holdem', hero='TT', villain='*'

How often the river completes a monotone (single-suit) board:

select count(monotoneBoard(river)) as pct_monotone
from   game='holdem', hero='*', villain='*'

Why “PQL”?

The syntax is loosely based on SQL: it borrows SELECT, FROM, WHERE, AS, AND, OR, NOT, the comparison operators (=, <, <=, >, >=), arithmetic (+, -, *, /), and parentheses for grouping. If you’ve written SQL before, the shape will look familiar.

Workspace Crates

CratePurpose
openpql-preludeCore poker types: cards, hands, evaluators, game variants
openpql-coreGame abstraction and shared compute kernels
openpql-range-parserParser for the (generic) range notation, e.g. AwKw, 77-55
openpql-pql-parserParser for PQL syntax (LALRPOP grammar)
openpql-runnerQuery executor and the opql CLI
openpql-macroInternal procedural macros for function registration

How to Read This Book

Try It Online

An interactive demo is available at https://pql-playground.solve.poker.