{"slug": "playing-chess-over-irc-from-emacs-even-against-a-bot", "title": "Playing chess over IRC from Emacs, even against a bot", "summary": "Developer Andros has fixed the broken IRC integration in the emacs-chess package and added a chess-irc-engage function so Emacs users can challenge each other by nick over a private IRC server, with the work submitted as PR #42 on the jwiegley/emacs-chess repository and still awaiting review. The setup requires an IRC server such as ngircd on port 6667 and Emacs 30 or later, with moves exchanged in algebraic notation like e4 and e5; the author warns the server has no password and recommends restricting access by firewall or VPN.", "body_md": "# Playing chess over IRC from Emacs, even against a bot\n\nAt work we have a sort of small chess club. We play some online games between colleagues, and afterwards we talk about the most notable moves. Most of us work remotely, so the routine is simple: we line up our calendars and, shortly after, we meet for an online game on a website like chess.com. Nothing complex, easy for everyone.\n\nThen, since some of my colleagues use Emacs, I asked myself: why not use it? Some time ago I wrote an article about [playing chess online with Emacs](https://en.andros.dev/blog/d8b3a759/playing-chess-online-with-emacs/). Among the different options, I explained that `chess` lets you play against the machine (with a simple but fun AI), over a local network, against ICS servers (platforms for playing online) and over IRC. Yes, through an IRC server! It uses a private conversation where commands and moves are sent. So, if we wanted to play among ourselves, all we would need is a daemon running an IRC server.\n\nRight, we need 2 pieces to play online:\n\n- An IRC server, such as ngircd.\n- The `chess` package installed in Emacs.\n\nThere was one problem, though: the IRC integration in `chess` was broken, so I fixed it. The branch of [PR #42](https://github.com/jwiegley/emacs-chess/pull/42) in `emacs-chess` is still waiting for review, but it works perfectly. I also added the `chess-irc-engage` function to challenge a friend by their nick.\n\nSo the flow of a game is as follows:\n\n```\nsequenceDiagram\n    participant A as Ana's Emacs\n    participant S as ngircd\n    participant P as Pepe's Emacs\n    A->>S: Connects as ana-chess\n    P->>S: Connects as pepe-chess\n    A->>S: Challenges pepe-chess\n    S->>P: \"Do you wish to play a chess game against Ana?\"\n    P->>S: Accepts\n    A->>S: e4\n    S->>P: e4\n    P->>S: e5\n    S->>A: e5\n```\n\n`e4` and `e5` are moves in algebraic notation: the file as a letter and the rank as a number.\n\nLet's set up the pieces on the board.\n\n## IRC server\n\nThe [ngircd](https://ngircd.barton.de/) server is written in C and is very lightweight. Installing it on Debian/Ubuntu is easy:\n\n```\nsudo apt install ngircd\n```\n\nReplace its configuration in `/etc/ngircd/ngircd.conf` with:\n\n```\n[Global]\n    Name = chess.example.org\n    Info = Private IRC for chess.el\n    Listen = 0.0.0.0\n    Ports = 6667\n    MotdPhrase = Chess only. Challenge with M-x chess-irc-engage\n    PidFile = /run/ngircd/ngircd.pid\n    ServerUID = irc\n    ServerGID = irc\n\n[Limits]\n    MaxNickLength = 20\n\n[Options]\n    PAM = no\n    DNS = no\n    Ident = no\n\n[Channel]\n    Name = #chess\n    Topic = Waiting room\n    Modes = tn\n```\n\nCheck the configuration:\n\n```\nsudo ngircd --configtest\n```\n\nand restart:\n\n```\nsudo systemctl restart ngircd\n```\n\nYou now have an IRC server for our chess club.\n\nThere is no password: anyone who reaches port 6667 can play, or start using it for malicious purposes. My advice is to restrict network access with a firewall that only allows your friends' IPs, or to put the server inside a VPN. I leave the decision in your hands.\n\nNow let's jump to the client.\n\n## Setting up Emacs\n\nYou need Emacs 30 or later. Add this to your `init.el`:\n\n```\n(use-package chess\n  :vc (:url \"https://github.com/tanrax/emacs-chess\"\n       :branch \"fix/chess-irc\"\n       :rev :newest)\n  :custom\n  (chess-irc-server \"chess.example.org\")\n  (chess-irc-port 6667)\n  (chess-irc-nick \"mynick-chess\")\n  (chess-full-name \"My Name\"))\n```\n\nReplace `chess.example.org` with the IP or domain of your IRC server, and `mynick-chess` with the nick you want to use.\n\nEvaluate it and your Emacs is ready to play.\n\nA game goes like this:\n\n1. You both run `M-x chess-irc` and press Enter at each prompt to accept the configured server, port and nick. You will see`Waiting for opponent — send /msg or use M-x chess-irc-engage` .\n2. The challenger runs `M-x chess-irc-engage` from the board and types the friend's nick, for example`pepe-chess` .\n3. The friend sees `Do you wish to play a chess game against My Name?` and answers`y` .\n4. Whoever wants white makes the first move. The other player will see `Your opponent played the first move, you are now black` .\n\nDuring the game you have some useful commands:\n\n| Action | Key | Command | \n|---|---|---|\n| Offer a draw | `C-c C-d` | `chess-display-draw` | \n| Resign | `C-c C-r` | `chess-display-resign` | \n| Ask to take back | `C-c C-t` | `chess-display-undo` | \n| Abort the game | `C-c C-a` | `chess-display-abort` | \n\nWant to talk to your opponent? Press `\"` on the board: a chat buffer opens, where you type each message and send it with Enter.\n\nAnd if you are brave, you can also challenge someone from any IRC client:\n\n```\n/msg mynick-chess chess match Pepe\n```\n\nMind you, you will then have to type your moves by hand, in algebraic notation. I think it can be fun if you have a physical board in front of you.\n\n## Bot\n\nIt could be fun to have an AI (not an LLM) to play with you: a special nick that is always online and ready for a game.\n\nFor that you need a headless chess engine. It is software that lets you play chess without a graphical interface, just by sending and receiving moves. Today, the strongest free one you can find is [Stockfish](https://stockfishchess.org/).\n\nHowever, Stockfish can only think about one move at a time. It cannot handle several games in parallel, and the bot may well be playing with several people at once. There are many solutions, but the simplest is a queue of move requests. Every time a player moves, the bot takes the whole game and sends it to a free engine, in order of arrival. When the engine finishes thinking, it returns the move to the bot, which sends it to the opponent. Luckily, the slowness of the human brain plays in our favour. While the human plans their move, the engine can be busy with another player's game.\n\n``` php\nflowchart LR\n    A[Ana's Emacs] <--> I[ngircd]\n    P[Pepe's Emacs] <--> I\n    I <--> B[Bot]\n    B --> Q[(Engine queue)]\n    Q --> S1[Stockfish 1]\n    Q --> S2[Stockfish 2]\n```\n\nIf you want a ready-to-use solution, I implemented it in the [chess-irc-bot](https://git.andros.dev/andros/chess-irc-bot) repository. A single command starts the ngircd server and the bots:\n\n```\ngit clone https://git.andros.dev/andros/chess-irc-bot.git\ncd chess-irc-bot\ndocker compose up -d --build\n```\n\nI set up 4 nicks, one per difficulty level.\n\n| Nick | Difficulty | \n|---|---|\n| `bot-easy` | Elo 1320 | \n| `bot-normal` | Elo 2000 | \n| `bot-hard` | Elo 2800 | \n| `bot-perfect` | Stockfish with no limits | \n\nWith `M-x chess-irc-engage` you can challenge any of them. If you want white, make the first move. If you prefer black, press the space bar to give the bot the first move.\n\n## Final notes\n\nThere are much more complex solutions with many more options, such as rankings. We are full of limitations:\n\n- **No encryption or authentication** : anyone who reaches the port can use someone else's nick.\n- **No arbiter** : each Emacs validates the moves and keeps its own clock.\n- **One connection per game** : each game opens an IRC connection with your nick, so two games at once need two nicks.\n- **No history** : games are not recorded, and there is no way to review them later.\n\nStill, it is enough to play with friends or against a good bot: it is built with a simple IRC server, a free chess engine and a few lines of Python. It is even a good option for small remote chess communities or federations.\n\nThe natural next step would be a simple TUI or GUI client that speaks the same IRC protocol, so you no longer depend on Emacs. A master move. For now I am happy playing with my colleagues and challenging the bots in my spare time.\n\nI only have one question left: white or black?\n\nThis work is under a [Attribution-NonCommercial-NoDerivatives 4.0 International license.](https://creativecommons.org/licenses/by-nc-nd/4.0/)\n\n## Help me keep writing\n\nEvery coffee gives me a push toward the next article.", "url": "https://wpnews.pro/news/playing-chess-over-irc-from-emacs-even-against-a-bot", "canonical_source": "https://en.andros.dev/blog/6981043b/playing-chess-over-irc-from-emacs-even-against-a-bot/", "published_at": "2026-11-30 10:29:27+00:00", "updated_at": "2026-11-30 10:45:20.412502+00:00", "lang": "en", "topics": ["developer-tools"], "entities": ["Emacs", "emacs-chess", "ngircd", "jwiegley", "Andros", "chess-irc-engage", "chess-irc", "PR #42"], "also_reported_by": [], "takeaway": "Emacs 30 users can install the fix/chess-irc branch of tanrax/emacs-chess via use-package :vc, set chess-irc-server, chess-irc-port and chess-irc-nick, then run M-x chess-irc and M-x chess-irc-engage to challenge an opponent by nick over ngircd on port 6667.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/playing-chess-over-irc-from-emacs-even-against-a-bot", "markdown": "https://wpnews.pro/news/playing-chess-over-irc-from-emacs-even-against-a-bot.md", "text": "https://wpnews.pro/news/playing-chess-over-irc-from-emacs-even-against-a-bot.txt", "jsonld": "https://wpnews.pro/news/playing-chess-over-irc-from-emacs-even-against-a-bot.jsonld"}}