Immerse yourself in the classic Tic-Tac-Toe game, now implemented in the Leo programming language.
Leo's struct
functionality is utilized to construct the game board. This Board
struct consists of three Row
elements. While arrays could offer an alternative structure, they are not currently supported in Leo.
- Creation of structures (
struct
) - Implementation of conditional logic
- Function exits using
return
Leo's command line interface facilitates the compilation and execution of programs. Input can be provided either directly via the command line or through an input file located in inputs/
.
- Execute the command:
leo run <function_name> <input_1> <input_2> ...
Refer to ./run.sh
for an example.
- Alter
inputs/tictactoe.in
with the required inputs. - Execute the command:
leo run <function_name>
leo execute <function_name> <input_1> <input_2> ...
leo run new
0 | 0 | 0 |
0 | 0 | 0 |
0 | 0 | 0 |
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 |
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 |