Mike Dilger on Nostr: I just whipped up a chess server, running on wss://chorus.mikedilger.com:444/ using ...
I just whipped up a chess server, running on wss://chorus.mikedilger.com:444/ using all ephemeral events, no access control required.
I was having a horrible week, doing huge coding but getting no wins and probably have to throw out my efforts. I really needed a win. So I did this chess thing which was (for me) easy with super rapid progress.
Here is the protocol, anybody can write a client for this. People connect and get paired up and play each other. There is no fancy Elo score matching yet. Nor did I write a client yet. Just the server... which is currently running and listening for chess events tagging this pubkey(hex): dbb45efeb8cc10e6f75fdff7e561e7db39cc7ba6592f4c22e26f3ee36b2e7bc2
(NIP-64 is not related to this work... yet)
Please somebody write a nice client.
// Event kinds (not yet allocated in nostr)
const REQ_TO_PLAY: EventKind = EventKind::Ephemeral(20300);
/*
* {
* "pubkey": <player-asking>,
* "kind": 20300,
* "tags": [
* ["p", <server-pubkey>],
* ],
* "content": "",
* ...
* }
*/
const RESP_TO_PLAY: EventKind = EventKind::Ephemeral(20301);
/*
* {
* "pubkey": <server>,
* "kind": 20301,
* "tags": [
* ["p": <player-asking>],
* ],
* "content": "queued", // 'queued' or 'error:<error>' or 'started:<d-tag-of-game>'
* ...
* }
*
*/
const GAME_STATE: EventKind = EventKind::Ephemeral(20302);
/*
* {
* "pubkey": <server>
* "kind": 20302,
* "tags": [
* ["d": <game-id>],
* ["p": <pubkey-for-white>],
* ["p": <pubkey-for-black>],
* ],
* "content": <FEN>,
* ...
* }
*/
const GAME_MOVE: EventKind = EventKind::Ephemeral(20303);
/*
* {
* "pubkey": <player>,
* "kind": 20303,
* "tags": [
* ["d": <game-id>],
* ["e": <last-game-state-event-being-reacted-to>],
* ["p", <server-pubkey>],
* ["p": <pubkey-for-white>],
* ["p": <pubkey-for-black>],
* ],
* "content": <long-algebraic-move>, // or various other signals like 'quit' TBD.
* ...
* }
*/
const GAME_ERROR: EventKind = EventKind::Ephemeral(20304);
/*
* 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>
* ...
* }
*/
Published at
2024-08-29 00:33:42Event JSON
{
"id": "3b514e677c7d88069f1e6040aa1606cdaca0d3460883319b54662f84cf05bc86",
"pubkey": "ee11a5dff40c19a555f41fe42b48f00e618c91225622ae37b6c2bb67b76c4e49",
"created_at": 1724891622,
"kind": 1,
"tags": [],
"content": "I just whipped up a chess server, running on wss://chorus.mikedilger.com:444/ using all ephemeral events, no access control required.\n\nI was having a horrible week, doing huge coding but getting no wins and probably have to throw out my efforts. I really needed a win. So I did this chess thing which was (for me) easy with super rapid progress.\n\nHere is the protocol, anybody can write a client for this. People connect and get paired up and play each other. There is no fancy Elo score matching yet. Nor did I write a client yet. Just the server... which is currently running and listening for chess events tagging this pubkey(hex): dbb45efeb8cc10e6f75fdff7e561e7db39cc7ba6592f4c22e26f3ee36b2e7bc2\n\n(NIP-64 is not related to this work... yet)\n\nPlease somebody write a nice client.\n\n\n// Event kinds (not yet allocated in nostr)\nconst REQ_TO_PLAY: EventKind = EventKind::Ephemeral(20300);\n/*\n * {\n * \"pubkey\": \u003cplayer-asking\u003e,\n * \"kind\": 20300,\n * \"tags\": [\n * [\"p\", \u003cserver-pubkey\u003e],\n * ],\n * \"content\": \"\",\n * ...\n * }\n*/\n\nconst RESP_TO_PLAY: EventKind = EventKind::Ephemeral(20301);\n/*\n * {\n * \"pubkey\": \u003cserver\u003e,\n * \"kind\": 20301,\n * \"tags\": [\n * [\"p\": \u003cplayer-asking\u003e],\n * ],\n * \"content\": \"queued\", // 'queued' or 'error:\u003cerror\u003e' or 'started:\u003cd-tag-of-game\u003e'\n * ...\n * }\n *\n */\n\nconst GAME_STATE: EventKind = EventKind::Ephemeral(20302);\n/*\n * {\n * \"pubkey\": \u003cserver\u003e\n * \"kind\": 20302,\n * \"tags\": [\n * [\"d\": \u003cgame-id\u003e],\n * [\"p\": \u003cpubkey-for-white\u003e],\n * [\"p\": \u003cpubkey-for-black\u003e],\n * ],\n * \"content\": \u003cFEN\u003e,\n * ...\n * }\n */\n\nconst GAME_MOVE: EventKind = EventKind::Ephemeral(20303);\n/*\n * {\n * \"pubkey\": \u003cplayer\u003e,\n * \"kind\": 20303,\n * \"tags\": [\n * [\"d\": \u003cgame-id\u003e],\n * [\"e\": \u003clast-game-state-event-being-reacted-to\u003e],\n * [\"p\", \u003cserver-pubkey\u003e],\n * [\"p\": \u003cpubkey-for-white\u003e],\n * [\"p\": \u003cpubkey-for-black\u003e],\n * ],\n * \"content\": \u003clong-algebraic-move\u003e, // or various other signals like 'quit' TBD.\n * ...\n * }\n */\n\nconst GAME_ERROR: EventKind = EventKind::Ephemeral(20304);\n/*\n * If the game is known, and the error event came from a player of the game:\n * {\n * \"pubkey\": \u003cserver\u003e,\n * \"kind\": 20304\n * \"tags\": [\n * \"e\": \u003cevent-that-was-in-error\u003e,\n * \"d\": \u003cgame-id\u003e, // if relevant (not present if game not found)\n * \"p\": \u003cpubkey-for-white\u003e, // if game not found, this is the author of event reacted to\n * \"p\": \u003cpubkey-for-black\u003e, // only if game was found, this is the other player\n * ],\n * \"content\": \u003cerror message\u003e\n * ...\n * }\n *\n * If the game is not known:\n * {\n * \"pubkey\": \u003cserver\u003e,\n * \"kind\": 20304\n * \"tags\": [\n * [\"e\": \u003cevent-that-was-in-error\u003e],\n * [\"p\": \u003cpubkey-of-error-event\u003e],\n * ],\n * \"content\": \u003cerror message\u003e\n * ...\n * }\n */\n",
"sig": "efdaadc4fc0bd8d0e995070e1a1174b3909e9f0ddc320f49d88a3c9aa83d72074e1e4c9c0a393ebcf0ad1be1deda1bfee538b41722f56102091a736fb71fa08f"
}