Coder Social home page Coder Social logo

takserver's Introduction

TakServer

Last updated on 05/24/2016

Server to handle online TAK games

The input/output of server is all text.

The client to server commands and their format is as below (format of all squares is [Capital letter][digit]. e.g., A2, B5, C4, (row numbers start from 1)

Since the server and client are still in beta, the API is bound to change to support more features (though I would try to keep the changes to a minimum)

Commands to server Description
Client client name Informs the server of the client being connected from
Register username email Register with the given username and email
Login username password Login with the username and password
Login Guest Login as a guest
Seek no time incr W|B Seeks a game of board size no with time per player time specified in seconds, increment per move incr specified in seconds and an optional choice of color W for white, B for black
Accept no Accepts the seek with the number no
Game#no P Sq C|W Sends a 'Place' move to the specified game no. The optional suffix 'C' or 'W' denote if it is a capstone or a wall (standing stone)
Game#no M Sq1 Sq2 no1 no2... Sends a 'Move' move to the specified game no. Sq1 is beginning square, Sq2 is ending square, no1, no2, no3.. are the no. of pieces dropped in the in-between squares (including the last square)
Game#no OfferDraw Offers the opponent draw or accepts the opponent's draw offer
Game#no RemoveDraw Removes your draw offer
Game#no Resign Resign the game
Game#no Show Prints a somewhat human readable game position of the game number no
Game#no RequestUndo Requests the other player to undo the last move or accept the other player's undo request
Game#no RemoveUndo Removes your undo request
List Send list of seeks
GameList Send list of games in progress
Observe no Observe the specified game. Server sends the game moves and clock info
Unobserve no Unobserve the specified game
Game#no Show Sq Prints the position in the specified square (this is used mainly to convert server notation to PTN notation)
Shout text Send message text to all logged in players
JoinRoom room Join the room room
ShoutRoom room text Send test to players in room room
LeaveRoom room Leave the room room
Tell player text Send private message text to player
PING Pings to inform server that the client is alive. Recommended ping spacing is 30 seconds. Server may disconnect clients if pings are not received
quit Sent by client to indicate it is going to quit. Server removes all seeks, abandons (which loses) game if any

The Client, Login and Register are the only three commands which work while not logged in.

The server to client messages and their format is as below. The list does not include error messages, you're free to poke around and figure out the error messages on your own or look at the code.

Messages from server Description
Welcome! Just a welcome message when connected to server
Login or Register Login with username/password or login as guest or register after this message
Welcome name! A welcome message indicating that you've logged in as name
GameList Add Game#no player_white vs player_black, sizexsize, original_time, incr, moves half-moves played, player_name to move Notifies client that a game has started (which the client can observe if it wants)
GameList Remove Game#no player_white vs player_black, sizexsize, original_time, incr, moves half-moves played, player_name to move Notifies client that the game has ended
Game Start no size player_white vs player_black your color Notifies client to start a game. The game no. being no, players' names being white_player, black_player and your_color being your color which could be either "white" or "black"
Game#no P Sq C|W The 'Place' move played by the other player in game number no. The format is same as the command from client to server
Game#no M Sq1 Sq2 no1 no2... The 'Move' move played by the other player in game number no. The format is same as the command from client to server
Game#no Time whitetime blacktime Update the clock with the time specified for white and black players
Game#no Over result Game number no is over. result is one of R-0, 0-R, F-0, 0-F, 1/2-1/2
Game#no OfferDraw Indicates the opponent has offered a draw
Game#no RemoveDraw Indicates your opponent has taken back his offer to draw
Game#no RequestUndo Request from opponent to undo the last move
Game#no RemoveUndo Opponent removes his undo request
Game#no Undo Undo the last move. Client is supposed to keep track of previous board states and undo to the last state.
Game#no Abandoned Game number no is abandoned by the opponent as he quit. Clients can treat this as resign.
Seek new no name boardsize time W\B There is a new seek with seek no. no posted by name with board size boardsize with time seconds for each player and an optional color choice for seek poster
Seek remove no name boardsize time W\B Existing seek no. no is removed (either the client has joined another game or has changed his seek or has quit)
Observe Game#no player_white vs player_black, sizexsize, original_time, moves half-moves played, player_name to move Start observing the game number no of board size size with original time setting of origin_time seconds where moves half-moves are played and it is player_name's turn to move
Shout <player> text Chat message text from player
Joined room room Indicates you've joined the room room
Left room room Indicates you've left the room room
ShoutRoom room <player> text Message text from player to chat room room
Tell <player> text Private chat message text from player
Told <player> text Confirmation that your message is sent to player. You'll receive this even if player is not logged in
Message text A message from server. Might be used to indicate announcements like name accepted/server going down, etc
Error text An error message
Online no no players are connected to server
NOK Indicates the command client send is invalid or unrecognized
OK Indicates previous command is ok. Clients can ignore this. I might remove this message altogether in future as it serves no real purpose

##Info for Client developers Stand alone clients can connect directly to playtak.com at port 10000 (but this communication will not be encrypted)
The defalut Web client runs on playtak.com port 80/443.
telnet to playtak.com on port 10000 to test the commands.

Typical communication is like below

  • Connect to server. Server gives welcome message
  • Server sends "Login or Register"
  • Client replies with login information or registers (If Client registers, password is sent to the mail and it can login with the password)
  • Server accepts name or asks for another name if the one provided is invalid or already taken
  • Server sends list of seeks with "Seek new" messages and games in progress with "GameList Add" messages
  • Client posts seek or accepts existing seek
  • If seek is accepted, server removes existing seeks for both the players (sends "Seek remove" for all) and starts game
  • Client sends moves, server validates moves and sends the move to other client. If invalid, server sends a "NOK" message.
  • Game progresses and ends either in a win/lose/draw or abandonment.

NOTE: https://playtak.com is now being maintained by US Tak Association (https://ustak.org)

takserver's People

Contributors

chaitu236 avatar nelhage avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

takserver's Issues

Getting NOK from Ping

TakBot was getting disconnected after a couple minutes of idle time, so I figured the server had started checking pings. I enabled TakBot to send a Ping every 30 seconds and the server always returns "NOK".

Mobile not displaying login form

I cannot load the login form in Chrome on Android. The button will display the disconnected notice, but not the login prompt.

Simultaneous games

The Protocol used to log in is flexible enough to allow guest logins and user logins.
A third option for bot's could reduce the number of 'guest' logins, and would improve
name designation.

Vision:
A login option to log in with an existing account (even if this account is logged in), but with a designated
boolean attribute to signal the server, that this is a bot login.
The user would then be loggen in as [Username]'s Bot_1.
Aequivalently, additional bot instances would be designated [Username]'s Bot_2, [Username]'s Bot_3 etc.
Users that are logged in as bots could have individualized interfaces to better offer services.
Bot accounts could for example get a different color in chat (similar to IRC-bridge, but including the text)
That way non-human messages can be disregarded more easiely.

This change would allow subsequent future changes, for example Highlighting Bot Games in the 'Join Game' menu, or a separate 'Play Bot Game' menu.

Passwords are stored in plaintext

Passwords should be hashed before storing to disk. If the account database is leaked online, account credentials would be in the clear. Using a strong password hashing function (not general cryptographic hashing functions like MD5, SHA-1, SHA-256,512, etc.) like bcrypt will ensure that the password cracker needs to spend significant amounts of CPU brute forcing the hashes to discover the passwords.

Alternatively, you could use the scrypt PBKDF as a password hashing function, which also requires memory hardness in addition to CPU hardness like bcrypt.

Libraries exist in Java for both bcrypt and scrypt:

http://www.mindrot.org/projects/jBCrypt/
https://github.com/FauxFaux/scrypt

Undo request

Can you have the 'Undo' message include who's turn it is, similar to the GameList lines? It'll make restoring the state easier for the AI.

Login/signup box showing two username boxes

Trying to sign up for an account and I'm getting two different "username" boxes at the same time.
Chrome 55 on Windows 8.1. It's like two different forms are showing at the same time - one for existing users and one for new users who want to sign up.
playtak

Database IDs should match online IDs

Right now, the IDs received via the server protocol are not the same IDs that end up in the database. A lot of things would be more convenient, programmatically, if they did – for example, a tool could automatically generate archive links from games in real-time. It would enable me to cross-reference my own logs with the server database.

Server stopped responding

It was a bot's move but nothing ever happened. The timer continued to countdown the bot's time. I don't think this was an issue with the bot programming. When nothing was happening, I refreshed the page to see what was going on. The game state did not reflect my last move. Instead, it was waiting for my move yet still continuing to count down the bot's timer.

Link to game.

Feature Request: User List

Currently the client is not informed of online/offline users. Only a number of online players is given. In this number included are all bots and long time idle users. It would be nice for users to be able to access a list of online users. The list could also have a flag for idleness.

This feature would infract the current platform behavior and policy of complete anonymity, obviously, so I am not sure, if you want it. However, people have asked me to implement this on the fork, which is obviously not possible currently.

server is double-sending moves in some cases

I have a bot that's logging all games on the server for analysis. In some cases where White plays a move and then the game ends (I can't tell from logs if this is due to time or resignation or what), it double-sends the opening move.

2016/05/04 10:46:26 < GameList Add Game#309 TakticianBot vs onewhohides, 5x5, 1200, 0 half-moves played, TakticianBot to move
2016/05/04 10:46:26 > Observe 309
2016/05/04 10:46:26 < Observe Game#309 TakticianBot vs onewhohides, 5x5, 1200, 1 half-moves played, onewhohides to move
2016/05/04 10:46:26 < Game#309 P A1
2016/05/04 10:46:26 < Game#309 Time 1200 -2216321
2016/05/04 10:46:26 < Game#309 P A1
2016/05/04 10:46:26 < Game#309 Time 1200 -2216321
2016/05/04 10:46:26 < GameList Remove Game#309 TakticianBot vs onewhohides, 5x5, 1200, 1 half-moves played, onewhohides to move
2016/05/04 10:46:26 < Game#309 Over 1-0
2016/05/04 10:46:26 < GameList Remove Game#309 TakticianBot vs onewhohides, 5x5, 1200, 1 half-moves played, onewhohides to move

There's also some weirdness with the time, which is being reported as -2216321 here…

Feature Request: Spectator list.

The spectator chat is currently mostly unused. Main reason for this is, that it is not clear how many, if any, users are watching a game. It would be of great use to give a listing of all players watching a game to all clients associated with the game (including the two players), and update if a player enters/drops the list of spectators. This way, the client can display a number with the game label that displays a full list of spectators either on hover, or on interaction (context menu).

