Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "draw_tree"
version = "0.9.0"
version = "0.9.1"
description = "Game tree drawing tool for extensive form games"
readme = "README.md"
requires-python = ">=3.10"
Expand Down
2 changes: 1 addition & 1 deletion src/draw_tree/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from extensive form (.ef) files, with support for Jupyter notebooks.
"""

__version__ = "0.9.0"
__version__ = "0.9.1"

from .core import (
draw_tree,
Expand Down
15 changes: 10 additions & 5 deletions src/draw_tree/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,18 @@ def _extract_action_label(move: str) -> str:
1. **Tilde-separated** (generated by ``gambit_layout_to_ef``):
``H~(\\frac{1}{2})`` → ``H``
2. **Raw label** (hand-written EF):
``\\frac{1}{3}`` → ``\\frac{1}{3}``
``\\frac{1}{3}`` → ``1/3``
"""
if not move:
return ""
# Split off chance probability annotation (tilde form)
parts = move.split("~", 1)
return parts[0]
label = parts[0]
m = _FRAC_RE.match(label)
if m:
sign = m.group(1)
return f"{sign}{m.group(2)}/{m.group(3)}"
return label


def _extract_chance_prob(move: str) -> str:
Expand Down Expand Up @@ -592,15 +597,15 @@ def _node_line(
# Terminal nodes
if iset is None:
return "t %s %s" % (
_q(n.nodeid),
_q(""),
_outcome_tail(n, outcome_num, n_players, zero_sum_expand),
)

first = id(iset) not in emitted_iset

if iset.player == 0:
# Chance node
head = "c %s %d" % (_q(n.nodeid), iset.id)
head = "c %s %d" % (_q(""), iset.id)
if first:
actions = " ".join(
"%s %s" % (_q(a), p)
Expand All @@ -614,7 +619,7 @@ def _node_line(
)

# Personal node
head = "p %s %d %d" % (_q(n.nodeid), iset.player, iset.id)
head = "p %s %d %d" % (_q(""), iset.player, iset.id)
if first:
actions = " ".join(_q(a) for a in iset.actions)
head += " %s { %s }" % (_q(""), actions)
Expand Down
Loading