Managing a World of Entities in XNA

A structure that I find works very well when managing entities in games is the world/entity/component pattern. Entities in the world are nothing more than collections of components, where the components have the responsibility to "do something" with the entity. The Entity just gives you a convenient place for common information (global transform, say), and specialized data goes into each component.

This way, you can compose components for different behaviors (rendering, audio, animation, user control, AI, explosions, particle systems, etc) and create entirely new kinds of entities out of an existing palette of components.

class World {
  List<Entity> entities_ = new List<Entity>();
  List<Entity> toAdd_ = new List<Entity>();
  List<Entity> toRemove_ = new List<Entity>();
  public World() {}
  public void AddEntity(Entity ent) {
    toAdd_.Add(ent);
  }
  public void RemoveEntity(Entity ent) {
    toRemove_.Add(ent);
  }
  public void Update() {
    int i = 0, n = toAdd_.Count;
    for (; i != n; ++i) {
      Entity ent = toAdd_[i];
      entities_.Add(ent);
      ent.OnAttach(this);
    }
    toAdd_.RemoveRange(0, n);
    i = 0; n = toRemove_.Count;
    for (; i != n; ++i) {
      Entity ent = toRemove_[i];
      entities_.Remove(ent);
    }
    for (i = 0, n = entities_.Count(); i != n; ++i)
      entities_[i].Update();
  }
}
 
class Component {
  string id_;
  protected Entity entity_;
  public Component(string id) {
    id_ = id;
  }
  public string ID { get { return id_; } }
  public Entity Entity { get { return entity_; } }
  internal void OnAttach(Entity ent) {
    entity_ = ent;
    LocalSetup();
  }
  protected virtual void LocalSetup() {}
  internal void Update() {
    LocalUpdate();
  }
  protected virtual void LocalUpdate() {}
}
 
