I decided to pull scoring out into its own file, scoring.js, and put that under test. The big fix was to use the percentage positioning rather than the pixel positioning for measuring distances.
I'm really not a fan of how the score is calculated. You can look at the code to see what's going on, but suffice it to say that:
It doesn't take the visible face of the block into account (#49)
It relies on the distance to the centroids of the blocks rather than the distance to its target position (which could be intentional, but it leads to weird situations where you allow any translation of the block setup)
There are a couple magic numbers in there that I really don't understand what their purpose is (I put comments in to signify as much)
I also must admit that I wrote the tests to match the numbers that the program spit out... so that's also not ideal.
I decided to pull scoring out into its own file,
scoring.js
, and put that under test. The big fix was to use the percentage positioning rather than the pixel positioning for measuring distances.I'm really not a fan of how the score is calculated. You can look at the code to see what's going on, but suffice it to say that:
I also must admit that I wrote the tests to match the numbers that the program spit out... so that's also not ideal.