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

Chess server #1453

Open
mikedilger opened this issue Aug 29, 2024 · 1 comment
Open

Chess server #1453

mikedilger opened this issue Aug 29, 2024 · 1 comment

Comments

@mikedilger
Copy link
Contributor

mikedilger commented Aug 29, 2024

To get a win today I wrote a chess server. I had to invent the protocol, and I went with this (this doesn't overlap with NIP-64):

[EDITED AS I CHANGED THE EVENTS A BIT]

Request to play:

{
    "pubkey": <player-asking>,
    "kind": 20300,
    "tags": [
         ["p", <server-pubkey>],
    ],
    "content": "",
     ...
}

Response to the request to play
where status is one of:
* queued
* error:<error>
* started:<d-tag-of-game>:<opponent-pubkey>:<b|w>
This event is sent to both the player asking, and the player queued that was roped in as the opponent.

{
   "pubkey": <server>,
   "kind": 20301,
   "tags": [
       ["p": <player-asking-or-their-opponent>],
   ],
   "content": <status-see-above>,
   ...
}

Game state (sent by the server initially and after every legal move). Initially it should come after the response to request to play.
FEN is https://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation

{
    "pubkey": <server>
    "kind": 20302,
    "tags": [
        ["d": <game-id>],
        ["p": <pubkey-for-white>],
        ["p": <pubkey-for-black>],
    ],
    "content": <FEN>,
    ...
}

Game Move
long algebraic move notation is https://en.wikipedia.org/wiki/Algebraic_notation_(chess)#Long_algebraic_notation
(but without captures or piece notation or check notation... just the source and dest and maybe a promotion piece after that, e.g. e7e8Q)

{
    "pubkey": <player>,
    "kind": 20303,
    "tags": [
        ["d": <game-id>],
        ["p", <server-pubkey>],
        ["p": <pubkey-for-white>],
        ["p": <pubkey-for-black>],
    ],
    "content": <long-algebraic-move>, // or various other signals like 'quit' TBD.
    ...
}

Game error, If the game is known, and the error event came from a player of the game:

{
    "pubkey": <server>,
    "kind": 20304
    "tags": [
        ["e": <event-that-was-in-error>],
        ["d": <game-id>], // if relevant (not present if game not found)
        ["p": <pubkey-for-white>], // if game not found, this is the author of event reacted to
        ["p": <pubkey-for-black>], // only if game was found, this is the other player
    ],
    "content": <error message>
    ...
}

If the game is not known:

{
    "pubkey": <server>,
    "kind": 20304
    "tags": [
        ["e": <event-that-was-in-error>],
        ["p": <pubkey-of-error-event>],
    ],
    "content": <error message>
    ...
}

I am running it right now here:

pubkey: dbb45efeb8cc10e6f75fdff7e561e7db39cc7ba6592f4c22e26f3ee36b2e7bc2
relay:  wss://chorus.mikedilger.com:444/

We could add this to NIP-64 (or something like it).

@mikedilger
Copy link
Contributor Author

I wrote a command line client and played with myself.

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

1 participant