Skip to content

Comment on Show HN: Termichess – Play chess in your terminal

Comments

Why reinvent a graphical interface in the terminal? If we are playing chess in the terminal, we are likely happy to accept abstractions and such. You could use normal letters for the different pieces, perhaps using lowercase for black and uppercase for white. Even the "grid" could be an optional setting, placing a slight emphasis on user skill in being able to visualize the grid on their own.

    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 assume you'd just use the unicode chess symbols, nowadays? (https://en.wikipedia.org/wiki/Chess_symbols_in_Unicode)

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.

There was some trouble in scaling unicode text within the layout. Unfortunately increasing `font-size` is not trivial within the context of terminal. There are some ways around this , but i figured out that it's far more easier to render chess pieces as pixel images using `rich-pixels` [1]

[1] https://github.com/darrenburns/rich-pixels

That makes a ton of sense. Kudos on tackling a lot of issues in making this!

I think the unicode chess symbols are not quite in the spirit of terminal applications. It is also more intuitive to move the rook using algebraic notation, if the rook is denoted by r, rather than "♜". But certainly, viewing the board using unicode symbols is a very reasonable user setting, but I would err that it would not be default.

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.

Totally fair. It also reminded me that emacs has a chess package. Because of course it does. :D

I did start initially with something like this, but then i sort of stumbled upon `chess-tui` and I was mostly trying to see if i can build something similar.

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.

I wrote cboard, a simple text-mode frontnend for playing with UCI engine, which basically works the way you describe. It is part of the Haskell chessIO package.

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.

Even the "grid" could be an optional setting, placing a slight emphasis on user skill in being able to visualize the grid on their own.

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
    echo

I'm going to assume this produces a grid. Once again, we are reinventing a graphical user interface. If we wanted all this, why wouldn't we open firefox and go to chess.com or lichess.org. Or even something that runs natively on your computer, perhaps even producing lavish and beautiful 2d or 3d rendering of the game.

Why reinvent a graphical interface in the terminal?

Pattern recognition

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.