Expanded cell specialization effects#6826
Expanded cell specialization effects#6826Accidental-Explorer wants to merge 98 commits intomasterfrom
Conversation
… for advanced organelles being larger.
…on' into changed-specialisation-calculation
…on' into changed-specialisation-calculation
…ntal tolerances from organelles.
|
For anyone seeing that last commit: I just implemented the calculations in the "lowest levels" possible to see everything that would have to be changed to match. So I am aware that it is 100% not efficient yet. Just want to see if I can get it to work yet. (Also, on the gameplay side I got stuck on EndosymbiontOrganelleSystem/MicrobeReproductionSystem for now) |
… for updating already spawned entities.
…o mimic the boosted effect for auto-evo.
| var type = cellTemplate.CellType; | ||
|
|
||
| var type = cell.Data!.CellType; | ||
| var totalSpecializationBonus = MicrobeInternalCalculations.CalculateSpecializationBonus( |
There was a problem hiding this comment.
Theoretically it might be faster to restructure this loop so that we loop the species' cell types and calculate the specialization once for each type and then go through all cells that use that type. This way we can save on recalculations of the base efficiency. Though I'm not sure if this would help in any visible way in terms of performance.
There was a problem hiding this comment.
If I've learned anything from this latest episode, I think once multicellular auto-evo starts, this will be run a lot, so even a small improvement in speed would mean a lot.
So I was about to do as you said, but then I realised that for the same reason at that point it will probably be faster to pre-calculate the specilization bonuses for cell types the way we do for MicrobeSpecies now? I am not sure if it's still worth it at that point, since we would only save the time of looking up the bonus from the cell type?
There was a problem hiding this comment.
Theoretically I foresee someone wanting to make the cell adjacency specialization logic a lot more complex, so I do see saving a part of the calculation as beneficial.
Isn't there already saving of the cell type specialization in the cell type? I guess this code might be setup like this to allow easy use from the editor as that would need to dynamically calculate specialization from the edits facade otherwise. So again using the cached info here is possible but needs reviewing all code calling this and adjusting that code to make sure it has calculated up to date specialization for each cell type.
There was a problem hiding this comment.
Theoretically I foresee someone wanting to make the cell adjacency specialization logic a lot more complex, so I do see saving a part of the calculation as beneficial.
True, but I thought the change mentioned in this comment chain was about saving time by not re-calculating the cell specialization bonus (not adjacency)? The adjacency would still have to be calculated while looping over all the cells.
Though on that note, I feel like for multicellular auto-evo we might actually also end up wanting to cache the TotalSpecializationBonus (cell specialization) for each cell in the design (so, cellTemplate?) to avoid re-calculating it a dozen times. (for in-gameplay cells, this effectively already happens via the Spawner system of course)
Isn't there already saving of the cell type specialization in the cell type? I guess this code might be setup like this to allow easy use from the editor as that would need to dynamically calculate specialization from the edits facade otherwise. So again using the cached info here is possible but needs reviewing all code calling this and adjusting that code to make sure it has calculated up to date specialization for each cell type.
Yeah, basically using the cached specializationfactor for multicellular cell types in the tolerances would be doing the same thing as I did for microbes in his commit two days ago as part of the auto-evo optimisation: ab71429
, with a side-helping of making sure the cell type specialization bonus really is properly calculated and cached for them in all cases.
There was a problem hiding this comment.
True, but I thought the change mentioned in this comment chain was about saving time by not re-calculating the cell specialization bonus
Yes, by looping like this it can save calculations
foreach (var type in speciesCellTypes)
{
var typeSpecialization = ....;
foreach (var cell in speciesCells)
{
if (cell.Type == type)
{
var total = typeSpecialization * GetAdjacencySpecialization(cell, speciesCells);
... do stuff here...
}
}
}
with a side-helping of making sure the cell type specialization bonus really is properly calculated and cached for them in all cases.
Yeah, that is kind of the main concern with any cache: making sure the cache is always up to date when used. And the main difficulty in making the switch in code to using a cache.
There was a problem hiding this comment.
Most of the code was already there, so I just switched it to use the cached version. And I changed the Multicellular editor to have the finishing the editing of one cell also call RepositionToOrigin (which already included the specialization calculation call) instead of preventing it.
I did it this way because not repositioning to origin did not make sense to me. (You would want to see that in the multicellular part of the editor right away, right?) But if there's a reason it should indeed not be done, I can split out the call to CalculateSpecialization.
(the remaining need for re-calculating the specialization bonus of a celltype will come once we actually start mutating them)
There was a problem hiding this comment.
I did it this way because not repositioning to origin did not make sense to me. (You would want to see that in the multicellular part of the editor right away, right?) But if there's a reason it should indeed not be done, I can split out the call to CalculateSpecialization.
I didn't check your code. But no. Actually we have to prevent that. Because repositioning before fully exiting the entire editor, will blow up action history. So if a cell type is repositioned to origin in a situation where the player is still in the editor, that will have broken editor history and will cause an error when undoing and redoing changes.
That is why the reposition to origin is deferred until fully exiting the editor.
There was a problem hiding this comment.
That comment is that the cell type does not get told in any other way that it was modified.
So it could do with a bit more context.
Technically yes we do have the code in all of the editors to apply the current edits, but those don't have a special way to let the cell type know that "hey, you've been edited". So that's what the comment is trying to say. Or were you pointing out something else?
There was a problem hiding this comment.
No, I think that makes sense to me now, thanks!
I put the calculation call for the specializationbonus in the else statement for if not positioning to origin so it's not calculated double for no reason. I hope that's alright. (I did not want to remove it from Reposition to Origin since it's relied on to do it in other contexts)
|
That does seem pretty good now, right? And so it looks like that problem is now solved. |
Yes. Statistically, with this sample size I would not be able to say there is any difference between the two. But if anything, the PR average is slightly faster right now. But I need to check that that second change did not break anything, particularly for multicellular. |
|
Looks like there is a problem with auto-evo prediction in the editor now that I have to resolve as well. |
|
I was able to avoid the errors by calculating the specialization bonus for the setup of new auto-evo prediction and suggestion rounds. But I have to say it feels off. Both of these systems appear to be cloning an original species, and those are supposed to have their specilizationbonus calculated already. |
|
They only clone the species to work as a base and then apply all the edits made in the editor on top, so it would be totally wrong to just copy the specialization. Instead it has to be recalculated to match the actual applied organelles and other editing state. |
…d cell specilization values instead of recalculating
…e RepositionToOrigin (which includes updating the SpecializationBonus)
…ll to use RepositionToOrigin (which includes updating the SpecializationBonus)" This reverts commit 4c885d2.
|
Considering the extensive changes since this was test-approved, I'll request another round of testing if and when the code is approved. |






Brief Description of What This PR Does
This PR is intended to expand the cell specialisation bonus to affect more than just process speeds.
Currently affects:
Tooltip on the specilization bonus in the editor still needs to be updated, which I will do once everything else is approved.
Related Issues
Progress Checklist
Note: before starting this checklist the PR should be marked as non-draft.
break existing features:
https://wiki.revolutionarygamesstudio.com/wiki/Testing_Checklist
(this is important as to not waste the time of Thrive team
members reviewing this PR)
styleguide.
Before merging all CI jobs should finish on this PR without errors, if
there are automatically detected style issues they should be fixed by
the PR author. Merging must follow our
styleguide.