class Entity {
  World world_;
  List<Component> components_ = new List<Component>();
  public Entity() {
  }
  public void AddComponent(Component comp) {
    components_.Add(comp);
    if (world_ != null)
      comp.OnAttach(this);
  }
  internal void OnAttach(World world) {
    world_ = world;
    for (int i = 0, n = components_.Count; i != n; ++i)
      components_[i].OnAttach(this);
  }
  public Component FindComponent(string id) {
    for (int i = 0, n = components_.Count; i != n; ++i)
      if (components_[i].ID == id) {
        return components_[i];
  }
  internal void Update() {
    for (int i = 0, n = components_.Count; i != n; ++i)
      components_[i].OnUpdate();
    if (pos_ != newPos_) {
      pos_ = newPos_;
      if (OnMoved != null)
        OnMoved(this, newPos_);
    }
  }
  internal Vector3 newPos_;
  internal Vector3 pos_;
  public Vector3 Position { get { return pos_; } set { newPos_ = value; } }
  public event EntityMoved OnMoved;
}
public delegate void EntityMoved(Entity ent, Vector3 pos);
 
 
class RenderableComponent : Component, SceneGraphNode {
  SceneGraphModel model_;
  public RenderableComponent(string model)
    : base("renderable")
  {
    model_ = SceheGraphModelLoader.Load(model);
  }
  internal override void LocalSetup() {
    Entity.OnMoved += new EntityMoved(this.Moved);
  }
  void Moved(Entity ent, Vector3 pos) {
    SceneGraph.NodeMoved(this, pos);
  }
  // an assumed callback from your scene graph
  public overrid void DrawSceneGraphNode(DrawInfo info) {
    model_.Draw(info);
  }
}
 
class ControllableComponent : Component {
  // Let's assume "Controller" is your controller wrapper.
  Controller controller_;
  public ControllableComponent(PlayerIndex player) {
    controller_ = Controller.ForPlayer(player);
  }
  public override void LocalUpdate() {
    if (controller_.Gas) {
      Entity.Position = Entity.Position + Vector3.Forward;
    }
    if (controller_.Right) {
      Entity.Position = Entity.Position + Vector3.Right;
    }
    if (controller_.Left) {
      Entity.Position = Entity.Position + Vector3.Left;
    }
  }
}
 
void Setup()
{
  // create a world
  world_ = new World();
  // create a track
  track_ = new Entity();
  track_.AddComponent(new RenderableComponent("trackmodel"));
  world_.AddEntity(track_);
  // create a mover
  mover_ = new Entity();
  mover_.AddComponent(new RenderableComponent("movermodel"));
  mover_.AddComponent(new ControllableComponent(PlayerIndex.One));
  world_.AddEntity(mover_);
}
 
void Update()
{
  // automatically update all entities in the world
  world_.Update();
}
 
void Render()
{
  // let's assume you have a scene graph...
  SceneGraph.Render();
}

Comments

Small Example

This was a great read. I really love the idea, but I really can't envisage how this would really work in practice.
It would be great if you ever found the time to release a small example game.

Also do you find this works well for most game types, including puzzle games for example?
Would you use an entity (or possibly a component) for score, health, UI type things or just 'physical' type things?
If you did have a 2d entity system for health, score, whatever, how would the players main entity interact with them?

Really glad I found your article and this site. Thanks for sharing!

Understanding Your Code

I like your example here of the component entity system which is a design pattern I'm trying to use in my own project, but there are some areas of your code that don't make sense. I'm hoping you can fill in some of the blanks for me.

First, how are the Entity and Component classes relating to eachother? Shouldn't the Entity class implement the Component class? Because if it doesn't, like you have in your code, the OnAttach() method in the Component class would not be able to take an Entity object passed to it, like you have in the Entity class. You are passing 'this' (components[i].onAttach(this);) where 'this' is the Entity class, but that method takes a Component object, so I really dont see how this will work unless Entity implements Component.

Next, in the RenderableComponent class, you implement a SceneGraphNode. Where is this class? Is there a using statement that is missing or is this a custom class?

Lastly, the line under the Entity class: public delegate void EntityMoved(Entity ent, Vector3 pos);

Does this line belong with the Entity class? Should it reside outside of the class but in the same .cs file?

Thanks!

-Josh

jwatte's picture

Thanks for your

Thanks for your comments!

First -- the code is probably more like pseudo-code than a ready-to-go library you can paste-and-use. It's used to illustrate the concept; you are intended to learn from this and implement it yourself in whatever way suits your engine.

That being said, I don't see where the type problem comes from. The World calls OnAttach() on Entity, passing in the World. The Entity calls OnAttach() on the Component, passing in the Entity. In each case, the function in question seems to be taking the right type argument.

Second, there is no standard SceneGraphNode class -- it just suggests how you can integrate a separate scene graph with a component-based entity system. Specifically, you do *not* want a system where each Entity (or, worse, Component) gets a callback to render each frame, whether they want it or not.

Finally, I believe delegate types can be members of classes as well as members of name spaces. To use them, qualify them like any other class scoped type, with the class name.

Hi, I have another

Hi, I have another question...and its very noob one...
I read the comments and people say that this code works very well with interfaces. But I am not sure why and where would I use them here? I just barely done a few outside tutorials of interfaces so I do not completely understand their usefullness.. is it just to hide some class functionality or there is something else to it? Ive implemented your example in my game code and it seems to work (have not compiled it yet) but I like the code structure more then that of inheritance. Where would I use an interface here?

How can I search components

How can I search components by type? Ive been looking everywhere but could not find it.

I need something like:

Find(ComponentType type)
{
foreach (Component c in components)
{
if (c.GetType() == type) return c;
}
}
but I could not figure out how to pass type as a reference to function.

Another minor question is why are you using iterators like that? Isnt it easier to just use "foreach" statement?

Thanks,
Cheb

jwatte's picture

An interface is a contract.

An interface is a contract. It specifices what functionality a given object will provide a caller, without specifying anything about how it will do that. Interfaces bring along no "baggage" other than the function names and signatures. An object can implement any number of interfaces, and you can cast an object instance to any of these interface types. Thus, an object can be both an ITimeListener and an ITargetable and a IHeatSignature, for example.

By contrast, inheritance in C# (or Java) only allows you to derive from a single base class, and brings along all the baggage of whatever went into implementing the superclass.

In C++, you will see interfaces referred to as "pure abstract base classes" (PABC), which are used in the same way, for the same reasons.

jwatte's picture

Just pass a Type object, and

Just pass a Type object, and use Type.IsAssignableFrom() on component.GetType() to test for compatibility. This allows you to ask for specific interfaces, too.

One way of doing this is with generics. If memory serves:

