Tuesday, April 19, 2011

Whence PQL?


"A-ha!" vs. "Ho-hum"

In the popular imagination, innovation comes from a flash of genius - a sudden, almost supernatural insight that often catches the inventor himself unawares. In reality, most innovation is far more mundane - small, incremental (and often obvious) improvements combine to make something new possible. Indeed, almost everything "new" on propokertools.com has found its genesis in incremental improvements - new games, graphs, and tools that build on what came before. After all, the very first version of propokertools.com was an answer to the question "What would an online version of PokerStove look like?"

PQL is the exception - it is the closest I've come to a "Eureka" moment yet.

Three as One

Here are three questions that have been answerable at one time or another via propokertools:
  • Given that player one has XX, player two has YY, and the board is ZZZ, what is the all-in equity for player one?
  • Given that player one has XX, player two has YY, and the board is ZZZ, how often does player one have at least two pair by the river?
  • Given that player one has XX, player two has YY, and the board is ZZZ, what does the graph of equities look like for player one?
Notice anything? These questions all have the same setup, namely "Given that p1 has ..., p2 has...". Let's call this the situation. After each situation, there is a question, which we can refer to as, well, the question. The three questions can all be rewritten as:
  • Given situation S, what is the answer to question Q?
In programmer-speak, we can say that we have abstracted out the concept of a situation and a question. This process of abstraction is one of the principal (some would say the principal) jobs of a programmer. And there is nothing particularly noteworthy about the abstraction above - any programmer worth her salt would spot it almost immediately.

Exposing the Abstraction

I spent a few weeks rewriting propokertools in December of 2010 (yes, all of propokertools (except for razz) got rewritten). One of the first things I did after throwing out several years' worth of accumulated cruft was to see how easy it would be to answer new poker questions with my re-written code. I began to write small programs to answer questions like "Given situation S, how often does player one win when he was an underdog before the flop?" and "Given situation R, how often is the winning hand a straight or better?". These programs were, for the most part, satisfyingly short and sweet. At first, I thought I would expose these little mini-programs as individual tools on the website. Then it hit me.

Why not let the users ask the questions?

Enter the DSL

"DSL" stands for "domain-specific language". A DSL is a language, usually small, used to describe a very particular area, or domain. For a somewhat contrived example of a DSL in action, one need only step up to the counter at a popular chain of coffee-shops during the morning rush. "Half-caf grande iced americano" means "using half regular beans and half decaffeinated beans, brew an espresso and dump it in a large to-go container, adding ice cubes and cold water." The key behind a successful DSL is that it is concise and unambiguous. An even more concise version of our coffee DSL can be seen behind the counter, as the people at the cash-registers write only a few characters of text on each coffee cup to completely describe what is to be brewed.

Another DSL you may be familiar with is the ProPokerTools "range of hands" DSL. For instance, in omaha, "AA**" means a hand with at least two aces in it.


Why Invent What You Can Steal?

To allow users to ask custom questions, I needed to create a new DSL. I had a number of requirements:
  • Need to be able to ask multiple questions
  • Need to be able to compose questions using boolean operators (such as AND, OR, and NOT)
  • Need to be able to fully describe the situation
  • Need a semantics that is easy to explain
As it happens, there is a language that has been used for decades in another domain that provides pretty much all of what we want. That language is SQL, or Structured Query Language. SQL is the industry-standard way to query databases. While the correspondence between SQL and our poker situation is not perfect, it is good enough, and given the availability of free tools around SQL, it became the obvious choice. Thus was born PQL - Poker Query Language.

Eating Your Own Dog Food

The most obvious way to make sure PQL was truly useful was to use it myself. As a result, all of the major features on the website and in the downloadable Odds Oracle are powered by PQL queries.

7 Comments:

At 6:42 AM, Anonymous Anonymous said...

This comment has been removed by the author.

 
At 6:46 AM, Anonymous Anonymous said...

Good post, helped me get my head around PQL a little better, I'm computer code illiterate.

More musings/tutorials/insights on the topic would be greatly appreciated.

 
At 11:06 PM, Blogger Edmond G. Belanger said...

Nice post

 
At 3:29 AM, Blogger Edmond G. Belanger said...

The power poker players had been novices once and now have honed their capacities in playing poker. Aside from taking in the tenets, techniques, wordings and achievement tips in poker, there are various advances worried in getting to be plainly successful poker players.I find www.metalcasinobonus.se this site for the best gaming and music, If you need you can visit this site.

 
At 11:25 PM, Blogger Unknown said...

I suppose I've selected an unbelievable and interesting blog.juegosdecasinoonlinecolombia.com.co

 
At 10:24 PM, Blogger Unknown said...

Artikel syang sangat bagus dan bermanfaat ini sangat membantu untuk pengetahuan untuk orang tang masih tidak tau

Kunjungi Situs Caramenangtaruhanbola.com Merupakan Website informasi judi online yang memberikan ulasan Situs Judi Online, Taruhan Bola, Poker Online, Dominoqq, Judi Togel, Agen Bola, Taruhan Bola Online, Cara menang Judi Bola di indonesia yang mengulas tips dan trik dalam bermain judi online.

Dominoq
Agen Bola
Trik Judi
Judi Togel
Panduan Judi
Poker Online
Informasi Judi
Info Judi Online
Review Bandar Judi
Review Bandar Judi Pokerqq
Review Bandar Judi Bola
Review Bandar Judi Togel
Cara Menang Judi Bola
Taruhan Bola Online
Cara Menang Taruhan Bola
Cara Menang Taruhan Bola Online
Cara Menang Taruhan Bola Poker Online
Cara Menang Taruhan Bola Judi Togel
Informasi Situs Judi
Info Situs Judi Bola Resmi
Informasi Situs Agen Sbobet
Info Bandar Bola Terpercaya
Info Bandar Judi Bola Online
Informasi Situs Judi Pokerqq
Info Situs Poker Online Resmi
Informasi Bandar Ceme Terbaik
Info Agen Judi Bola Terpercaya
Info Situs Judi Bola Terpercaya
Panduan Bermain Judi Bola Online
Informasi Agen IDN Poker Terpercaya
Informasi Situs Judi Qiu Qiu Online
Daftar Bandar Bola Online Terpercaya

 
At 1:11 AM, Blogger Casino-online.promo said...

If I had known before that you can raise a lot of money on online gambling, and at the same time have fun, I would have done this thing much earlier. Currently, he began to play Marathonbet Casino UK and is pleased with the game in slots. It happens that I win a big jackpot and it turned into a job, as I play and win every day. I like playing online poker there.

 

Post a Comment

<< Home