Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hilliamt/homedao-aleo-tictactoe
https://github.com/hilliamt/homedao-aleo-tictactoe
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/hilliamt/homedao-aleo-tictactoe
- Owner: HilliamT
- Created: 2023-10-22T21:47:25.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-22T21:47:47.000Z (about 1 year ago)
- Last Synced: 2024-04-14T10:33:21.568Z (7 months ago)
- Language: Shell
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[//]: # ()
A standard game of Tic-Tac-Toe in Leo.
⭕ ❕ ⭕ ❕ ❌
➖ ➕ ➖ ➕ ➖
⭕ ❕ ❌ ❕ ⭕
➖ ➕ ➖ ➕ ➖
❌ ❕ ❌ ❕ ⭕
## Representing State
Leo allows users to define composite data types with the `struct` keyword.
The game board is represented by a struct called `Board`, which contains three `Row`s.
An alternative representation would be to use an array, however, these are not yet supported in Leo.## Language Features
- `struct` declarations
- conditional statements
- early termination. Leo allows users to return from a function early using the `return` keyword.## Running the Program
Leo provides users with a command line interface for compiling and running Leo programs.
Users may either specify input values via the command line or provide an input file in `inputs/`.### Providing inputs via the command line.
1. Run
```bash
leo run ...
```
See `./run.sh` for an example.### Using an input file.
1. Modify `inputs/tictactoe.in` with the desired inputs.
2. Run
```bash
leo run
```## Executing the Program
```bash
leo execute ...
```## Playing the Game
### 1. Create a new game board
```bash
leo run new
```
| | | |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 0 | 0 |
| 0 | 0 | 0 |### 2. Player 1 makes a move
```bash
leo run make_move 1u8 1u8 1u8 "{ r1: { c1: 0u8, c2: 0u8, c3: 0u8 }, r2: { c1: 0u8, c2: 0u8, c3: 0u8 }, r3: { c1: 0u8, c2: 0u8, c3: 0u8 } }"
```
| | | |
|---|---|---|
| 1 | 0 | 0 |
| 0 | 0 | 0 |
| 0 | 0 | 0 |### 3. Player 2 makes a move
```bash
leo run make_move 2u8 2u8 2u8 "{ r1: { c1: 1u8, c2: 0u8, c3: 0u8 }, r2: { c1: 0u8, c2: 0u8, c3: 0u8 }, r3: { c1: 0u8, c2: 0u8, c3: 0u8 } }"
```
| | | |
|---|---|---|
| 1 | 0 | 0 |
| 0 | 2 | 0 |
| 0 | 0 | 0 |