  T FindComponent<T>() {
    Type t = typeof(T);
    foreach (Component c in components_) [
      if (t.IsAssignableFrom(c.GetType())) {
        return (T)c;
      }
    }
    return null;
  }

The integer iterators mean that you can mutate the lists while iterating without throwing. That might be useful in the case of, for example, updating all the components letting a component add another component, but might also be quite dangerous, so don't feel any particular need to emulate that style :-)

1 to 1 relationship: Subsystem to Component Type

What are your thoughts on an entity only consisting of an ID, where the components that define its behavior are not added to the entity but instead to a matching subsystem (i.e. health component adds to health subsystem, pizza-making component to a pizza-making subsystem)? In this scenario, the subsystem maintains a homogeneous dictionary of that particular type of component indexed by the entity ID. Components then would only be data containers, where the actual methods would reside in the subsystem, which would perform operations on its components in a uniform fashion. I've read about this architecture in a few places and have even tried to implement it myself but it seems a little tedious to continually have to make a new component AND subsystem any time I wanted to create a new behavior.

I also have one other question -- from what I understand from your post is that components on the same entity communicate with each other by obtaining a pointer to one another in the OnAttached() method, thus by definition creating dependencies between each other's existence. Doesn't that make components more rigid? How would one add a component to an entity on the fly during a game if the entity didn't have the other requisite component? What about components who rely on the logic of another component in another entity? Is there a messaging system of some kind at work?

jwatte's picture

Sorry I'm late to reply. The

Sorry I'm late to reply.

The problem with "the health subsystem" and "the pizza-making subsystem" is that you have to know what the subsystems are beforehand. Yes, I've also heard of this -- there are game engines that have 50 different pointers in their "struct Entity," and a pointer is either NULL, or points to a known species of subsystem (particle system, collision generator, or whatnot). It's a more pragmatic way to get something done as long as you control the entire code base, but if you want to support plug-ins, or use the code base across parallel projects, it might get in the way.

When it comes to pointers vs messages, in either case, if the recipient isn't there, whatever you intended to happen won't happen. Testing for NULL can happen in the caller of a function, or in a message dispatcher finding nobody is subscribed. The difference is not earth-shattering (although function calls allow function return values).

To add two mutually co-dependent components (I've actually done this), I would suspend the entity, add both components, and then resume the component; suspending detaches components and resuming re-attaches components. Thus, they will find each other in the onattach callback.
Although mutual dependence is generally a design problem -- perhaps you should merge them, or find a third common component to both depend on, or break the cycle some other way.

Am I wrong here?

"Yes, I've also heard of this -- there are game engines that have 50 different pointers in their 'struct Entity,' and a pointer is either NULL, or points to a known species of subsystem (particle system, collision generator, or whatnot)."

Hmmm, I don't think this is what he's referring to. I'm researching the same method, and to the best of my knowledge, the entity class or struct doesn't need any pointers to anything whatsoever. Technically speaking, there doesn't even need to be an entity object. It can be purely conceptual, only becoming cohesive through the effects of your subsystems.

I.E. A location component storing your x,y,z coordinates, which is processed by the movement subsystem. Anything that needs to be communicated from the movement subsystem to another subsystem, for example the animation subsystem, would be done by raising an event through the subsystem controller. The animation subsystem would then pick up that event at the beginning of its loop, which would contain the GUID representing the conceptual entity, and do whatever it needed to do.

You really wouldn't have to know what subsystems you need beforehand, just what events are relevant. When creating your movement subsystem, you know other subsystems will need to know when collisions occurr, etc., so you create events for them. Later on, when you're designing other subsystems, they can pick up those events and figure out what to do with them.

At least that's how I personally understand the theory behind Entity Systems. The entity is literally just a (conceptual) collection of components. The components are processed by independent subsystems, along with any events that might be generated (or not) from other subsystems. So in theory you could add a Location component, but no Drawing component, and there wouldn't be any problems other than that your conceptual entity wouldn't be drawn. It would have a location and it would still be able to move.

This also means that you wouldn't have to loop through a list of entities and run a centralized Update method that checks for the presence of components. Each subsystem would contain its own list of relevant components, looping only through those, and only doing so only as often as that subsystem requires. Each subsystem's main loop could reside in its own thread, so you wouldn't have to worry about one subsystem bogging down another, and there wouldn't be (m)any horribly confusing resource locks to worry about.

AI picks up events from the controller and does its thing, while movement and drawing are simultaneously doing their own thing. You can add and remove any component from any entity on the fly, without having to hardcode any of the possibilities. Creating an invisible portal controlled by the user that can be used as a healing item is as easy as adding the appropriate components, and it's all handled in a nicely multi-threaded fashion that can take advantage of almost as many processor cores as you throw at it.

jwatte's picture

Well, at that point, your

Well, at that point, your "entity" instead exists as a number of cross-pointers (explicit or implicit) through the systems. Some animation instance knows to listen to "position changed" messages for ID 1234. The problem with broadcast systems is that messages can become a bottleneck. If you have 1,000 NPCs moving, the movement controller of each of which is sending a "I moved" message, then 1,000 animations need to filter 1,000 "I moved" messages each just to get the right message. With pointers, you cut down N-squared to the optimal N. There's also the question about how this object dies -- everything needs to hear about "entity 1234 died" so it can remove itself from the world.

There's another option where the ID of each subcomponent is the ID of the entity. That draw-back is that there can only be one sub-component per entity. When an entity dies, all subsystems remove component ID 1234 if it exists. Sparse arrays of components (really, hash tables from ID to component instance) make this reasonably efficient. You then also don't need to broadcast messages; instead you can have whomever needs the data from somewhere else, poll from that somewhere else. Animation need position? Ask the position manager for the value of instance 1234, should it exist. Hash table look-ups are slower than pointers, but only by a linear factor 3 or so.

Integrating GameScreens / GameStates

I'm having a great time working with a version of this system and am wondering how you would go about integrating different game states? Would each state be considered a "World" with its own collection of entities and have its own respective update and draw methods called by a manager class of some sort when it is the active state?

jwatte's picture

What is a "game state"? A

What is a "game state"? A different level? A different game mode? (multiplayer deathmatch vs capture-the-flag vs singleplayer story)?

For a different level, I would dispose all the content (in the XNA content manager), throw away the current world (let GC take care of it), and load a new world fresh with new data.

For a different game mode, when it's networked vs not, that typically goes into another abstraction (like input, say), although I can see how you could allow modes to affect all object creation. For example, the network manager could add a networking component to any object that gets added to the world, if it's an object it cares about.

To clarify =)

I was thinking along the lines about how to integrate the Game State Management example on the creators club website (i.e. screen manager, pushing and popping scenes to determine which one needs updating / drawing). At the most basic level, I'm trying to figure out how to connect my game world to some simple screens, to create a flow like this:

Title Screen --- > (options screen?) --> start the game (this currently is my World class with a list of all the world's entities, Update, Draw methods) --- > pause screen ---> game over screen.

Given the context of the Component-Entity-World archetecture, would I work to integrate these screens in as components within a world or would they be their own abstractions outside of the Entity system?

jwatte's picture

I would treat screens as

I would treat screens as something separate from entities. There would be a "world runner" screen which would create the world, load a level of entities into it, step physics etc.

Communication

And how do you handle communication like AI wants to move unit closer to the enemy? Where would you put it? In unit's class or separate class?

One option would be to have

One option would be to have an AIBehaviorComponent that you add to entities. If the MovementBehaviorComponent asks for an IMovementCommands interface from other components on the entity, then a user-controlled entity can have a UserMovementCommands that exposes that interface, so the MovementBehaviorComponent doesn't need to know whether it's driven by AI or a user.

For higher-level thinking, like "I need to control this area of the map," that would either be an entity in and of itself, or it would be a totally separate system. Either way, it would have to query the map and the world for information that it can use for its decision making somehow. The runtime cost would be the same in both ways, so whether you make "AI thinking" an entity or not is more up to how it would fit into your particular game.

Scene graph

I am very interested in the component structure you show here and am putting together a simple engine to test it out and see if it would work well for my needs. However, I am having trouble understanding one important concept.

How do the renderable components tie in to the Scene Graph?

In your example you have RenderableComponent inheriting from both Component and SceneGraphNode. Assuming SceneGraphNode is the base node class for the scene graph, this wouldn't work in C#.

A simple overview of how they work together would help me a great deal, or possibly even a separate article on your scene graph implementation.

I really appreciate the detailed responses you give here, on GameDev.net, and on the XNA forums. You provide a wealth of invaluable information and insight to the game development community.

jwatte's picture

Well, Component could be an

Well, Component could be an interface (IComponent), or SceneGraphNode could be an interface (ISceneGraphNode), or the RenderableComponent would simply own a SceneGraphNode that it configures accordingly. It all depends on how specifically you want to implement it. Personally, I make ISceneGraphNode an interface, but if you have heavy-weight nodes in your scene graph, delegation (ownership) would probably be better for you.

Parent/Child Hierachy

You have no parent/child object/tree hierachy with your entities. How do you manage large numbers of entities that would benefit from this structure?

Also do you create components with lists of subcomponents if you need them?

jwatte's picture

You could just add a "Parent"

You could just add a "Parent" property to the Entity if that's what you wanted. The Entity does contain some very common properties, like Position etc -- in a hierarchical system, "Parent" could very well be one of those.

An alternative is to add an IParented interface, which has a Parent property, and when you need to parent something, you add a component that implements that interface. That would be the ultimate in componentizing, but probably too complex for most simple situations :-)

For my games, I haven't needed parenting, though, because my entities are fairly coarse (entire characters, etc), and for animation hierarchies, I treat an entire skeleton as a component, which exposes "attachment points" that other things can slave their position off of (rather than "attach to").

test

didnt work last time

jwatte's picture

If you post anonymously, the

If you post anonymously, the comments need to be approved before they're shown. If you register and log in, that's not needed.

Component Inheritance

Hi

How many levels does your component class hierachy typically go?
How many levels does your entity class hierachy typically go?

Regards
Craig

jwatte's picture

When I started out, I had an

When I started out, I had an entity system that went up to three deep (entity -> vehicle -> car), but I've since actually just flattened it down to a single level. There's just Entity.
For components, there's now just two levels: Component, and the concrete component kinds (EnginePropulsion, LaserWeapon, etc), using interfaces for the commonalities of being Propulsion or Weapon.

If this is so great...

Hi,

I don't want to sound like an idiot if you get me, but...

If this system is so great (and I know some use it), why do so many not use it, including Unreal Engine 3, CryEngine 2 etc?

Cheers,
Rich

At least one series

http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/
According to this guy who was a developer on one of the early Tony Hawk games, they used it there, not sure which game in the series, my guess would be 1 or 2? I'm not sure if they still use it in the current versions.

jwatte's picture

I suppose there are a few

I suppose there are a few reasons.
First, the inheritance hierarchy is easier to understand and explain.
Second, back in the days, the inheritance hierarchy was considered the bees knees. Never underestimate the power of inertia!

Component communication

I have been reading a few articles regarding this design pattern and it seems as though the biggest challenge is how components relay messages within the entity. For example -- if in a controller component a player pushes the "accellerate" button, force is applied by the physics component to the entity which ultimately updates the entities position. How do you get these to talk to each other without them being too dependent upon each other's existence? BTW -- thanks so much for such an insightful article!!!!

jwatte's picture

For some common things, I've

For some common things, I've found that putting them in the Entity makes most sense. Position, Orientation, and velocities go there for me. This has the draw-back that my "rules" entity (which runs overall game logic) has a position, even though it doesn't have a physical presence, but I can live with that.

For slightly less common things, I define interfaces. There's an IPhysicsObject interface, which defines properties like Mass, and can accept force and torque. This component delegates to the physics library. Then I have a Control object (not an interface) which reads the input library, and applies the appropriate forces to the IPhysicsObject. There's a different Control object for vehicles than for avatars, say.
The Entity class has a FindComponent(Type) method, and a FindComponent(name) method, although 99% of the time I use the Type flavor. Name is there to separate multiple instances of the same type (particle effects, say) if they need some control information.

Some other things that are common: there are two update phases. The "update" phase allows all components to read the previous state of the entity, and write the new state. However, you can't read the new state. The "commit" phase copies the new state to old state, and allows reading the new state (for forwarding to a scene graph, etc). During edit mode, the Update never gets called (as I don't want objects to move around while being edited) but the commit function keeps getting called (to commit changes made in the editor).

