1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-04 06:23:13 +03:00
juvix/examples/milestone/TicTacToe
2023-02-21 20:40:09 +01:00
..
CLI Format examples (#1856) 2023-02-21 20:40:09 +01:00
Logic Format examples (#1856) 2023-02-21 20:40:09 +01:00
Web Format examples (#1856) 2023-02-21 20:40:09 +01:00
juvix.yaml Restructure the documentation and add a tutorial (#1718) 2023-01-19 13:28:21 +01:00
README.org Add documentation for compiling/running the TicTacToe example (#1664) 2022-12-13 11:14:56 +00:00
TicTacToe.juvix Run the new Juvix formatter for all the Juvix examples (#1764) 2023-01-25 13:52:04 +01:00

TicTacToe

TicTacToe

This directory contains Juvix code for a Tic-Tac-Toe game that can be run as a terminal application or a Web application.

The common logic code is in Logic/, the code specific to the terminal application is in CLI/ and the code specific to the Web application is in Web/.

Terminal application

To compile and run the terminal application use the following steps:

cd CLI
juvix compile TicTacToe.juvix
./TicTacToe

You will see the following output:

MiniTicTacToe
-------------

Type a number then ENTER to make a move

+---+---+---+
| 1 | 2 | 3 |
+---+---+---+
| 4 | 5 | 6 |
+---+---+---+
| 7 | 8 | 9 |
+---+---+---+
Player X:

Web application

To compile the Web application use the following steps:

cd Web
juvix compile -t wasm -r standalone TicTacToe.juvix

To run the Web application you must first serve the files in the Web/ directory, using Python for example:

python3 -m http.server

Then navigate to http://localhost:8000 in your browser.