Skip to content

Releases: IRLL/HEB_graphs

🎉 Cut looping behaviors

04 Feb 19:17
Compare
Choose a tag to compare

Add boolean option to cut looping behaviors and redirect them to alternatives.

Examples:

Uncutted

unrolled_graph = unroll_graph(gather_wood.graph)

GatherWood

Cutted

unrolled_graph = unroll_graph(gather_wood.graph, cut_looping_alternatives=True)

GatherWoodCut

Uncutted

unrolled_graph = unroll_graph(get_new_axe.graph)

GetNewAxe

Cutted

unrolled_graph = unroll_graph(get_new_axe.graph, cut_looping_alternatives=True)

GetNewAxeCut

🎉 Unrolling looping behaviors

03 Feb 18:50
Compare
Choose a tag to compare

We can now unroll looping behaviors like in this example:

class GatherWood(Behavior):
    """Gather wood"""

    def __init__(self) -> None:
        """Gather wood"""
        super().__init__("Gather wood")

    def build_graph(self) -> HEBGraph:
        graph = HEBGraph(self)
        feature = FeatureCondition("Has an axe")
        graph.add_edge(feature, Action("Punch tree"), index=False)
        graph.add_edge(feature, Behavior("Get new axe"), index=False)
        graph.add_edge(feature, Action("Use axe on tree"), index=True)
        return graph


class GetNewAxe(Behavior):
    """Get new axe with wood"""

    def __init__(self) -> None:
        """Get new axe with wood"""
        super().__init__("Get new axe")

    def build_graph(self) -> HEBGraph:
        graph = HEBGraph(self)

        feature = FeatureCondition("Has wood")
        graph.add_edge(feature, Behavior("Gather wood"), index=False)
        graph.add_edge(feature, Action("Craft axe"), index=True)
        return graph
 
def build_looping_behaviors() -> List[Behavior]:
    behaviors: List[Behavior] = [GatherWood(), GetNewAxe()]
    all_behaviors = {behavior.name: behavior for behavior in behaviors}
    for behavior in behaviors:
        behavior.graph.all_behaviors = all_behaviors
    return behaviors

GatherWood
GetNewAxe

🚑 Hotfix draw_networkx_nodes_images

03 Feb 02:27
Compare
Choose a tag to compare

🚑 Hotfix allow draw_networkx_nodes_images to draw even if some nodes miss an image.

Full Changelog: 0.2.1...0.2.2

📝& 🎨 Documentation & Colored Textboxes

23 Jan 02:14
ece34bf
Compare
Choose a tag to compare

Changes:

  • 🎨 Add colored textboxes when drawing HEBGraph without images
  • 🐛 Fix infinite looping due to missing check when computing histograms
  • 📝 Add unrolling example and explanation in README

🎉 First HEBG Release

23 Jan 00:23
Compare
Choose a tag to compare

This is the first release of the HEBG package.

This package is meant to build programmatic Hierarchical Explanable Behaviors as Graphs to compare them to human explanations of behavior. Taking the definition of "behavior" as a function from observation to action.

Features

  • Creation of HEBGraph object using the three available types of nodes: Action, FeatureCondition and Behavior.
  • Using HEBGraph objects as functional behaviors, calling them with an observation will return the action based on the graph.
  • Creation of Hierarchical Behaviors: a Behavior with it's own HEBGraph can be used in an other Behavior HEBGraph.
  • Unrolling of a hierarchical HEBGraph, to recursively transform each behavior Node in a graph to it's own subgraph if available.
  • Code generation from HEBGraph.