Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a leaderboard #39

Closed
robertmarsal opened this issue Mar 12, 2014 · 14 comments
Closed

Implement a leaderboard #39

robertmarsal opened this issue Mar 12, 2014 · 14 comments

Comments

@robertmarsal
Copy link

It is nice to see one's high score, but it would be better to be able to compare with others

@gabrielecirulli
Copy link
Owner

Hi! I don't think this can be done in the current state of things. It'd require a big amount of work to implement a server to store the scores, which is a thing I'm not prepared to do at this point. Right now, the main vehicle for score sharing is twitter and it seems to be doing a good job so far

@Delapouite
Copy link

@robertboloc Hi. How could score forgery be avoided?

@robertmarsal
Copy link
Author

I understand. I haven't really thought about the implementation of this feature.
@Delapouite I am no expert, but I don't think anything can be done to provide a 100% viable solution given that the client runs the code.

@slopjong
Copy link

@robertboloc can you beat me?

2048_-_2014-03-12_23 53 29

@robertmarsal
Copy link
Author

😄 right now my best score is near 5000 points so, not yet, but with all the time I spend playing this game maybe I will... 😉

@Yogu
Copy link

Yogu commented Mar 13, 2014

I thought about preventing forgery a bit and this is what I came up with:

If you want to prevent the client from "undoing" an action, the client must send its move to the server, which then responds with the "random" tile added. This significantly decreases performance, especially for users with high ping. I think we'd have to live with the possibility of clients with an undo feature, if they exist.

But if you don't care about undoing, the following concept should work:

  • The server has a rsa keypair
  • Before the game starts, the server generates a bunch of random seeds and signs them together with a timestamp
  • The client now uses one of these seeds to initialize the random number generator for addRandomTile
  • The client records each move (this results e.g in Top-Left-Left-Right.... Invalid moves are not included.
  • When the game is over and the user decides to submit the score, the client sends the signed seed, the move sequence and the score to the server
  • The server now validates the signature of the seed, checks if it's not too old and not already used, and then simulates the game using the move squence. If everything seems ok and the scores match, it is accepted.

If you can share the game mechanics between server and client (with node.js), it shouldn't be that hard to implement. To reduce the server load, you could only accept scores that will be within the top 100 if accepted.

@slopjong
Copy link

@gabrielecirulli I love 2k :-)

5th game = 2nd win & new best score

2048_-_2014-03-13_16 06 59

@gabrielecirulli
Copy link
Owner

@Yogu thanks for the ideas but I'm not willing to personally withstand the server hosting costs and the development time for this feature.

@aks0
Copy link

aks0 commented Mar 13, 2014

@gabrielecirulli Awesome game! :)

2048-high-3

@slopjong
Copy link

@aks0 Damn. You passed me, good job 👍

@gabrielecirulli
Copy link
Owner

Sorry guys, gotta close this. Nice scores, though. 👍

@charliezhang
Copy link

@Yogu Interesting thoughts on anti-forgery. One problem though, is that as long as the client decodes the random number generator it can predict the next game state deterministically. Then the search problem becomes significantly easier once you know what and where the next tile is, it is not a alpha-beta search anymore.

@charliezhang
Copy link

@Yogu BTW, here is an implementation of global leader board: http://go2048.com/rank.html

@Yogu
Copy link

Yogu commented Mar 23, 2014

@charliezhang That's what I meant with

I think we'd have to live with the possibility of clients with an undo feature, if they exist.

because otherwise, the game would be really slow (contacting the server for each move).

Thanks for the leaderboard link, got 29th :-)

This was referenced Mar 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants