/df-wizard-chess

๐Ÿง™ Dialogflow fulfillment for Wizard Chess

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

Wizard Chess w/ Dialogflow

Gitter Build Status codecov Dependabot Status Code style: black

๐Ÿค” What is Wizard Chess?

To truly understand, I will have you read this

What do you do when you really want to play blindfold chess but you're stuck at home? ๐Ÿ 

Ask your chess friends - easy ๐Ÿ‘จโ€๐Ÿ‘จโ€๐Ÿ‘งโ€๐Ÿ‘ฆ

They don't like blindfold ๐Ÿคท

Google for an online solution ๐Ÿ’ป, there are so many chess apps. There has to be one about blindfold chess.

Pbbt ๐Ÿ‘… There ain't one.

What about.. the popular ones?

They say "hide your pieces, it's just like blindfold chess ๐Ÿ˜‡"

Ugh - that's a scam

I have to do something about this.. ๐Ÿ‘จโ€๐Ÿ”ง๐Ÿณ

Wizard Chess is that something. The goal is to provide the best blindfold chess experience. That is, to have anything you might need while playing blindfold chess - be it a platform to play, a platform to learn, or a platform to further develop your prowess. See ๐Ÿง How do you do it? for the technical details.

Wizard Chess is already available as a Google Action! See ๐Ÿ„๐Ÿฝโ€โ™‚๏ธ Where can I play? to know more.

๐Ÿง How do you do it?

We use the wizardry ๐Ÿ”ฎ of AI assistants and chatbots to interact with the user. When a user talks to our AI asssistant, the message is forwarded to Dialogflow. It processes the request from the assistant - intelligently, with machine learning - and sends it to our webhook. Now our server uses this cooked data to generate a response and sends it back to Dialogflow which in turn sends it to the assistant. The whole process basically looks like this:

    User ======= |AI assistant/chatbot| <-------> |Dialogflow| <-------> |THIS SERVER| ๐Ÿ’ช

Examples of operations done on our end are creating and storing chess games in a database, receiving a move and updating the board accordingly, and generating responses for the user.

๐Ÿ„๐Ÿฝโ€โ™‚๏ธ Where can I play?

The app is already available for the Google Assistant here. You can even launch the app without touching the link at all, just say Talk to Wizard Chess to your Google Assistant to boot up the Action.

More platforms coming soon! Let me know via email or Gitter if you want to see Wizard Chess on a particular platform so that we can prioritize it.

๐Ÿ“• How do I play?

Upon starting the Wizard Chess Action (by saying Talk to Wizard Chess), you will be asked to choose the side you'd like to play as and the assistant will present you with a list of three options: White, Black and Random. Now you can either select an option by touch or say your choice out loud. The latter even works with devices which don't have a screen (e.g. Google Home).

Playing moves

The system to interpret moves is very lenient and allows you to choose how you want to say the move.

Here's a short list of how you can describe your moves:

  • Long descriptive format - e.g. Knight from g1 to f3 or Pawn e4 captures d5 or even without mentioning the piece d5 takes c4
    • For pawn promotion, you can add the name of the promotion piece to the end - that is, Pawn from d7 to d8 queen or b2 takes c1 queen
  • Shorter format with just the piece and square - e.g. Knight to d4 or Queen takes f6
    • Pawn promotion is supported in the same way as above
    • Note that you will be notified by the assistant if your move is ambiguous. This usually means that there were more than one moves which matched your description - for example when two knights can come to the mentioned square and you didn't specify which one.
  • Pawn moves by the squares they want to move to - e.g. e4, g3
  • Short Algebraic Notation (SAN) - e.g. Bd6, Nbd7
  • Long Algebraic Notation (LAN) - e.g. e2-e4, Nf6xe4, O-O

Note: The app doesn't yet support descriptive moves like Knight b to d7 or e takes d5. In that case you should use the long descriptive format of move by mentioning the actual square the piece was at - e.g. knight b8 to d7 and e4 takes d5

Castling

You can castle by telling the assistant to castle and mentioning the side you want to castle on.

Some examples: Castle short, Castle kingside, Long castling, Castle to the queen's side

If you don't mention which side you want to castle on (just castles), castling will be performed on whichever side is legal, defaulting to the kingside in case both are legal.

Undoing the moves

You can easily undo your last move by saying Undo move, take back my last move, etc.

Seeing the board

You are also given the option to take a peek at the board. To do that just say something like show me the board or let me see the board to the assistant.

Resignation

You can resign at any time by just saying resign.

๐Ÿ”ง Contributing

Use the issue tracker to suggest new features or report bugs. Feel free to directly create pull requests for small changes and typos. Create an issue before opening larger pull requests so that the changes can be discussed beforehand. The latest Dialogflow agent can be downloaded from <link to be updated>.

โฐ Changelog

0.2.0 - 16/05/2020

  • Moved from SQLite to Postgres with SQLAlchemy
  • Bug fixes in show_board
  • Bug fixes with session_id handling
  • Added feature to accept SAN (or overspecified SAN) moves
  • Fixed bug which caused stale result comment after engine's move
  • Added feature to accept move when only a piece and square are mentioned
  • Fixed bug which made app to crash when square had capital letters (A4, D5 etc.)
  • Edited show board feature to flip board when user is playing as black

0.1.1 - 07/05/2020

  • Set up Travis CI
  • Set up coverage reporting with Codecov
  • Moved from using Dict in memory to sqlite3 DB on disk ๐ŸŽ‰
  • Added testing to cover more than 90% of codebase ๐Ÿ’ช
  • Added feature to see board at any time ๐Ÿ‘๏ธ
  • Board image will be shown after completion of games ๐Ÿ“œ

0.1.0 - 27/04/2020

  • Format according to Black formatting tool
  • Basic functionality to play a game as a Google Action
  • Voice-activated ability to castle, promote pawn, and play move when at least the two squares involved in the move are given.
  • Works with games stored in memory as Dict data type. Considering move to sqlite in future versions
  • Unit tests added for most basic functions. More tests required for functions which handle intents.

License

Licensed under GNU General Public License 3.0 (GPL-3.0). See LICENSE for full text.