Closed jbphet closed 7 years ago
I spent some time working on this, and I've realized that items 1 and 2 above don't really lend themselves to simplification because some of the code is base on events, and so was written using listeners, and the other code was written to looks at the state at a given moment in time, so it lends itself to being in the step function. I've documented this but largely left it as is.
This is done, the results seem like a substantial improvement. Closing.
This sim has some fairly complex behavior for making decisions about when expressions combine with one another, when coin terms combine, when expressions combine with coin terms, when collection areas have priority over joining expressions, and so on. This logic is currently distributed between four locations:
ExpressionManipulationModel.js
, where listeners are added when expressions and coin terms are added to the modelExpressionManipulationModel.js
step function, where determinations are made about what is hovering over whatExpressionManipulationModel.js
that determine which thing is overlapping the most with another thing, which often includes logic about whether it is eligible for combiningExpressionManipulationView.js
, where decisions are made about removing coin terms from the model if they are released over the creator boxThis seems to work reasonably well, but would be hard to maintain since there is a lot of interdependency and implicit assumptions about the order in which various notifications will proceed. I think it would be best to move the bulk of this logic into one location - the listeners that are added to coin terms and expressions when the are added to the model - and to rename/refactor the methods such as
getExpressionMostOverlappingWithExpression
(and there are a number of these sorts of functions) to something more likegetExpressionMostEligibleToCombineWithExpression
and to have some of the logic about the eligibility to combine in these methods (it's currently there, but the method names don't really reflect this).