leo/examples/tictactoe
d0cd 751e79a66e More fixes to example scripts
WIP scripts

WIP alias leo

WIP alias leo

WIP alias leo
2023-02-16 12:51:19 -08:00
..
inputs unify leo examples with workshop, run all examples in circleci 2022-09-21 15:59:33 -07:00
src Rename console.assert* to assert*. (#2205) 2022-12-06 21:56:48 -08:00
.gitignore [examples] A tic-tac-toe app. 2022-08-04 15:08:05 -07:00
program.json Update tictactoe example 2022-09-19 19:30:11 -07:00
README.md Rename examples 2022-09-30 10:37:29 -07:00
run.sh More fixes to example scripts 2023-02-16 12:51:19 -08:00

workshop/tictactoe

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 Rows. 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
leo run <function_name> <input_1> <input_2> ...

See ./run.sh for an example.

Using an input file.

  1. Modify inputs/tictactoe.in with the desired inputs.
  2. Run
leo run <function_name>