Skip to main content

build_tree

Function build_tree 

Source
pub fn build_tree(cfg: &GameConfig) -> Result<Tree, TreeError>
Expand description

Builds the full betting tree for cfg.

The tree can grow very large; use build_tree_bounded for untrusted input.

§Examples

use native_solver::{build_tree, Card, Chips, GameConfig, Node};

let board = ["Ks", "Th", "7s", "4d"]
    .iter()
    .map(|card| card.parse())
    .collect::<Result<Vec<Card>, _>>()?;
let config = GameConfig::new(board, Chips::whole(100), Chips::whole(200)).with_bet_sizes([0.5]);
let tree = build_tree(&config)?;

// OOP acts first, and decision ids run from 0.
assert!(matches!(tree.root, Node::Decision { id: 0, .. }));
assert!(tree.num_decision_nodes > 0);

§Errors

Returns an error if the board is not a legal flop, turn, or river, the pot is not positive, the stack is negative, or a bet size is not a positive finite number.