|
1 | 1 |
|
2 |
| -## Rock-Paper-Scissors |
| 2 | +# Rock, Paper, Scissors (RPS) with Bitcoin Protocol |
3 | 3 |
|
4 |
| -Rock-Paper-Scissors is an interactive game between two players who lock some money into a UTXO, and then proceed to play the game; the winner will get the sats. |
| 4 | +This script implements the Rock, Paper, Scissors game based on a protocol described [here](https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2023-May/021599.html). |
5 | 5 |
|
6 |
| -Play as Alice: |
7 | 6 |
|
8 |
| -```console |
9 |
| -$ python rps.py --alice --rock |
| 7 | +## Prerequisites |
| 8 | + |
| 9 | +After following the [root prerequisites](../..#prerequisites), make sure to install the additional requirements: |
| 10 | + |
| 11 | +```bash |
| 12 | +$ pip install -r requirements.txt |
10 | 13 | ```
|
11 | 14 |
|
12 |
| -On a separate terminal, play as Bob: |
| 15 | +## How to Run: |
13 | 16 |
|
14 |
| -```console |
15 |
| -$ python rps.py --alice --scissors |
| 17 | +The game can be played as either Alice or Bob, and you can specify your move (rock, paper, scissors). Additionally, other options like non-interactive mode and automatic mining can be set. |
| 18 | + |
| 19 | +```bash |
| 20 | +python rps.py --alice/--bob [--rock/--paper/--scissors] [--non-interactive] [--mine-automatically] [--host HOST] [--port PORT] |
16 | 21 | ```
|
17 | 22 |
|
18 |
| -The two scripts will communicate via a socket in order to coordinate the initial UTXO creation; once the game is funded, they take turns to spend it according to the rules. |
| 23 | +In order to play a game, run `python rps.py --alice` on a shell, and `python rps.py --bob` on a separate shell. |
| 24 | + |
| 25 | +The two scripts will establish a socket to communicate and negotiate a game UTXO. |
| 26 | + |
| 27 | +Once the UTXO is funded (NOTE: it must be funded externally), the two scripts proceed to play the game. |
| 28 | + |
| 29 | +### Arguments: |
| 30 | + |
| 31 | +- `--alice` / `--bob`: Specify the player you want to play as. |
| 32 | +- `--rock` / `--paper` / `--scissors`: Specify your move. If ommitted, a random move is chosen. |
| 33 | +- `--non-interactive`: Run in non-interactive mode (if not enabled, the user has to confirm each action). |
| 34 | +- `--mine-automatically`: Enable automatic mining when transactions are broadcast. |
| 35 | +- `--host`: Specify the host address (default is `localhost`). |
| 36 | +- `--port`: Specify the port number (default is `12345`). |
0 commit comments