JimViebke / IslandMUD

A C++ MUD
MIT License
9 stars 3 forks source link

Re-implement AI logic as a tree of objectives #221

Open JimViebke opened 8 years ago

JimViebke commented 8 years ago
class Objectives
{
private:
    std::shared_ptr<Objective> objective;
    std::vector<std::shared_ptr<Objectives>> child_objectives;

    bool is_leaf_node() const
    {
        return child_objectives.size() == 0;
    }

public:
    std::shared_ptr<Objective> get_leaf_objective()
    {
         return (is_leaf_node()) ? objective : child_objectives.back()->get_leaf_objective();
    }
};