MikhaD / wordle

A recreation of the popular game Wordle with additional modes and features. Made with Svelte in Typescript.
https://mikhad.github.io/wordle/
GNU General Public License v3.0
209 stars 194 forks source link

Different answer word per timezone #19

Closed lukeswitz closed 2 years ago

lukeswitz commented 2 years ago

Can this be standardized like the regular game? Asking for date.today will return a different randomSeed for each timezone.

MikhaD commented 2 years ago

As I understand the regular wordle is time zone specific. I'm quite sure what you're asking for, but what I can do is make the hourly and infinite modes non time zone specific so that everyone has the same hourly at the same time.

lukeswitz commented 2 years ago

I just want every time zone to have the same answer for the daily & hourly seed. Make sense? I don’t think you’re understanding my issue, let me know how I can clarify that if I switch time zones on devices they present different answers because new Date() is used to pull the local datetime. Setting a static time zone to base the randomseed from would be helpful

MikhaD commented 2 years ago

The regular wordle does not use a static time zone, which is why I haven't. I will consider using a static time zone for hourly, once I have figured out how to squash all the issues changing it will cause. I'm going to close this issue and open a new feature request issue.

lukeswitz commented 2 years ago

Sorry, but you’re wrong. Here in the US there’s several time zones. Wordle gives us the same word no matter what. Look at the js file in all the worldle forks. Carry on.

MikhaD commented 2 years ago

That shouldn't be the case, but I'll look into it. It should be that as long as the year, month and day are the same the daily wordle is the same, regardless of hour. The only time it is meant to be different is when one time zone has passed into the next day and the other hasn't yet. Could you please tell me which time zones you noticed the discrepancy between so I can test it and reopen this issue?

lukeswitz commented 2 years ago

Every time zone across the world gives you a different answer. Clear your cache please, change your local time zone to anything in Canada and then change across the globe. Every time the page loads regardless of the gameMode (ensuring you’ve emptied localstorage) will produce a different daily, hourly & infinite answer. Calling new Date() grabs the user time. I can’t keep repeating myself just test it, it’s incredibly simple to troubleshoot.

MikhaD commented 2 years ago

I have been able to recreate the problem for daily, I know what I was doing wrong. I was using new Date(today.getFullYear(), today.getMonth(), today.getDate()).valueOf() to seed the random number used to pick the daily word. That gives the number of milliseconds since January 1, 1970, 00:00:00 UTC for 00:00 in the given time zone, which is obviously different. However, you said that hourly is also producing a different result. Hourly uses new Date(today.getFullYear(), today.getMonth(), today.getDate(), today.getHours()).valueOf() to seed the random number, which should give the same value regardless of time zone, as the number of milliseconds from January 1, 1970, 00:00:00 at 8:00pm in UTC and 10:00pm in UTC+2 is the same.

@lukeswitz could you please confirm that you are experiencing the issue with hourly as well before I push the fix to daily? Thank you.

lukeswitz commented 2 years ago

Yes, as you can check the hourly ms from the valueOf() function will also have the issues of the daily, as you use the same ingredients for the game mode recipes.

lukeswitz commented 2 years ago

Thanks for the fix but more importantly, showing me how to address this. I was using UTC, but I hadn’t seen the modes were also creating a new date for which I hadn’t accounted for. Endless gratitude for your efforts

MikhaD commented 2 years ago

No problem. Can you confirm that it is now working as intended in hourly and daily? Make sure the version is 1.1.4.

lukeswitz commented 2 years ago

Using it in a sandbox and it works fine. Thanks again. I applied it to the hourly and infinite one for continuity across all modes. Best