If a named list is unwanted (to preserve anonymity) a pure number (as with the online players) would be great.

Doesn't correctly score 'double-win'

When a move creates roads for both players at once, the current rules dictate that the active player wins. However, currently, it seems to be scored as a tie.

Registration and Password reset emails, not arriving

Hey Team, probably not the best place for this, but I can't see another contact on the site.

I have just attempted to register, but have yet to receive an email confirmation. I attempted a password reset with the same result.

here is what I did:

  1. go to http://www.playtak.com
  2. logged in as guest
  3. played one game against the beginner bot (won!)
  4. played one game against the intermediate bot (won!)
  5. attempted to register (boshlol:[my email]@gmail.com)
  6. see the check your email message.
  7. no email
  8. message says disconnected from play tak
    9 . refresh the page
  9. reset password
  10. "token sent to your email"
  11. no email
  12. message says disconnected from server.

Fail to recognize roadwin

  1. a4 d1
  2. c3 c4
  3. d4 d3
  4. c2 b4
  5. c1 e4
  6. d4< c5
  7. b3 d4
  8. b3+ c5-
  9. 2b4> Cc5
  10. 3c4> c5-
  11. Sb4 d3+
  12. b2 e5
  13. Cd3 4d4>
  14. Se3 5e4+
  15. Sd5 3c4>12
  16. a2 Se1
  17. d3> 2d4-
  18. 1e3< 2e4-

Alternate Rule Objects (e.g. to test FPA solutions)

The USTak Association has set up a committee to test and evaluate solutions to first player advantage (mostly, but not solely in regards to tournaments). To test those, it would be of great help, if people could select alternate game rules when creating games. The idea is to attach rule objects to all games starting with the introducing patch. That class would define things like turn order, for instance. Ultimately they would regulate the flow of any in progress games, and the respective identifier for that rule would be stored with the database entry, to identify this game as variation game, and signify which variation was played.
The class could then be extended to represent different rules and prototypes could server as copy-blueprints for the objects actually used in the games. This would be both a server- and client side modification, and heavily impact the way the server functions. The potential benefits are that we have the chance to test rules otherwise not practically testable with a large number of players.

I can modify the server myself and send you the pull request for review, but truth be told, it would probably require a lot of modifications to solidly implement. I would set it up with a bunch of JUnit tests to prove base functionality. Would you consider taking those changes into consideration?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.