♞ shinyChess - a Shiny app to play & study Chess. - Shiny Contest Submission

♞ shinyChess - a Shiny app to play & study Chess.

Authors: Almarch

Abstract: This app brings together:

  • a graphical chess board,
  • a chess rule engine,
  • the most powerful chess solver AI,

into a smooth, web-hosted Shiny app.

Either you wish to explore the subtle equilibrium of Masters' parties, either you need to come back on your own games, this app may assist you.

The game intends to facilitate interaction with a PGN records collection. Paste your PGN directly into the game, and study each move using the latest version of Stockfish :fish:

Full Description:

shinyChess

This is an app to play & study chess. It lies upon powerful tools:

  • The R library rchess, that wraps:
    • the chess engine chess.js. It ensures the game playability and rules integrity.
    • the chess graphical board chessboardjs. The board design comes from there.
  • The chess solver stockfish, wrapped into the eponymous R package. This is the AI that is used to analyse the parties and predict the next best move.
  • The web framework shiny. It supports the user interface and allow for web deployment.
chessboardjs stockfish Shiny

Play

The game can be played and is recorded using the Portable Game Notation (PGN). Select the next move using the drop list, and confirm with Play.

Navigate back and forth through the party using the navigation arrows.

Save and load the party

The party PGN is displayed on the first element of the lateral accordion. Save it to your clipboard using the Copy button; or load a new party from your clipboard using Paste.

For instance, copy the following PGN and load it in the app:

1.e4 c5 2.c3 d5 3.exd5 Qxd5 4.d4 Nf6 5.Nf3 Bg4 6.Be2 e6 7.h3 Bh5 8.O-O Nc6 9.Be3 cxd4 10.cxd4 Bb4 11.a3 Ba5 12.Nc3 Qd6 13.Nb5 Qe7 14.Ne5 Bxe2 15.Qxe2 O-O 16.Rac1 Rac8 17.Bg5 Bb6 18.Bxf6 gxf6 19.Nc4 Rfd8 20.Nxb6 axb6 21.Rfd1 f5 22.Qe3 Qf6 23.d5 Rxd5 24.Rxd5 exd5 25.b3 Kh8 26.Qxb6 Rg8 27.Qc5 d4 28.Nd6 f4 29.Nxb7 Ne5 30.Qd5 f3 31.g3 Nd3 32.Rc7 Re8 33.Nd6 Re1+ 34.Kh2 Nxf2 35.Nxf7+ Kg7 36.Ng5+ Kh6 37.Rxh7+

Openings

The R package rchess comes with a collection of openings. They are gathered in the drop list of the second element of the lateral accordion.

If an opening is played, its name will appear selected in the drop list. An opening may also be selected and played at any time. It then replaces the current party.

Game analysis

To analyze the game, from the third element or the lateral accordion: select the analysis time per move and click the launcher button. Be careful, even a few seconds make a long time for a long party.

The party is analyzed using Stockfish, one of the most powerful chess solver. The result is yielded as a plot.

The analysis plot takes all analyzed moves as x and the advantage in centipawn (cp) as y. The y axis is presented on a sigmoid scale. A positive value is an advantage for White and a negative value is an advantage for Black.

The vertical red line identifies the current move. On top, the exact advantage and the best next move are displayed. The party can be explored using the game navigation arrows.


Shiny app: https://Almarch.shinyapps.io/shinyChess/
Repo: GitHub - Almarch/shinyChess: A shiny interface to play and study chess

Thumbnail:
5b910232-df75-4f8c-b4cd-381a719049e2

Full image: