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
Process Organelles #57
Conversation
I took the liberty of fixing some minor errors. The "ProcessOrganelle is nil" error you got actually came from a syntax error in the file (Lua has no -= operator). It starts error-free now, but still doesn't seem to work. I'll leave that to you. |
Everything should be good! Can you confirm that there are no random tabstops and everything looks good to you? |
No tab stops there (did you find something in your setup?). The processing seems to work, but the speed of conversion is frame-rate dependent. To fix this, it's probably necessary to not just limit the frequency of conversion, but also how fast the resources are stored inside the ProcessOrganelles. If that's not limited, the ProcessOrganelles will keep filling up and suck the vacuoles dry. As a side note, I was confused by invisible agent storage. I parked the microbe besides the oxygen emitter and watched the agent count in the HUD. Since I never saw oxygen go above zero, I assumed that the ProcessOrganelle converted 1 oxygen into 1 oxytoxy although it was configured for a 2:1 rate. So we either need to show the player how much the ProcessOrganelles have stored, or switch to a non-buffered processing. |
Just found out that save/load game functionality actually was implemented (and my code here had a bug with it) I'll get to fix that.
The two solutions could make the displayed agents more intuitive, but if you don't think that'll be enough, it is not impossible to display the sum of oxygen (in vacuoles and buffers) instead of only the oxygen in vacuoles. Edit: Regarding tabstops, i have no clue. I understand my first pull request had tabstops, but for the second one i'm baffled. Perhaps it's codeblocks that adds them while pretending to add spaces. (I've exclusively used Notepad++ for this branch) |
I'd be partial to the first option, as it would allow designers to tweak the conversion rate by adjusting the ProcessOrganelle's cooldown. Ideally, ProcessOrganelle would have a property "conversionInterval" that gives the time between two conversions. The organelle would figure out by itself how much of each input agent it must take in each frame to maintain that interval in times of abundant resources. The confusion I mentioned could also be handled in the organelle graphics. Gradually changing the color of the organelle (or, when we have such a thing, adjust some animation) as it fills up will not only give a sense of "where do my resources go", but also "when will that organelle do something" (in case the conversion interval is several seconds long). |
Good ideas! I'll try it out later |
@@ -10,6 +10,7 @@ function MicrobeComponent:__init() | |||
Component.__init(self) | |||
self.organelles = {} | |||
self.vacuoles = {} | |||
self.producerOrganelles = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be more consistent, shouldn't this be called processOrganelles
?
I think you'll like the cooldown system i just pushed. Only missing changing color of ProcessOrganelle relative to buffer storage now. |
One of the Now, one question about the cooldown. What does |
timeBetweenProcess as the name suggest is the minimum time between producing output. processCooldown is set to timeBetweenProcess when something is produced and then counts down until it reaches 0, once it reaches 0 another output can be produced. You missed this line in update: I'm currently struggeling with lua arithmetic making the colors change. Sloowly making progress. |
Ah, now I see. May I suggest to rename By the way, I thought of another model to restrict the conversion speed. Instead of waiting for the cooldown, then consuming input agents from its buffer, the ProcessOrganelle fills its buffer at a rate that will allow one conversion every For example, the interval is 2 seconds and the organelle requires 5 oxygen and 3 nitrogen. This means it needs 2.5 oxygen per second and 1.5 nitrogen per second to maintain its intended conversion rate. During a timestep of 16 milliseconds, the organelle will try and grab This would basically mean that a process organelle requires an abundance of resources over the duration of its interval to function at max capacity, which is an easy rule to remember for players. If resources are scarce and organelles have to fight over them, they will work slower. Furthermore, if the player gathers up resources, they are consumed at a steady rate instead of being gone in an instance because the processors' internal cooldowns are all elapsed. And probably the most interesting advantage is that it's easy to adjust the effectiveness of ProcessOrganelles on the fly - just increase or decrease the interval. That can be a nice target for toxins. |
I only named it that because you seemed to deem that less confusing in a comment above.
Thats exactly how i have implemented it xD except i don't absorb fractions, but wait until enough time have elapsed to absorb 1 unit. |
There you go! crazy colours and all the fixes you could dream of. Changed the oxygen amount required for a oxytoxy to 4 to better display the colour change. I was very confused for a long time by a bug i discovered. The oxygen emitter will instantly when the game start, emit 2 oxygen units somewhere on top of / below the player microbe (even tho the emitter is far away from the player) which the microbe will then instantly absorb. |
Oh, I see now. Hm, well not exactly. In fact, there's still a rather serious problem in your implementation, unless I'm missing something (again). If I read this line right, a ProcessOrganelle can take at most 1 of each resource per frame. What if we have a crazy organelle that needs 100 oxygen, and a very short cooldown (say, 1 millisecond)? At a framerate of 60 Hz, the actual cooldown would be 100 frames or about 167 milliseconds. At 20 Hz, it would still be 100 frames, but 500 milliseconds. |
I'll fix it, but it will probably be a small contribution towards the 'spiral of death' (http://gafferongames.com/game-physics/fix-your-timestep/) |
There's my best bid on a solution. It distributes 1 unit of each agent type (at max) per 100 milliseconds (adjustable). Edit: I'll merge when i have your final approval |
Oops, sorry. I thought I already posted on this. Must have closed the browser tab before clicking the "comment" button. Honestly, I'm not really happy with that solution. For one, I think that while loop isn't valid Lua syntax, looks more like C++ (don't worry, I only just noticed that too after looking at it for a combined 15 minutes at least). More importantly, unless I'm mistaken, this implementation only allows for 10 agents per second per vacuole to be distributed to all other organelles that want it, right? So if we have one vacuole and two process organelles that want to consume 5 agents per second each, that's fine, but as soon as the player adds another process organelle, the conversion speed of all three process organelles goes down. I'm beginning to think that we might need to reevaluate the way that agents are distributed inside a microbe. Especially because this distribution is not specific to process organelles. Almost organelles will consume some agent (mostly energy, but maybe also other stuff). I'll think about it for a bit and probably make a forum post (or a GitHub ticket) to discuss it. |
Wow that was dumb, can't believe i forgot to actually test it.
Personally i saw this more as a feature than a problem, but yeah lets think & discuss! |
Don't get me wrong, a feature like that is probably a good idea. I just feel that it should be more explicit and configurable (per-vacuole setting for "agent bandwidth") than this. |
Yeah, you're right! |
After reading through the discussion on the forum again and some consideration, i feel this is sufficient for now.
|
Could you add some documentation for the processing and agent distribution algorithm? Especially the detail that at most 1 of each agent is distributed every 100 milliseconds. And maybe refactor that hardcoded 100 ms into a constant |
Can you rebase this onto master and squash the commits, as described in the style guide? I tried, but there were merge conflicts that I wasn't sure how to resolve without breaking your code. |
Might aswell wait for game states to be merged, I'll do it later .) |
The game state branch is merged now. |
That was a bit complex, but it looks like it worked. Altough i had to fix... something. for it to be willing to merge. |
That doesn't look right. The result should be one single commit, adding only the stuff that has been changed in this particular branch. Right now, there are two commits in this branch, one of them absolutely huge, containing changes that already are in master (the style guide, for example). Hold on, I'll see if I can fix this. |
There you go. Can you give it a final once-over to make sure I didn't break anything? If everything's fine, go ahead and merge it. As for what happened with your rebase attempt, I suspect it had to do with the intermittent rebases / merges that were done to pull in changes from master into this branch. I removed all commits that weren't related to process organelles (i.e. those that were pulled in from master) with an interactive rebase, then rebased again onto the current master. |
Thanks for fixing it |
I fixed it up and rebased again. |
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
See #41.
Work in progress, don't merge yet.