The pattern is generally that all components are inert containers of parameter information until they are attached to an entity. Inside the OnAttached callback, the component configures itself, loads assets, and finds pointers to other components (so they are cached inside the Update calls). Inside OnDetached, the components un-register/un-load themselves again. I add all the components to the entity first, and then call OnAttached on each of them, so that they can actually find the other components even if there is an ordering difference.

And all my component configuration is through an XML scene file, rather than in code, and I have a scene editor/inspector control that allows me to tweak objects at runtime, and save out a new XML file. But that's kind-of more code than fits in a single article :-)

Component logic

So here's a couple more questions... :D
Do your components contain data and logic, or do you have various subsystems to handle the logic? It would appear from what I could gather above that the components do. If I recall correctly on one of your posts on the XNA creator's site that you mentioned having different "worlds" (i.e. physics, collisions, graphics) which almost sounds like a subsystem approach and am wondering if that applies at all to your example here.

You mentioned the two update "phases" above and I was a little curious on where those phases get implemented? Are they two seperate methods contained within the components? I guess I'm wondering kind of how that would look in code.

Sorry for all the ???s -- I'm thoroughly interested in using this approach and have been reading lots of articles (i.e. "Evolve Your Hierarchy" and the T-Machine article, etc..) and posts over on gamedev.net but very few have examples in c#... and even though I can sort of read c++, I know I'm missing a lot of the fine details due to my lack of good familiarity with that language. Thanks again!!!!!!!

