Skip to content

1.0 Quick Guide

Julio Toboso edited this page Oct 24, 2026 · 3 revisions

Quick Guide

The core idea

A hero is one character. Over a game she becomes a Human, a Wizard, a Fighter, an Alchemist... She stays the same hero. In TOP you write each of those meanings as a Tag, and you may apply Tags to any object as you see fit. The object keeps its identity. Its meaning grows.

Assume we have this class defined for our examples:

from TopKit import *

class Character:
    """The host: made with ordinary Python objects.
       TOP never changes its identity."""

    def __init__(self, name, level=1):
        self.name = name
        self.level = level
---
title: Ari
---
swimlane-beta TD
    subgraph Character
        name["name: Ari"]
        level["level: 3"]
    end
Loading

A Tag is a category.

Applying a Tag means membership, identity, belonging...

Tagging an object always means membership to the category stablished by the tag.

class Hero(Tag):
    pass

ari = Character("Ari", level=3)
Hero(ari)

assert ari in Hero     # Ari is a Hero now
assert Hero            # "is there any Hero?" (yes)
for h in Hero:         # Let's print all the heroes
   print(h.name)       
---
title: Ari
---
swimlane-beta TD
    subgraph Hero
        hero_field(("Hero ∋ ari"))
    end

    subgraph Character
        name["name: Ari"]
        level["level: 3"]
    end
Loading

An empty Tag is already useful for classification. It defines a category and a population.

A living and instantiated Hero Tag is a also called an Agency or Organization, not a Class. An Agency is considered active (assert Hero) if it contains at least one member, called an Agent. Any object can be targeted by a Tag (Hero(ari)), and if it does join the agency it becomes a member, which validates the membership check (assert ari in Hero). The set of Agents of a certain Tag is called a Field. There are many utilities that arise from managing fields. For starters, you kan keep tabs of every active Agent (print(Hero)=>Hero:{ari}).

Clone this wiki locally