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

Implement organelles for processing agents into other agents #41

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

Implement organelles for processing agents into other agents #41

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

Comments

@bkloster
Copy link
Contributor

bkloster commented Oct 5, 2013

To simulate a simple metabolism inside a microbe, organelles for transforming agents (materials) into other agents (products) are required. These ProcessOrganelles should take a set (but configurable) amount of materials from their microbe with Microbe:takeAgent and, if enough materials are available, store the products with Microbe:storeAgent.

To make the process configurable, the following API functions are suggested:

ProcessOrganelle:setMaterialAmount(agentId, amount)
ProcessOrganelle:setProductAmount(agentId, amount)

The material and product amounts are stored in a table. The ProcessOrganelle:update() function iterates over the material table, checking if a sufficient amount is available. If yes, it takes those amounts from the microbe's storage organelles and stores the product amounts in turn.

@jjonj
Copy link
Contributor

jjonj commented Oct 28, 2013

I'd like to be assigned to this!
I'm wondering if we would want to support several processing organelles having input agents in common in a single microbe? This could be supported indirectly with cooldowns on processing or/and by distributing input agents equally (involves not waiting until there is enough, but having buffers in processing-organelles) could even be extended with a priority system (lungs getting priority over the oxytoxy-neuro-toxin producer)!

@ghost ghost assigned jjonj Oct 28, 2013
@bkloster
Copy link
Contributor Author

I'm wondering if we would want to support several processing organelles having input agents in common in a single microbe?

Players can add multiple organelles of the same type, so yes, organelles within a microbe may end up competing for materials. I'm not sure if we need a priority system for that, though. It might actually be interesting gameplay to micro-manage the organelles during times of scarce resources by toggling them on and off as needed.

On an unrelated note, I vote for our first poison organelle to be named "oxytoxy-neuro-toxin organelle".

@jjonj
Copy link
Contributor

jjonj commented Oct 28, 2013

Perhaps i should go ask the design people what they think about multiple-consumer organelles then?

And that naming was never up for discussion!

@bkloster
Copy link
Contributor Author

The discussion about organelle mechanics mostly took place in this thread, which resulted in this wiki page. However, I'm pretty sure that different organelles using the same resource will be pretty common. I think all movement organelles (maybe even all organelles, but that's for the biologists to decide) will use the ATP agent and the players are free to attach as many movement organelles as they want. The same goes for processing organelles, I presume.

@jjonj
Copy link
Contributor

jjonj commented Oct 28, 2013

I'll implement a buffer for each producer with fair distribution of input agents then, should be easy enough to change to something else, if micro management or a more advanced priority system is desired.

@NickTheNick-zz
Copy link

There is some useful documentation done by Seregon on the different organelles and their processes for the Microbe Stage. Here it is:

http://thrivegame.forum-free.ca/t997p120-microbial-compounds-and-organelles#28200

I originally posted it here, but it wouldn't format properly.

@NickTheNick-zz
Copy link

Also, note the distinction I explained on that thread between agents and compounds. Agents are chemicals released by a microbe, whereas compounds are what makes up everything in the game, like sand, wood, coal, etc.

@jjonj
Copy link
Contributor

jjonj commented Oct 30, 2013

I'm pretty much done with the solution for this issue, however its not working..
Lua is giving the following error when i try to instantiate my new class from setup.lua:
Attempt to call global 'ProcessOrganelle' (a nil value)
I made sure my class was added to the manifest before setup.lua! If someone (Nimbal) has any idea what i'm missing and/or can look at the problem in the code: https://github.com/Revolutionary-Games/Thrive/tree/41-processing-organelles that'd be great!

@bkloster
Copy link
Contributor Author

I think that's a nasty case of "misleading error message" in luabind. Try calling Organelle.__init(self) inside ProcessOrganelle.__init.

Oh, by the way. When you are working on a feature and have some of it done, you can already make a pull request. Even if the feature is far from done, it's a great way to discuss the work in progress.

@bkloster
Copy link
Contributor Author

I've committed some minor fixes and opened a pull request so that we can comment on specific lines.

jjonj added a commit that referenced this issue Nov 14, 2013
Closes #41

Add ProcessOrganelle

Fixed syntax in process_organelle.lua and added hasInputAgent method to ProcessOrganelle class

Added ProcessOrganelle support into Microbe class, and added process_organelle.lua to manifest

Added code to setup.lua to test ProcessOrganelle (currently not working)
Minor fixes to ProcessOrganelle related code in process_organelle.lua and microbe.lua

Minor formatting and reintroduced function missing in process_organelle.lua

Fix some minor errors in the ProcessOrganelle script

* Use table.insert instead of a[#a+1] to not repeat the table name
* Call superclass' constructor in ProcessOrganelle.__init
* Explicitly pass self to Organelle.update in ProcessOrganelle.update
* Lua has no -= (or += for that matter)
* Typos

Fixed error in loading a savegame with ProcessOrganelle.

Removed debugging code in microbe.lua

Created cooldown system for Process organelles, limiting the frequency of agent absorbtion and production

Fixed missing local specifier on two variables in process_organelle.lua

Implemeneted colours for process organelles to reflect how filled it is. Also minor bugfixes

Move "local" to where it belongs

Made distribution of agents, dependant on time elapsed instead of frames. (1 agent per agent type distributed per 100ms)

Release candidate 1 Done.

- Fixed compile error
- Removed debugging code
- Changed setup of compounds/agents to reflect mitochondrion

Added additional documentation for processing compounds.
Minor refactoring to compound distribution for more accuracy.

Replaced magic value with proper constant
jjonj added a commit that referenced this issue Nov 14, 2013
Closes #41

squashed commits:
Add ProcessOrganelle for converting compounds

Closes #41

Add ProcessOrganelle

Fixed syntax in process_organelle.lua and added hasInputAgent method to ProcessOrganelle class

Added ProcessOrganelle support into Microbe class, and added process_organelle.lua to manifest

Added code to setup.lua to test ProcessOrganelle (currently not working)
Minor fixes to ProcessOrganelle related code in process_organelle.lua and microbe.lua

Minor formatting and reintroduced function missing in process_organelle.lua

Fix some minor errors in the ProcessOrganelle script

* Use table.insert instead of a[#a+1] to not repeat the table name
* Call superclass' constructor in ProcessOrganelle.__init
* Explicitly pass self to Organelle.update in ProcessOrganelle.update
* Lua has no -= (or += for that matter)
* Typos

Fixed error in loading a savegame with ProcessOrganelle.

Removed debugging code in microbe.lua

Created cooldown system for Process organelles, limiting the frequency of agent absorbtion and production

Fixed missing local specifier on two variables in process_organelle.lua

Implemeneted colours for process organelles to reflect how filled it is. Also minor bugfixes

Move "local" to where it belongs

Made distribution of agents, dependant on time elapsed instead of frames. (1 agent per agent type distributed per 100ms)

Release candidate 1 Done.

- Fixed compile error
- Removed debugging code
- Changed setup of compounds/agents to reflect mitochondrion

Added additional documentation for processing compounds.
Minor refactoring to compound distribution for more accuracy.

Replaced magic value with proper constant

Re-changed emitters to use new oxygen, glucose, atp, co2 system.
Cleanup of old variable and comment names in setup.lua
@jjonj jjonj closed this as completed in ed014af Nov 20, 2013
jjonj added a commit that referenced this issue Dec 15, 2013
Involves a refactoring of emitter components

Exposed AgentComponent to lua

Added exposed AgentComponent to script_bindings.cpp

Add explicit "this->" in SystemWrapper

Just to get it in line with the styleguide.

Catch luabind::error and print a more helpful error message

Added functionality for ejecting excess compounds in Microbe:storeAgent.
Set a lower capacity on energy in player microbe to display the effect.

Moved all compound emission code to AgentEmitterComponent and replaced existing code with calls to emitAgent(...)

Changed emitAgent parameters to include agentId and amount.
Discovered a bug relating to particle lifetime for custom emitter.

Added TimedAgentEmitterComponent for automatic emission of agents instead of that being default

Add Collision system for handling custom events upon collisions.

squashed commits:
Implementation of custom collision events. Some questionable design choices within. (Untested)

Updated collision system to new structure. Now uses CollisionHandlerComponent and CollisionSystem. Manifolds used instead of global callback.

Fixed previous compile error - a new one has taken it's place (uintptr_tr not defined)

Basic working state achieved. m_collisionCallbackKey assignment from lua does not seem to take effect.

Also storage and load still needs implementing, and agentabsorber system needs refactoring.

Storage and load implemented.
AgentAbsorber system & component refactored to use this system.
Acceptance tests performed

Collision filters added, not fully functional

Collision functionality nearly updated.
Needs cleanup, testing and integration with agentabsorber.

Working CollisionFilter class.

Attempt at exposing CollisionFilter to lua. Not successful.

Fixes to improve usage of CollisionFilter. Now uses Collision struct instead of typedef to pair of entityIds.
Better model for exposure to lua (still doesn't quite work).
Cleaned up documentation and header includes.

Fixed minor compile error

Collision system finalized.
- Added a member to Collision to represent the duration of collision represented since last clearCollisions().
  This member will allow more fine grained control of collision handling (damage every 0.5 second, etc).
- Cleaned up documentation and debugging code.

Renamed CollisionHandlerComponent to CollisionComponent.
Added removeCollisionGroup to CollisionComponent.
Added constructor taking a collision group to CollisionComponent

Refactoring of CollisionSystem. Stopped using mutable keyword in collision class and instead uses unordered map.
Added a vector<collision*> mirroring the contents of the unordered_map to allow iteration in lua.

Changed to using boost::map_values for iteration.

Rebased onto master.
Fixed setup.lua
Various relevant fixes.
Code is currently not functioning due to strange bug.

Implementation of custom collision events. Some questionable design choices within. (Untested)

Updated collision system to new structure. Now uses CollisionHandlerComponent and CollisionSystem. Manifolds used instead of global callback.

Fixed previous compile error - a new one has taken it's place (uintptr_tr not defined)

Basic working state achieved. m_collisionCallbackKey assignment from lua does not seem to take effect.

Also storage and load still needs implementing, and agentabsorber system needs refactoring.

Fix typo in Lua script

The previous version crashed because the game state passed to
CollisionFilter's constructor was nil in Lua and consequently
nullptr in C++.

Simplify GameState::findSystem

throw an exception if a reference type is cast, not for pointer
types.

Refactor signature handling of CollisionFilter

Returning a pair of references is a little tricky because it's
not obvious how the std::pair template will handle it. Returning
a reference to a pair, however, is more predictable.

Use static initializers when possible

Minor refactoring

* Use typedefs (i.e. CollisionFilter::Signature) instead of repeating
the type
* Use emplace when possible, it's more readable than constructing
  the collection item manually
* Rename permutation -> combination

Do not register collision filter in Implementation constructor

At that point, the m_impl field of the CollisionFilter is not
initialized yet (because the Implementation object is not
fully constructed). The CollisionSystem asks the filter for
its signature, which is saved in the m_impl object. Since this
doesn't point to anything useful yet, it crashes.

Added CollisionFilter.init and CollisionFilter.shutdown to allow users to create their CollisionFilters in constructors.
Removed debugging code.

Minor refactorings for CollisionFilter and CollisionSystem

Removed typedefs in collision_filter.cpp.

Removed minor error in rebasing

Add ProcessOrganelle for converting compounds
Closes #41

squashed commits:
Add ProcessOrganelle for converting compounds

Closes #41

Add ProcessOrganelle

Fixed syntax in process_organelle.lua and added hasInputAgent method to ProcessOrganelle class

Added ProcessOrganelle support into Microbe class, and added process_organelle.lua to manifest

Added code to setup.lua to test ProcessOrganelle (currently not working)
Minor fixes to ProcessOrganelle related code in process_organelle.lua and microbe.lua

Minor formatting and reintroduced function missing in process_organelle.lua

Fix some minor errors in the ProcessOrganelle script

* Use table.insert instead of a[#a+1] to not repeat the table name
* Call superclass' constructor in ProcessOrganelle.__init
* Explicitly pass self to Organelle.update in ProcessOrganelle.update
* Lua has no -= (or += for that matter)
* Typos

Fixed error in loading a savegame with ProcessOrganelle.

Removed debugging code in microbe.lua

Created cooldown system for Process organelles, limiting the frequency of agent absorbtion and production

Fixed missing local specifier on two variables in process_organelle.lua

Implemeneted colours for process organelles to reflect how filled it is. Also minor bugfixes

Move "local" to where it belongs

Made distribution of agents, dependant on time elapsed instead of frames. (1 agent per agent type distributed per 100ms)

Release candidate 1 Done.

- Fixed compile error
- Removed debugging code
- Changed setup of compounds/agents to reflect mitochondrion

Added additional documentation for processing compounds.
Minor refactoring to compound distribution for more accuracy.

Replaced magic value with proper constant

Re-changed emitters to use new oxygen, glucose, atp, co2 system.
Cleanup of old variable and comment names in setup.lua

Add missing <iostream> include

A fresh Ubuntu 12.04 installation complains about not knowing
std::cerr in scripting/luabind.h when compiling with the mingw
environment. A simple additional include fixes it.

Fixed minor bug and minor adjustment of emission values.
Removed debugging code.

Added meshnames to agent registry, and removed it from every EmitterComponent

Added movement at random ejecting angle

Readded constant size for compounds
jjonj added a commit that referenced this issue Jan 3, 2014
AI now working (still on player)
- Will seek out emitters emitting oxygen or glucose if it's missing it.
- Will wander randomly while sated

Now spawning additional AI controlled microbes
- Microbe class interface changed to match required entity-like interface for despawning

Program will eventually crash due to Z being set to non-zero for undetermined reasons.

Non-proper fix of non-zero z value crashes.

AI microbes with different colors
Bad fix for Z-desync

Fixed that all AI was spawned @ 0,0.
Cleaned up debugging code.

Made proper random choice of emitters for AI.
Previous fix for randomized spawning position did not work, unable to find a fix.

Fixed random positioned spawning

Added proper destruction of MicrobeAISystem.
Reverted some bad design choices regarding microbe interface.
Fixed saving and loading of AIComponents

Renamed MicrobeAIComponent to MicrobeAIControllerComponent

Fixed a bug with storage method not returning anything

Update build server URL

Added functionality for ejecting excess compounds from microbes.
Involves a refactoring of emitter components

Exposed AgentComponent to lua

Added exposed AgentComponent to script_bindings.cpp

Add explicit "this->" in SystemWrapper

Just to get it in line with the styleguide.

Catch luabind::error and print a more helpful error message

Added functionality for ejecting excess compounds in Microbe:storeAgent.
Set a lower capacity on energy in player microbe to display the effect.

Moved all compound emission code to AgentEmitterComponent and replaced existing code with calls to emitAgent(...)

Changed emitAgent parameters to include agentId and amount.
Discovered a bug relating to particle lifetime for custom emitter.

Added TimedAgentEmitterComponent for automatic emission of agents instead of that being default

Add Collision system for handling custom events upon collisions.

squashed commits:
Implementation of custom collision events. Some questionable design choices within. (Untested)

Updated collision system to new structure. Now uses CollisionHandlerComponent and CollisionSystem. Manifolds used instead of global callback.

Fixed previous compile error - a new one has taken it's place (uintptr_tr not defined)

Basic working state achieved. m_collisionCallbackKey assignment from lua does not seem to take effect.

Also storage and load still needs implementing, and agentabsorber system needs refactoring.

Storage and load implemented.
AgentAbsorber system & component refactored to use this system.
Acceptance tests performed

Collision filters added, not fully functional

Collision functionality nearly updated.
Needs cleanup, testing and integration with agentabsorber.

Working CollisionFilter class.

Attempt at exposing CollisionFilter to lua. Not successful.

Fixes to improve usage of CollisionFilter. Now uses Collision struct instead of typedef to pair of entityIds.
Better model for exposure to lua (still doesn't quite work).
Cleaned up documentation and header includes.

Fixed minor compile error

Collision system finalized.
- Added a member to Collision to represent the duration of collision represented since last clearCollisions().
  This member will allow more fine grained control of collision handling (damage every 0.5 second, etc).
- Cleaned up documentation and debugging code.

Renamed CollisionHandlerComponent to CollisionComponent.
Added removeCollisionGroup to CollisionComponent.
Added constructor taking a collision group to CollisionComponent

Refactoring of CollisionSystem. Stopped using mutable keyword in collision class and instead uses unordered map.
Added a vector<collision*> mirroring the contents of the unordered_map to allow iteration in lua.

Changed to using boost::map_values for iteration.

Rebased onto master.
Fixed setup.lua
Various relevant fixes.
Code is currently not functioning due to strange bug.

Implementation of custom collision events. Some questionable design choices within. (Untested)

Updated collision system to new structure. Now uses CollisionHandlerComponent and CollisionSystem. Manifolds used instead of global callback.

Fixed previous compile error - a new one has taken it's place (uintptr_tr not defined)

Basic working state achieved. m_collisionCallbackKey assignment from lua does not seem to take effect.

Also storage and load still needs implementing, and agentabsorber system needs refactoring.

Fix typo in Lua script

The previous version crashed because the game state passed to
CollisionFilter's constructor was nil in Lua and consequently
nullptr in C++.

Simplify GameState::findSystem

throw an exception if a reference type is cast, not for pointer
types.

Refactor signature handling of CollisionFilter

Returning a pair of references is a little tricky because it's
not obvious how the std::pair template will handle it. Returning
a reference to a pair, however, is more predictable.

Use static initializers when possible

Minor refactoring

* Use typedefs (i.e. CollisionFilter::Signature) instead of repeating
the type
* Use emplace when possible, it's more readable than constructing
  the collection item manually
* Rename permutation -> combination

Do not register collision filter in Implementation constructor

At that point, the m_impl field of the CollisionFilter is not
initialized yet (because the Implementation object is not
fully constructed). The CollisionSystem asks the filter for
its signature, which is saved in the m_impl object. Since this
doesn't point to anything useful yet, it crashes.

Added CollisionFilter.init and CollisionFilter.shutdown to allow users to create their CollisionFilters in constructors.
Removed debugging code.

Minor refactorings for CollisionFilter and CollisionSystem

Removed typedefs in collision_filter.cpp.

Removed minor error in rebasing

Add ProcessOrganelle for converting compounds
Closes #41

squashed commits:
Add ProcessOrganelle for converting compounds

Closes #41

Add ProcessOrganelle

Fixed syntax in process_organelle.lua and added hasInputAgent method to ProcessOrganelle class

Added ProcessOrganelle support into Microbe class, and added process_organelle.lua to manifest

Added code to setup.lua to test ProcessOrganelle (currently not working)
Minor fixes to ProcessOrganelle related code in process_organelle.lua and microbe.lua

Minor formatting and reintroduced function missing in process_organelle.lua

Fix some minor errors in the ProcessOrganelle script

* Use table.insert instead of a[#a+1] to not repeat the table name
* Call superclass' constructor in ProcessOrganelle.__init
* Explicitly pass self to Organelle.update in ProcessOrganelle.update
* Lua has no -= (or += for that matter)
* Typos

Fixed error in loading a savegame with ProcessOrganelle.

Removed debugging code in microbe.lua

Created cooldown system for Process organelles, limiting the frequency of agent absorbtion and production

Fixed missing local specifier on two variables in process_organelle.lua

Implemeneted colours for process organelles to reflect how filled it is. Also minor bugfixes

Move "local" to where it belongs

Made distribution of agents, dependant on time elapsed instead of frames. (1 agent per agent type distributed per 100ms)

Release candidate 1 Done.

- Fixed compile error
- Removed debugging code
- Changed setup of compounds/agents to reflect mitochondrion

Added additional documentation for processing compounds.
Minor refactoring to compound distribution for more accuracy.

Replaced magic value with proper constant

Re-changed emitters to use new oxygen, glucose, atp, co2 system.
Cleanup of old variable and comment names in setup.lua

Add missing <iostream> include

A fresh Ubuntu 12.04 installation complains about not knowing
std::cerr in scripting/luabind.h when compiling with the mingw
environment. A simple additional include fixes it.

Fixed minor bug and minor adjustment of emission values.
Removed debugging code.

Added meshnames to agent registry, and removed it from every EmitterComponent

Added movement at random ejecting angle

Readded constant size for compounds

Bug fix preventing AI microbes from moving
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

3 participants