Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a chess game in Hydra head #1098

Closed
abailly-iohk opened this issue Oct 4, 2023 · 11 comments
Closed

Implement a chess game in Hydra head #1098

abailly-iohk opened this issue Oct 4, 2023 · 11 comments
Assignees
Labels
app An application or tool built on top of Hydra Head red 💣 💥 ⁉️ Very complex, risky or just not well understood feature 💬 feature A feature on our roadmap

Comments

@abailly-iohk
Copy link
Contributor

abailly-iohk commented Oct 4, 2023

NOTE: Re-iterated this into multiple increments, the first being:

Why

  • We want to "eat our own dog food", eg. use the technology we are building on a daily basis in order to:
    • Test our own stuff
    • Improve the overall user experience, even though developers can tolerate more complex UIs than the average user
    • Experience running an app/system
  • Games where plays are run in a Hydra head with only results/leaderboards being kept on L1 seem a good use case for Hydra Head protocol
  • Chess being a well-known deterministic game, with simple rules, few players, easy to build interface, is a good candidate
  • Yet it's also challenging to provide a great UX so that it's fast and easy to setup a game
  • We want to improve the DX for people wanting to build stuff on top of Hydra, this app will be a "reference DApp", something we can point people at and refer to when improving Hydra

What

  • Implement an application that allow 2 players to play a Chess game remotely in a Hydra Head and record the result on L1
  • The application should be easy to install even for users unfamiliar with cardano-node and hydra-node
    • Having a short and sweet README.md on a dedicated repository (e.g. hydra-chess) could be a good goal post here.
  • The UI provided can be a simple TUI or even a CLI, but there should be a proper API to make it easy for anyone to build a proper UI, whether web-based or for desktop deployment
  • A player should not be able to Close the head to avoid losing a game
  • It must be possible to play on mainnet with minimal funds, eg. playing a game should cost a minimal amount of ADAs

Acceptance criteria

Here is the basic scenario this feature should cover:

  • Two users want to play one or more Chess game using Cardano
  • They can build the hydra-chess on their machines or download pre-built binaries when/if available
  • They run the hydra-chess application locally selecting which public network to run on which provides some command-line interface
  • They can exchange connectivity information provided by the interface and use that to configure known peers
  • Once peers are configured on both sides, they can
    1. initialise a new head
    2. start a new game once the head is opened
    3. play game using some simple interface and board display
    4. see the result of the game
    5. start and play one or more other games in the head
    6. close the head once they don't want to play anymore
    7. have the game(s) results be reflected on L1

Requirements:

  • OS support limited to Linux/Mac OS
  • Users should have a good knowledge on their machine and network configuration (eg. be able to tweak firewall to let other people connect to their node)
  • Application should be easy to download and build (eg. easier than say cardano-node or hydra-node)
@abailly-iohk abailly-iohk added the 💭 idea An idea or feature request label Oct 4, 2023
@abailly-iohk abailly-iohk self-assigned this Oct 4, 2023
@abailly-iohk abailly-iohk added amber ⚠️ Medium complexity or partly unclear feature app An application or tool built on top of Hydra Head labels Oct 4, 2023
@ltouro
Copy link

ltouro commented Oct 4, 2023

Suggestions:

  • Time plays a crucial role in online chess. Bullet/Blitz/Speed chess are the most popular in online setting. Thus, 'Time control' would be great to have.
  • The same Hydra head should handle multiple games between two players (i.e. a Head equals to a chess session).

@abailly-iohk
Copy link
Contributor Author

  • Time plays a crucial role in online chess. Bullet/Blitz/Speed chess are the most popular in online setting. Thus, 'Time control' would be great to have.

I am a lame Chess player and unfamiliar with the existing online landscape, thanks a lot for the pointers! Fortunately, Hydra Heads now have a notion of time, albeit with a large granularity, so we could already provide this feature.

  • The same Hydra head should handle multiple games between two players (i.e. a Head equals to a chess session).

🤔 I would think a single Head would hold a single game to be simpler and more obvious but that seems perfectly possible. Perhaps in v2 :)

@abailly-iohk
Copy link
Contributor Author

On second thought, running several games in sequence seems pretty straightforward and should be part of v1.

@abailly-iohk
Copy link
Contributor Author

A few months ago, I have started working on a Black Jack game, which could easily be repurposed to support Chess: https://github.com/abailly/black-jack
The core idea is to have the rules implemented in PlutusTx be reusable from Haskell code, and abstract away the details of interacting with the hydra cluster.

@abailly-iohk abailly-iohk changed the title Implement Chess in Hydra head Implement a 2-player deterministic game in Hydra head Oct 12, 2023
@ch1bo ch1bo added 💬 feature A feature on our roadmap and removed 💭 idea An idea or feature request labels Nov 7, 2023
@abailly-iohk
Copy link
Contributor Author

Links to some early Miro drawings: https://miro.com/app/board/uXjVMA_OXQ0=/?moveToWidget=3458764561779396079&cot=14

@ch1bo ch1bo added red 💣 💥 ⁉️ Very complex, risky or just not well understood feature and removed amber ⚠️ Medium complexity or partly unclear feature labels Nov 7, 2023
@ch1bo
Copy link
Member

ch1bo commented Nov 21, 2023

Links to some early Miro drawings: https://miro.com/app/board/uXjVMA_OXQ0=/?moveToWidget=3458764561779396079&cot=14

Pasting this here as it might not be accessible to everyone:
image

@ch1bo
Copy link
Member

ch1bo commented Nov 21, 2023

Had a quick look around for some suitable UIs:

Maybe we want to do it in Elm?

@abailly-iohk
Copy link
Contributor Author

Are you aware of https://github.com/mpizenberg/elm-cardano/ ?

@Pdest08
Copy link

Pdest08 commented Nov 22, 2023

Why not use something like beacon tokens for peer discovery to identify players who want to play a match. Player dApp indexes on-chain requests to play (they specify what skill level match they want, game type [speed chess, regular match]).

cardano-foundation/CIPs#466

@abailly-iohk
Copy link
Contributor Author

Indeed, the current idea is to have each player be represented on-chain through a dedicated token. My first idea was to hold the ELO score of the player but indeed we could add more metadata either encoded in the token name or the txs' metadata.
Note however that this token will be committed to a head for the purpose of playing, and redistributed back once the game ends (TBH I still don't have the full mechanics of the game sorted out 😄 ) through the usual Head protocol's Fanout mechanism hence there will be a period of time, while playing a game, where the player won't be in control of the delegation of their assets which is one purpose of the CIP you mentioned.
I don't think this is a big issue as I don't envision people tying a lot of ADAs into their game token but this again points at some limitation we are aware of about the Head protocol: Who decides how the funds locked in a Head are delegated?

@abailly-iohk abailly-iohk changed the title Implement a 2-player deterministic game in Hydra head Implement a chess game in Hydra head Jan 8, 2024
@ch1bo
Copy link
Member

ch1bo commented Jan 9, 2024

We have broken down and re-iterated this original feature idea into two concrete steps we are currently taking / seeing: #1237 and #1238

@ch1bo ch1bo closed this as not planned Won't fix, can't repro, duplicate, stale Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app An application or tool built on top of Hydra Head red 💣 💥 ⁉️ Very complex, risky or just not well understood feature 💬 feature A feature on our roadmap
Projects
Archived in project
Development

No branches or pull requests

5 participants