ActiveStarMap needs unit tests
borg286 opened this issue ยท 7 comments
Looking over the logic for ActiveStarMap I see a whole bunch of heuristics for calculating the scaling factor for enchantments based on the intersection of the constellation bounding boxes. But the logic is hard to follow and seems error prone. You should add some unit tests for this class so that some toy examples of input bounding boxes produce the scaling factor you want.
Since the randomness is only used for calculating the duration on potions it should be deterministic.
I recommend you walk through the code using 3 perfectly overlapping constellations and see if shiftDistribution does what you want. Based on my calculations this line of code
will result in perfectly overlapping constellations to have a final perc value of 3, which gets clamped to 1, which gets shifted to .44.
The problem I suspect is that because you perform this loop
a total of 3 times that intersectingSize gets unwanted values.
I recommend you simply take the first constellation and intersect it with the 2nd constellation (using a default rectangle of the entire canvas. Then take that intersection and intersect it with the 3rd constellation, call this the final intersection. Calculate the bounding box for all 3 constelations. Take that final intersection area and divide by the bounding box area and call that the final perc. This will make it much easier to reason. If you want go ahead and shift it, but I don't think that is necessary.
I also propose an alternative for calculating the percent value. Instead of having a fixed scaling factor based on the placement of the constellations, instead the constellations will simply be selected, and the drawing board simply shows how bright the contellations are in the sky. The current block favors gaming the system, and gives the false impression that the user should try to align the stars. The enchantment level seems to have nothing to do with overlapping stars, but only overlapping rectangles. Once the player knows that this is the only thing that matters they will simply stack them, and thus removes the fun. If we continue with rewarding overlapping rectangles please find some feedback mechanism that informs the player of the strength of constellations.
If we did abandon rewarding overlapping rectangles what do we pick?
The question is how to retain the 'drawing' aspect, while letting players chose how to balance between the enchantments from one constellation and another. The current UI does not give the feedback as to how aligned the sky is with the selected constellations.
I propose that we give players to choose the size to put on the paper and disregard the placement/overlap.
Thus we'd have 2 scaling factors each capped between 0-1
Strength) The relative size of the constellation compared to the total size of all 1-3 constellations on the paper.
Resonance) How much that constellation is "in the sky". 0 when it is the exact wrong day for visibility, 60% when it just crosses the horizon, then scaling linearly while in the sky up to 100% when directly above.
I also propose that you change how strong/bright the lines are for the drawn constellation based on (2)
Using sizes is a much more intuitive UI that leads players to understand how powerful enchantments from that constellation will be. Having the brightness also guides the player into understanding resonance with the sky.
Hey, thanks for bringing this up. Reading the astral tome, i'd have never figured out how placing the constellations on the parchment would influence the resulting effects from the engraved glass. But, i'm still quite confused. Right now as the code is, are you supposed to stack constellations on each other, stars, or leave them apart as much as you can?
@yagomont spread them apart, unless using a version more than a year old.
Also, Page 2 of the Stellar Refraction Table in the Astral Tome:
"The placement of the Constellations seems to have great a impact as to their dominance in the final pattern. The fewer overlapping points from each Constellation, the stronger their presence will be in the final drawing."
I see. What was unclear to me was if by points it meant the stars or the constellation lines, or both. Apparently keeping them not touching is enough.
Uhh... What the fuck.
I just made 8 engraved glass and tried different combinations to test this, with varying levels of distance between the stars. What I saw was that stacking constellations on each other actually produced better results than if they are not touching at all!
Armara not touching its neighbours, for example, gave me prot IV consistently.
Now, stacked upon Pelotrio and Mineralis, it gave prot V.
Repeat the same happenings in a few other tries.
Thus, experimentation brings me to this conclusion:
This is broken.
(This was on the latest Jenkins build of .19)
(In one of the engraved glasses, it actually worked as expected,with farther away constellations giving their top effects, which makes this even more bizarre.)
There is some rng involved, with weighting being applied based on arrangement. None of it is guaranteed outside of a few corner cases.