Make getRandomLatLng() less likely to prefer higher latitudes#729
Merged
BilelJegham merged 1 commit intoGeoGuess:masterfrom Apr 2, 2024
Merged
Make getRandomLatLng() less likely to prefer higher latitudes#729BilelJegham merged 1 commit intoGeoGuess:masterfrom
BilelJegham merged 1 commit intoGeoGuess:masterfrom
Conversation
👷 Deploy request for geoguess2 accepted.
|
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #729 +/- ##
=======================================
Coverage 52.12% 52.12%
=======================================
Files 53 53
Lines 752 752
Branches 209 209
=======================================
Hits 392 392
Misses 328 328
Partials 32 32 ☔ View full report in Codecov by Sentry. |
BilelJegham
approved these changes
Apr 2, 2024
Member
BilelJegham
left a comment
There was a problem hiding this comment.
Looks good, thanks for your contribution
Member
|
@all-contributors please add @zhudotexe for code |
Contributor
|
I've put up a pull request to add @zhudotexe! 🎉 |
1 failed test on run #685 ↗︎Details:
|
|||||||||||||||||||||
| Test | Artifacts | |
|---|---|---|
| SinglePlayer > Play SinglePlayer Mode Country Time 10s |
Test Replay
Screenshots
|
|
Review all test suite changes for PR #729 ↗︎
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Types of Changes
Description
The current implementation of
getRandomLatLng()assumes that the Earth is a flat rectangle and chooses a latitude and longitude uniformly, which ends up preferring higher latitudes once the rectangle is projected onto a sphere. This PR modifies the implementation to sample from the surface of the earth with equal probability (see https://math.stackexchange.com/questions/114135/how-can-i-pick-a-random-point-on-the-surface-of-a-sphere-with-equal-distribution).I preserved the behaviour of only choosing a latitude in the range [-85, 85] (
(Math.acos(0.995) * 57.2958) - 90 == -84.3and(Math.acos(-0.995) * 57.2958) - 90 == 84.3).How Has This Been Tested?
I couldn't get Cypress working locally or on CI, but I verified that the trigonometric way of generating latitudes maintains the same bounds and played a few test games on a local deployment.
Screenshots (if appropriate):