GithubHelp home page GithubHelp logo

tictactoe's Introduction

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>

Executing the Program

leo execute <function_name> <input_1> <input_2> ...

Playing the Game

1. Create a new game board

leo run new
0 0 0
0 0 0
0 0 0

2. Player 1 makes a move

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

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

tictactoe's People

Contributors

farzinfara avatar

Watchers

 avatar

tictactoe's Issues

Sorry, this issue was spam.

I'm sorry to inform you that my GitHub token was compromised, leading to the creation of spam posts. Upon discovering this, I took action to close the issue and correct the content.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.