Sub topic 9
Skill Trees and Skill Points
This chapter assumes you understand levels and can read short Python programs. It focuses on skill trees: collections of abilities that players buy with skill points. A skill point is a limited resource that lets a player learn one or more abilities.
A skill tree connects progression to player choice. Levels can give every player the same rewards, but a skill tree lets players shape a build. A build is the combination of abilities and bonuses a player chooses.
Model Skills as Nodes
Treat each skill as a node with a cost and prerequisites. A prerequisite is a skill that must be learned first. For example, a basic attack might unlock two advanced attacks. Those attacks might later unlock a powerful finishing move.
| Field | Purpose | Example |
|---|---|---|
| `cost` | Skill points required | `2` |
| `requires` | Skills that must already be learned | `["slash"]` |
| `effect` | Change made when the skill is active | `"+20% damage"` |
A skill should earn its place in the tree. Its effect should change how the player approaches combat, movement, exploration, or another important activity. A collection of small percentage bonuses can be useful, but it often produces less interesting decisions than distinct abilities.
Check Costs and Prerequisites
Keep the rules separate from the code that displays the tree. This makes balance changes easier. The following example stores the tree in a dictionary and checks whether a player can learn a skill.
SKILLS = {
"slash": {"cost": 1, "requires": []},
"whirlwind": {"cost": 2, "requires": ["slash"]},
"berserk": {"cost": 2, "requires": ["slash"]},
"execute": {"cost": 3, "requires": ["whirlwind", "berserk"]},
}
def can_learn(skill, learned, points):
node = SKILLS[skill]
return (
skill not in learned
and points >= node["cost"]
and all(required in learned for required in node["requires"])
)
learned = {"slash"}
points = 2
print(can_learn("whirlwind", learned, points)) # True
print(can_learn("execute", learned, points)) # FalseThe learned set prevents duplicate purchases. The all function requires every prerequisite, not merely one of them. In this example, the player must learn both branches before learning execute.
A common error is checking only the cost. That allows players to skip the intended order and can make high-tier abilities available too early. Another error is checking only the immediate parent when a skill has multiple prerequisites. Store all requirements and validate all of them.
Design the Choice
A meaningful choice has a real opportunity cost. If players can quickly buy every skill, the tree is only a menu. If one branch is always stronger, the tree has a correct answer rather than a choice.
Use branches to support different goals. One path might improve area damage, while another improves defense or mobility. Compare choices in actual play, not only in a spreadsheet. A weaker-looking skill may be valuable because it changes timing, positioning, or risk.
Decide how many points players receive and how often. Awarding points only at major levels makes choices easy to understand. Awarding points from several sources gives flexibility but requires careful tracking.
Exercise
A skill requires 3 points and two prerequisites. The player has 5 points but only one prerequisite. Should the game allow the purchase? Why?
Show answer
No. A valid purchase requires both enough points and every listed prerequisite. The player must learn the missing prerequisite first.