I have been trying to build a terminal based app for sometime now and this is an attempt at trying to build a chess app that one can play right inside terminal.
I was inspired by `chess-tui`[1] which is a rust based project and was looking to build something similar using python. Luckily I stumbled upon textual[2] recently and it made my task of building this far more easier than I thought.
[1] https://github.com/thomas-mauran/chess-tui [2] https://github.com/textualize/textual
A B C D E F G H
8 r n b q k b n r
7 p p p p p p p p
6
5
4
3
2 P P P P P P P P
1 R N B Q K B N R
This to me feels more like truly playing chess in the terminal. Add a non-interactive session mode, for example "chesst game123 view" to produce a view of the game, and "chesst game123 e2 e4" to move the pawn infront of white king two squares up. Naturally moving a piece can by default also print the new board state, after the opponents move. Implicitly prompting you to move again, or to just leave the terminal and do something else.I'd also assume people would use https://en.wikipedia.org/wiki/Algebraic_notation_(chess) for the notation. No need to say "e2 e4" if "e4" is already non-ambiguous. Plus side for learning this notation is it can help read old games.
And "e2 e4" contains technically superflous information, yes. The application should be able to parse the most minimal algebraic notation possible, but also more verbose commands.
The first version was chess notation based movement. I got some initial feedback that it's probably not very useful. I still understand that most people would probably use chess.com or some other chess app if they want a full blown graphical experience and with terminal there are many limitations at play which would limit a full experience for such folks. But there is hopefully more interesting things that can be added to this such as your suggestions for viewing games that will make it more useful.
https://github.com/mlang/chessIO
And Emacs Chess (also known as chess.el) has a "chess-plain" board variant which is configurable down to which letters should be used. Borders are also optional, all configurable.
As a starting point (and only a few because this gets long and tedious to show) - it uses tput ( https://man7.org/linux/man-pages/man1/tput.1p.html https://www.gnu.org/software/termutils/manual/termutils-2.0/... )
#!/bin/bash
echo ' A B C D E F G H'
echo -n '1 '
tput mr
echo -n 'r'
tput me
echo -n ' n '
tput mr
echo -n 'b'
tput me
echoPattern recognition
Very cool program though :)
> 2. Qf3
Well maybe it was jus...
> 4. Nh3
I see...
I guess I'm stuck with the Sicilian. If anyone knows a way to make the Alapin wild and tactical as black, I'm listening.
So the board shrinks down as you reduce the size of window. Currently there is an issue in the chess pieces scaling down in size if we reduce the size of terminal. Showing images properly is quite tricky in terminal, hope to get to it sometime later this week.
> Need Keyboard support.
That's also something on my mind. Do you have any specific scenario in mind. I was thinking of hotkeys or chess notation as input.
If you write an XBoard-compatible terminal client, then it can just work with GNU chess and other back ends.