Reference for Scripted Tree Building

Scripted tree building in HRC is a powerful feature that enables users to create fully customized decision trees using simple scripts. This functionality streamlines the process of setting up calculations and reduces the need for manual pruning. Users can define spot-specific rules, such as opening sizes and calling options depending on position, separate sizings for squeeze spots, and custom postflop sizings based on stack-pot-ratio. Get started with provided example scripts and learn to customize them to suit your needs, or write your own scripts to create the perfect tree configurations for your poker analysis.

Scripted Tree Building

With the introduction of the postflop model, users started to really push the UI based tree setup in HRC to its limits. Scripted tree building allows full customization of the tree building process with the help of simple scripts. This feature is only available for Monte Carlo hands and only for users with a HRC Pro license.

Scripting can remove the need for excessive manual pruning after the tree creation. It also enables users to define their desired betting setup once and then re-use the script for any number of calculations.

Screenshot of Script Settings

The core idea is that users still configure the stacks, blinds and equity model via the user interface. However, instead of entering globally allowed raise sizes and flat calling options in the user interface, users can provide a script with spot-specific rules. The script has access to the full game state for each decision point, including all previous actions.

With access to the game state it's straightforward to implement rules that go beyond our UI capabilities, for example:

  • Define bet and raise sizes and calling options depending on the player's position
  • Configure various sizings postflop, depending on the effective stack-pot-ratio
  • etc.

Getting Started

Let's get the very first scripted build out of the way:

  • Start a new Advanced Monte Carlo hand.
  • Setup stacks in the 25-40bb range and select an equity model as usual.
  • Download the example script (Use right click: Save link as...)
  • Click Next to go to the bet sizing setup and select the Scripting tab.
  • Use the Open Script button and select the downloaded file.
  • HRC will automatically start to estimate the size of the resulting tree, updating the figures in the bottom table.
  • Wait until the estimate is done, then click Finish to actually create the tree.

Nice, you have created your first scripted tree!

This example features a generic 25-40bb MTT setup:

  • No limps, except for the SB who can complete
  • Multiple sizings for opening, 3-betting and squeezing
  • All 4-bets are all-in
  • Separate sizings for the blinds

Customizing the example

Don't get discouraged by the code, customizing the script is simple and doesn't require any coding skills.

You can use any text editor to customize the script. We can recommend Geany as a free and lightweight option that is available for Windows, OSX and Linux. Using Window's default text editor is also fine, but you won't have the colored syntax highlighting.

You already downloaded the example earlier, now let's open it in Geany. You should see the syntax colored similar to the "Show example source" option below. Focus on the first few lines where the sizes are defined, it's no more complicated than changing those values and saving the file. Then simply load the modified version in HRC, that's it!

Show example source


Additional examples

In this section we'll provide a selection of scripts for some common tree configurations. Check back here for updates and additional examples.

These scripts were created in collaboration with the HRC Discord Community, you can find additional examples pinned in the #scripting channel. Stop by if you have any scripting requests!

Advanced MTT example (no limping)

This script should be suitable for most stack sizes and is very flexible in the way it can be customized. The main restriction is that limps are generally not allowed, except for the small blind player who can complete.

Download mtt_advanced_20211029.js (Use right click: Save link as...)

View Source Code


Preflop:

  • Opening / 3-bet / squeeze sizes in big blinds
  • Configurable number of flats against opens / 3-bets / etc
  • Separate sizings for SB / BB
  • Sizing for 4-bets and 5-bets in relation to the pot IP & OOP
  • Option to disable cold calls against 3-bets+
  • Option to always allow flat calls if they close the action
  • Adding all-in if SPR is below a set value
  • All-in threshold like UI

Postflop:

  • Option to disable donk betting
  • Option to allow donk betting only if a player showed previous aggression
  • Option to force a checkdown for multiway pots after a set street
  • Option for additional pot-% sizings for all flop bets
  • Option for additional pot-% sizings only for flop c-bets
  • Adding all-in if SPR is below a set value

Advanced PKO example (with limps)

This is an extension of the previous example and has the option to allow one or more limps. This is likely to be most useful for bounty games.

The opening sizes can be adjusted based on the number of limpers and whether the raising player has position on all limpers. Since we are now dealing with a large number of possible opening sizes, using fixed 3-bet sizings is no longer suitable. Instead this script defines the 3-bet sizes as multiplicators of the previous raise.

Download pko_limps_20211206.js (Use right click: Save link as...)

View Source Code


Preflop:

  • Opening / 3-bet / squeeze sizes as multiplier of last raise
  • Configurable number of limps and flats against opens/3bets/etc
  • Option to allow SB completes in addition to the regular limping limit
  • Option to adjust opening sizes depending the number of limps
  • Separate sizings for SB / BB
  • Sizing for 4-bets and 5-bets in relation to the pot IP & OOP
  • Option to disable cold calls against 3-bets+
  • Option to always allow flat calls if they close the action
  • Adding all-in if SPR is below a set value
  • All-in threshold like UI

(Differences to the no-limp version in bold.)

Postflop:

  • Option to disable donk betting
  • Option to allow donk betting only if a player showed previous aggression
  • Option to force a checkdown for multiway pots after a set street
  • Option for additional pot-% sizings for all flop bets
  • Option for additional pot-% sizings only for flop c-bets
  • Adding all-in if SPR is below a set value

Simple Fixed Limit example

This simple script generates a Fixed Limit tree, implementing the fixed bet and raise sizings and the standard betting caps.

Download example_fixed_limit.js (Use right click: Save link as...)

View Source Code


By default this script only generates postflop lines for heads-up pots, this can be changed at line 37.

Writing your own scripts

To write your own scripts, some coding experience would be helpful. The scripts are written in JavaScript, but if you know any C-like language (C, C++, C#, Java,...) this should be sufficient. It's easiest to get started by adjusting / extending the example, we'll post additional ones soon.

Resources:

If you have any requests or problems with the scripting API then please let us know via discord in the #scripting channel. You can also post your custom scripts there if you need help.