jwatte's picture

I'm using subsystems for

I'm using subsystems for graphics, sound, physics and special effects. However, I put the game logic in the actual world/entity system.

Update and Commit are methods on the entity components. In editor mode, Update() is not called, but Commit() is; this allows objects to update themselves in the scene graph when moved through the editor, without having to run the physical simulation (which is polled and controlled mainly out of Update()). In my system, all entities are first Update()-ed, which Update()-s the components within the entity. Then, as a separate pass, all entities are Commit()-ed, which Commit()-s the components within the entity. This way, all entities and components only depend on the state of other entities/components for the same update cycle/time step, because of the rules for reading/writing old/new state, and copying the state after update but before commit.

I'm thinking that the component system could probably be "purified" by defining events for the update, commit and perhaps pre-render events (although that can come from the scene graph). Then, components that don't need to do anything, don't need to get called, and I'd save some on overhead. The drawback would be slightly more code to register yourself for the events you needed in the component.

Finally, the components are there for editing: in my world editor, I can select an entity (using the entity list, or the world view clicking if it's collidable). When selected, the entity properties go on top of the window, followed by the properties for each component, each in their own collapsible roll-out panel. There's also a little bit of UI to add or remove components to an existing entity. All in all, it all comes together pretty well -- it's certainly a structure that's working well for me for now, even though it takes some short-cuts (like making position/orientation entity properties, rather than component properties, and making all components have update and commit functions).

Update and Commit

So regarding the old/new states -- does each component have two copies of each of its variables - ? -- example: life component... does this component have an int oldLife and int newLife variable such that in it's Update() method, it and other components that require its data are reading and performing operations on oldLife and then in Commit(), the life component takes the value in oldLife and publishes it to newLife?

How does your physics simulator Update figure into this, since in the physics libraries I've seen this is handled by one call to the physics sim's Update() method? In my case, I'm working with Farseer which just uses one Update() call per time step to iterate through each of the bodies and geoms that are registered with it -- how would this one function figure into Update() and Commit() within the entities with Physics components?

jwatte's picture

That's up to each component.

That's up to each component. Currently, the Entity double-buffers the "well known" values, which are position, orientation, and their derivatives.

The update from physics subsystem to entity subsystem happens in the Update() call, where the physics component will read the simulation outcome from the physics subsystem, and copy it into the entity state. This means the physics is run separate from the entity system (and, in fact, could be run in another thread entirely, with the proper sync points).

Is that something like

jwatte's picture

Yes. There are, in fact, a

Yes. There are, in fact, a lot of descriptions of component systems out there, including in some volumes of the Game Programming Gems book series. It's the way that modern game design is moving, for several reasons:
- Specialized systems need specialized data structures. Rendering does not use the same data as collision, which doesn't use the same data as AI. Putting everything in the scene graph, like a lot of people did in the '90s, no longer works at all.
- Class inheritance is not flexible enough to mold to express new gameplay entities as they are created.
- Designers want to be able to create new entities (a "talking door" puzzle, say) without necessarily involving engine programmers.