Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an AgentRegistry #42

Closed
bkloster opened this issue Oct 5, 2013 · 6 comments
Closed

Add an AgentRegistry #42

bkloster opened this issue Oct 5, 2013 · 6 comments
Assignees
Labels

Comments

@bkloster
Copy link
Contributor

bkloster commented Oct 5, 2013

To facilitate the management of agent types in the microbe stage, we need a central registry for storing information about agents. The information required (or useful) per agent is currently limited to

  • id: A unique integer id, generated with generateAgentId and possibly different per game instance
  • name: A unique string for identifying the agent across game instances. Should be in English and expressive, but short.
  • displayName: A string that can be displayed to the user, may be localized some time in the future.

The list of properties might grow in the future, so the AgentRegistry should account for that. Users, i.e. script authors, must be able to easily register new agents as well as query information about already registered ones.

The simplest implementation can just be a table like this:

AgentRegistry = {
    energy = {
        agentId = generateAgentId(),
        name = "energy",
        displayName = "Energy",
    }
    oxygen = {
        agentId = generateAgentId(),
        name = "oxygen",
        displayName = "Oxygen",
    }
}

Plus a simple API function registerAgentType(name, displayName) that generates an agentId and inserts the necessary information into the above table.

@jjonj
Copy link
Contributor

jjonj commented Oct 15, 2013

I'd like to try and implement this in C++ instead of lua.
Since pretty much all of the agent code is already in C++ it makes sense to me, and i would like to get more familiar with the core C++.
I was thinking of a simple AgentSystem (AgentRegistrySystem?) class in the agent.h/cpp file.
It would contain some sort of hashmap with agentId as key and simple objects or entities (not sure which?) as values.

Public member functions would be int registerAgentType(const string& name, const string& displayName), string getAgentDisplayName(int id) and string getAgentInternalName(int id)
A lua script would register all agents to the game instance at runtime in setup.lua

@bkloster
Copy link
Contributor Author

Implementing the agent registry in C++ would also enable us to add checks into other agent related systems (both C++ and Lua) to assure that an agent id has been registered before use. So I'm not opposed to the idea.

However, I don't think it needs to be a System. After all, what would the update() method do?

@jjonj
Copy link
Contributor

jjonj commented Oct 15, 2013

Ah yes, i see what you mean. Perhaps just a very static AgentRegistry class then

@ghost ghost assigned jjonj Oct 15, 2013
bkloster added a commit that referenced this issue Oct 28, 2013
@jjonj
Copy link
Contributor

jjonj commented Oct 29, 2013

Guess this just needs to be closed?

@bkloster
Copy link
Contributor Author

Do it yourself! (See PM in forum).

@jjonj jjonj closed this as completed Oct 29, 2013
@jjonj
Copy link
Contributor

jjonj commented Oct 29, 2013

Closed with e3bccd1 #48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants