Skip to content

Commit

Permalink
docs: added protocol specification
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashley Huxley committed Jul 7, 2024
1 parent 9b4e6cb commit 0ec2875
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions protocol.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Protocol Specification

The game communicates actions to the other flipper using an array of three bytes. The first byte indicates the player and the action that the player performed. The second two bytes contain the X and Y coordinates of the location of that action.

## First Byte

| Bit | Description |
| ----| ----------- |
| 0 | Unused |
| 1 | Unused |
| 2 | Unused |
| 3 | Player |
| 4-7 | Action |

The 3rd bit denotes the player:

0. Fox
1. Wolf

Bits 4-7 denote the action:

| Value | Action |
| -------| ------------------------------------------------------------------- |
| 0b0000 | (Reserved) |
| 0b0001 | The player moved to the location specified in bytes 2 and 3 |
| 0b0010 | The player dropped a bomb at the location specified in bytes 2 and 3|
| 0b0011 | The player died. (Location bytes unused and should be set to 0x00) |

### Example:

**0x11 0x02 0x03**
The wolf has moved to position (2, 3)

**0x02 0x05 0x01**
The fox has placed a bomb in position (5, 1)

**0x13 0x00 0x00**
The wolf has died

0 comments on commit 0ec2875

Please sign in to comment.