panoptyk / panoptyk-engine

5 stars 1 forks source link

Why can't each agent track their rank in the faction? #35

Closed mitchkm closed 4 years ago

mitchkm commented 4 years ago

https://github.com/panoptyk/panoptyk-engine/blob/68713c74a2e9331583acc2b90d80f77756524d24/src/models/faction.ts#L15

This map is always only 1 to 1, might as well contain it in the agent if its id is necessary anyway. Less overhead for a faction to track its agents' rank. Although tracking its members makes sense.

scm2217 commented 4 years ago

Each agent can track their rank in a faction, they just have to use the faction getAgentRank function.

I thought about leaving rank on the agent, but thought it was inappropriate to store another model's data in the Agent model. I have already made a helper function to easily get rank in my upcoming bot changes, but we could have a rank getter in Agent if you think it is important.

mitchkm commented 4 years ago

I think the way you track it works best. It would be nice to also have a faction contain another "map" that converts rank number to some sort of meaningful text. 1 -> "Leader", 2 -> "Officer" ect. I also think Agent should have a shortcut to get their rank though for ease. Not sure if getting rank should return string or number.

public get factionRank() { return this.faction.getAgentRank(this); }