diff --git a/tictactoe/.gitignore b/tictactoe/.gitignore
new file mode 100644
index 000000000..f721f7f6f
--- /dev/null
+++ b/tictactoe/.gitignore
@@ -0,0 +1,5 @@
+.env
+*.avm
+*.prover
+*.verifier
+outputs/
diff --git a/tictactoe/README.md b/tictactoe/README.md
new file mode 100644
index 000000000..84d6f7f33
--- /dev/null
+++ b/tictactoe/README.md
@@ -0,0 +1,82 @@
+
+
+[//]: # ()
+
+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 |
diff --git a/tictactoe/build/main.aleo b/tictactoe/build/main.aleo
new file mode 100644
index 000000000..2431ce383
--- /dev/null
+++ b/tictactoe/build/main.aleo
@@ -0,0 +1,237 @@
+program tictactoe.aleo;
+
+struct Row:
+ c1 as u8;
+ c2 as u8;
+ c3 as u8;
+
+struct Board:
+ r1 as Row;
+ r2 as Row;
+ r3 as Row;
+
+
+function new:
+ cast 0u8 0u8 0u8 into r0 as Row;
+ cast 0u8 0u8 0u8 into r1 as Row;
+ cast 0u8 0u8 0u8 into r2 as Row;
+ cast r0 r1 r2 into r3 as Board;
+ output r3 as Board.private;
+
+
+closure check_for_win:
+ input r0 as Board;
+ input r1 as u8;
+ is.eq r0.r1.c1 r1 into r2;
+ is.eq r0.r1.c2 r1 into r3;
+ and r2 r3 into r4;
+ is.eq r0.r1.c3 r1 into r5;
+ and r4 r5 into r6;
+ is.eq r0.r2.c1 r1 into r7;
+ is.eq r0.r2.c2 r1 into r8;
+ and r7 r8 into r9;
+ is.eq r0.r2.c3 r1 into r10;
+ and r9 r10 into r11;
+ or r6 r11 into r12;
+ is.eq r0.r3.c1 r1 into r13;
+ is.eq r0.r3.c3 r1 into r14;
+ and r13 r14 into r15;
+ is.eq r0.r3.c3 r1 into r16;
+ and r15 r16 into r17;
+ or r12 r17 into r18;
+ is.eq r0.r1.c1 r1 into r19;
+ is.eq r0.r2.c1 r1 into r20;
+ and r19 r20 into r21;
+ is.eq r0.r3.c1 r1 into r22;
+ and r21 r22 into r23;
+ or r18 r23 into r24;
+ is.eq r0.r1.c2 r1 into r25;
+ is.eq r0.r2.c3 r1 into r26;
+ and r25 r26 into r27;
+ is.eq r0.r3.c2 r1 into r28;
+ and r27 r28 into r29;
+ or r24 r29 into r30;
+ is.eq r0.r1.c3 r1 into r31;
+ is.eq r0.r2.c3 r1 into r32;
+ and r31 r32 into r33;
+ is.eq r0.r3.c3 r1 into r34;
+ and r33 r34 into r35;
+ or r30 r35 into r36;
+ is.eq r0.r1.c1 r1 into r37;
+ is.eq r0.r2.c2 r1 into r38;
+ and r37 r38 into r39;
+ is.eq r0.r3.c3 r1 into r40;
+ and r39 r40 into r41;
+ or r36 r41 into r42;
+ is.eq r0.r1.c3 r1 into r43;
+ is.eq r0.r2.c2 r1 into r44;
+ and r43 r44 into r45;
+ is.eq r0.r3.c1 r1 into r46;
+ and r45 r46 into r47;
+ or r42 r47 into r48;
+ output r48 as boolean;
+
+
+function make_move:
+ input r0 as u8.private;
+ input r1 as u8.private;
+ input r2 as u8.private;
+ input r3 as Board.private;
+ is.eq r0 1u8 into r4;
+ is.eq r0 2u8 into r5;
+ or r4 r5 into r6;
+ assert.eq r6 true;
+ lte 1u8 r1 into r7;
+ lte r1 3u8 into r8;
+ and r7 r8 into r9;
+ assert.eq r9 true;
+ lte 1u8 r2 into r10;
+ lte r2 3u8 into r11;
+ and r10 r11 into r12;
+ assert.eq r12 true;
+ is.eq r1 1u8 into r13;
+ is.eq r2 1u8 into r14;
+ and r13 r14 into r15;
+ is.eq r3.r1.c1 0u8 into r16;
+ and r15 r16 into r17;
+ is.eq r1 1u8 into r18;
+ is.eq r2 2u8 into r19;
+ and r18 r19 into r20;
+ is.eq r3.r1.c2 0u8 into r21;
+ and r20 r21 into r22;
+ is.eq r1 1u8 into r23;
+ is.eq r2 3u8 into r24;
+ and r23 r24 into r25;
+ is.eq r3.r1.c3 0u8 into r26;
+ and r25 r26 into r27;
+ is.eq r1 2u8 into r28;
+ is.eq r2 1u8 into r29;
+ and r28 r29 into r30;
+ is.eq r3.r2.c1 0u8 into r31;
+ and r30 r31 into r32;
+ is.eq r1 2u8 into r33;
+ is.eq r2 2u8 into r34;
+ and r33 r34 into r35;
+ is.eq r3.r2.c2 0u8 into r36;
+ and r35 r36 into r37;
+ is.eq r1 2u8 into r38;
+ is.eq r2 3u8 into r39;
+ and r38 r39 into r40;
+ is.eq r3.r2.c3 0u8 into r41;
+ and r40 r41 into r42;
+ is.eq r1 3u8 into r43;
+ is.eq r2 1u8 into r44;
+ and r43 r44 into r45;
+ is.eq r3.r3.c1 0u8 into r46;
+ and r45 r46 into r47;
+ is.eq r1 3u8 into r48;
+ is.eq r2 2u8 into r49;
+ and r48 r49 into r50;
+ is.eq r3.r3.c2 0u8 into r51;
+ and r50 r51 into r52;
+ is.eq r1 3u8 into r53;
+ is.eq r2 3u8 into r54;
+ and r53 r54 into r55;
+ is.eq r3.r3.c3 0u8 into r56;
+ and r55 r56 into r57;
+ ternary r57 r0 r3.r3.c3 into r58;
+ ternary r52 r0 r3.r3.c2 into r59;
+ ternary r52 r3.r3.c3 r58 into r60;
+ ternary r47 r0 r3.r3.c1 into r61;
+ ternary r47 r3.r3.c2 r59 into r62;
+ ternary r47 r3.r3.c3 r60 into r63;
+ ternary r42 r0 r3.r2.c3 into r64;
+ ternary r42 r3.r3.c1 r61 into r65;
+ ternary r42 r3.r3.c2 r62 into r66;
+ ternary r42 r3.r3.c3 r63 into r67;
+ ternary r37 r0 r3.r2.c2 into r68;
+ ternary r37 r3.r2.c3 r64 into r69;
+ ternary r37 r3.r3.c1 r65 into r70;
+ ternary r37 r3.r3.c2 r66 into r71;
+ ternary r37 r3.r3.c3 r67 into r72;
+ ternary r32 r0 r3.r2.c1 into r73;
+ ternary r32 r3.r2.c2 r68 into r74;
+ ternary r32 r3.r2.c3 r69 into r75;
+ ternary r32 r3.r3.c1 r70 into r76;
+ ternary r32 r3.r3.c2 r71 into r77;
+ ternary r32 r3.r3.c3 r72 into r78;
+ ternary r27 r0 r3.r1.c3 into r79;
+ ternary r27 r3.r2.c1 r73 into r80;
+ ternary r27 r3.r2.c2 r74 into r81;
+ ternary r27 r3.r2.c3 r75 into r82;
+ ternary r27 r3.r3.c1 r76 into r83;
+ ternary r27 r3.r3.c2 r77 into r84;
+ ternary r27 r3.r3.c3 r78 into r85;
+ ternary r22 r0 r3.r1.c2 into r86;
+ ternary r22 r3.r1.c3 r79 into r87;
+ ternary r22 r3.r2.c1 r80 into r88;
+ ternary r22 r3.r2.c2 r81 into r89;
+ ternary r22 r3.r2.c3 r82 into r90;
+ ternary r22 r3.r3.c1 r83 into r91;
+ ternary r22 r3.r3.c2 r84 into r92;
+ ternary r22 r3.r3.c3 r85 into r93;
+ ternary r17 r0 r3.r1.c1 into r94;
+ ternary r17 r3.r1.c2 r86 into r95;
+ ternary r17 r3.r1.c3 r87 into r96;
+ ternary r17 r3.r2.c1 r88 into r97;
+ ternary r17 r3.r2.c2 r89 into r98;
+ ternary r17 r3.r2.c3 r90 into r99;
+ ternary r17 r3.r3.c1 r91 into r100;
+ ternary r17 r3.r3.c2 r92 into r101;
+ ternary r17 r3.r3.c3 r93 into r102;
+ cast r94 r95 r96 into r103 as Row;
+ cast r97 r98 r99 into r104 as Row;
+ cast r100 r101 r102 into r105 as Row;
+ cast r103 r104 r105 into r106 as Board;
+ call check_for_win r106 1u8 into r107;
+ call check_for_win r106 2u8 into r108;
+ not r107 into r109;
+ and r109 r108 into r110;
+ ternary r110 r106.r1.c1 r106.r1.c1 into r111;
+ not r107 into r112;
+ and r112 r108 into r113;
+ ternary r113 r106.r1.c2 r106.r1.c2 into r114;
+ not r107 into r115;
+ and r115 r108 into r116;
+ ternary r116 r106.r1.c3 r106.r1.c3 into r117;
+ cast r111 r114 r117 into r118 as Row;
+ not r107 into r119;
+ and r119 r108 into r120;
+ ternary r120 r106.r2.c1 r106.r2.c1 into r121;
+ not r107 into r122;
+ and r122 r108 into r123;
+ ternary r123 r106.r2.c2 r106.r2.c2 into r124;
+ not r107 into r125;
+ and r125 r108 into r126;
+ ternary r126 r106.r2.c3 r106.r2.c3 into r127;
+ cast r121 r124 r127 into r128 as Row;
+ not r107 into r129;
+ and r129 r108 into r130;
+ ternary r130 r106.r3.c1 r106.r3.c1 into r131;
+ not r107 into r132;
+ and r132 r108 into r133;
+ ternary r133 r106.r3.c2 r106.r3.c2 into r134;
+ not r107 into r135;
+ and r135 r108 into r136;
+ ternary r136 r106.r3.c3 r106.r3.c3 into r137;
+ cast r131 r134 r137 into r138 as Row;
+ cast r118 r128 r138 into r139 as Board;
+ not r107 into r140;
+ and r140 r108 into r141;
+ ternary r141 2u8 0u8 into r142;
+ ternary r107 r106.r1.c1 r139.r1.c1 into r143;
+ ternary r107 r106.r1.c2 r139.r1.c2 into r144;
+ ternary r107 r106.r1.c3 r139.r1.c3 into r145;
+ cast r143 r144 r145 into r146 as Row;
+ ternary r107 r106.r2.c1 r139.r2.c1 into r147;
+ ternary r107 r106.r2.c2 r139.r2.c2 into r148;
+ ternary r107 r106.r2.c3 r139.r2.c3 into r149;
+ cast r147 r148 r149 into r150 as Row;
+ ternary r107 r106.r3.c1 r139.r3.c1 into r151;
+ ternary r107 r106.r3.c2 r139.r3.c2 into r152;
+ ternary r107 r106.r3.c3 r139.r3.c3 into r153;
+ cast r151 r152 r153 into r154 as Row;
+ cast r146 r150 r154 into r155 as Board;
+ ternary r107 1u8 r142 into r156;
+ output r155 as Board.private;
+ output r156 as u8.private;
diff --git a/tictactoe/build/program.json b/tictactoe/build/program.json
new file mode 100644
index 000000000..a2f5a1369
--- /dev/null
+++ b/tictactoe/build/program.json
@@ -0,0 +1,6 @@
+{
+ "program": "tictactoe.aleo",
+ "version": "0.0.0",
+ "description": "",
+ "license": "MIT"
+}
diff --git a/tictactoe/inputs/tictactoe.in b/tictactoe/inputs/tictactoe.in
new file mode 100644
index 000000000..aff78f3ac
--- /dev/null
+++ b/tictactoe/inputs/tictactoe.in
@@ -0,0 +1,18 @@
+// The `new` function does not take any inputs.
+[new]
+
+// Inputs for the `make_move` function.
+// - `player` : A u8 representing the player making the move. 1 for player 1, 2 for player 2.
+// - `row` : A u8 representing the row to make the move in.
+// - `column` : A u8 representing the column to make the move in.
+// - `board` : A representation of the board state.
+[make_move]
+player: u8 = 1u8;
+row: u8 = 1u8;
+col: u8 = 1u8;
+board: Board = Board {
+ r1: Row { c1: 0u8, c2: 0u8, c3: 0u8 },
+ r2: Row { c1: 0u8, c2: 0u8, c3: 0u8 },
+ r3: Row { c1: 0u8, c2: 0u8, c3: 0u8 },
+};
+
diff --git a/tictactoe/program.json b/tictactoe/program.json
new file mode 100644
index 000000000..a2f5a1369
--- /dev/null
+++ b/tictactoe/program.json
@@ -0,0 +1,6 @@
+{
+ "program": "tictactoe.aleo",
+ "version": "0.0.0",
+ "description": "",
+ "license": "MIT"
+}
diff --git a/tictactoe/run.sh b/tictactoe/run.sh
new file mode 100644
index 000000000..0c57c04e4
--- /dev/null
+++ b/tictactoe/run.sh
@@ -0,0 +1,157 @@
+#!/bin/bash
+# First check that Leo is installed.
+if ! command -v leo &> /dev/null
+then
+ echo "leo is not installed."
+ exit
+fi
+# Create a new game.
+echo "
+###############################################################################
+######## ########
+######## STEP 0: Creating a new game of Tic-Tac-Toe ########
+######## ########
+######## | | | | ########
+######## | | | | ########
+######## | | | | ########
+######## ########
+###############################################################################
+"
+leo run new || exit
+
+# Have the Player 1 make a move.
+echo "
+###############################################################################
+######## ########
+######## STEP 1: Player 1 makes the 1st move. ########
+######## ########
+######## | x | | | ########
+######## | | | | ########
+######## | | | | ########
+######## ########
+###############################################################################
+"
+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 } }" || exit
+
+# Have the Player 2 make a move.
+echo "
+###############################################################################
+######## ########
+######## STEP 2: Player 2 makes the 2nd move. ########
+######## ########
+######## | x | | | ########
+######## | | o | | ########
+######## | | | | ########
+######## ########
+###############################################################################
+"
+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 } }" || exit
+
+# Have the Player 1 make a move.
+echo "
+###############################################################################
+######## ########
+######## STEP 3: Player 1 makes the 3rd move. ########
+######## ########
+######## | x | | | ########
+######## | | o | | ########
+######## | x | | | ########
+######## ########
+###############################################################################
+"
+leo run make_move 1u8 3u8 1u8 "{ r1: { c1: 1u8, c2: 0u8, c3: 0u8 }, r2: { c1: 0u8, c2: 2u8, c3: 0u8 }, r3: { c1: 0u8, c2: 0u8, c3: 0u8 } }" || exit
+
+# Have the Player 2 make a move.
+echo "
+###############################################################################
+######## ########
+######## STEP 4: Player 2 makes the 4th move. ########
+######## ########
+######## | x | | | ########
+######## | o | o | | ########
+######## | x | | | ########
+######## ########
+###############################################################################
+"
+leo run make_move 2u8 2u8 1u8 "{ r1: { c1: 1u8, c2: 0u8, c3: 0u8 }, r2: { c1: 0u8, c2: 2u8, c3: 0u8 }, r3: { c1: 1u8, c2: 0u8, c3: 0u8 } }" || exit
+
+# Have the Player 1 make a move.
+echo "
+###############################################################################
+######## ########
+######## STEP 5: Player 1 makes the 5th move. ########
+######## ########
+######## | x | | | ########
+######## | o | o | x | ########
+######## | x | | | ########
+######## ########
+###############################################################################
+"
+leo run make_move 1u8 2u8 3u8 "{ r1: { c1: 1u8, c2: 0u8, c3: 0u8 }, r2: { c1: 2u8, c2: 2u8, c3: 0u8 }, r3: { c1: 1u8, c2: 0u8, c3: 0u8 } }" || exit
+
+# Have the Player 2 make a move.
+echo "
+###############################################################################
+######## ########
+######## STEP 6: Player 2 makes the 6th move. ########
+######## ########
+######## | x | o | | ########
+######## | o | o | x | ########
+######## | x | | | ########
+######## ########
+###############################################################################
+"
+leo run make_move 2u8 1u8 2u8 "{ r1: { c1: 1u8, c2: 0u8, c3: 0u8 }, r2: { c1: 2u8, c2: 2u8, c3: 1u8 }, r3: { c1: 1u8, c2: 0u8, c3: 0u8 } }" || exit
+
+# Have the Player 1 make a move.
+echo "
+###############################################################################
+######## ########
+######## STEP 7: Player 1 makes the 7th move. ########
+######## ########
+######## | x | o | | ########
+######## | o | o | x | ########
+######## | x | x | | ########
+######## ########
+###############################################################################
+"
+leo run make_move 1u8 3u8 2u8 "{ r1: { c1: 1u8, c2: 2u8, c3: 0u8 }, r2: { c1: 2u8, c2: 2u8, c3: 1u8 }, r3: { c1: 1u8, c2: 0u8, c3: 0u8 } }" || exit
+
+# Have the Player 2 make a move.
+echo "
+###############################################################################
+######## ########
+######## STEP 8: Player 2 makes the 8th move. ########
+######## ########
+######## | x | o | | ########
+######## | o | o | x | ########
+######## | x | x | o | ########
+######## ########
+###############################################################################
+"
+leo run make_move 2u8 3u8 3u8 "{ r1: { c1: 1u8, c2: 2u8, c3: 0u8 }, r2: { c1: 2u8, c2: 2u8, c3: 1u8 }, r3: { c1: 1u8, c2: 1u8, c3: 0u8 } }" || exit
+
+echo "
+###############################################################################
+######## ########
+######## STEP 9: Player 1 makes the 9th move. ########
+######## ########
+######## | x | o | x | ########
+######## | o | o | x | ########
+######## | x | x | o | ########
+######## ########
+###############################################################################
+"
+leo run make_move 1u8 1u8 3u8 "{ r1: { c1: 1u8, c2: 2u8, c3: 0u8 }, r2: { c1: 2u8, c2: 2u8, c3: 1u8 }, r3: { c1: 1u8, c2: 1u8, c3: 2u8 } }" || exit
+
+echo "
+###############################################################################
+######## ########
+######## Game Complete! Players 1 & 2 Tied ########
+######## ########
+######## | x | o | x | ########
+######## | o | o | x | ########
+######## | x | x | o | ########
+######## ########
+###############################################################################
+"
diff --git a/tictactoe/src/main.leo b/tictactoe/src/main.leo
new file mode 100644
index 000000000..24ec333e6
--- /dev/null
+++ b/tictactoe/src/main.leo
@@ -0,0 +1,111 @@
+program tictactoe.aleo {
+ // A row in a tic tac toe board.
+ // - `c1` : The first entry in the row.
+ // - `c2` : The second entry in the row.
+ // - `c3` : The third entry in the row.
+ // A valid entry is either 0, 1, or 2, where 0 is empty, 1 corresponds to player 1, and 2 corresponds to player 2.
+ // Any other values are invalid.
+ struct Row {
+ c1: u8,
+ c2: u8,
+ c3: u8
+ }
+
+ // A tic tac toe board.
+ // - `r1` : The first row in the board.
+ // - `r2` : The second row in the board.
+ // - `r3` : The third row in the board.
+ struct Board {
+ r1: Row,
+ r2: Row,
+ r3: Row,
+ }
+
+ // Returns an empty board.
+ transition new() -> Board {
+ return Board {
+ r1: Row { c1: 0u8, c2: 0u8, c3: 0u8 },
+ r2: Row { c1: 0u8, c2: 0u8, c3: 0u8 },
+ r3: Row { c1: 0u8, c2: 0u8, c3: 0u8 },
+ };
+ }
+
+ // Returns `true` if there exists a row, column, or diagonal with all entries occupied by the same player.
+ // - `b` : A tic tac toe board.
+ // - `p` : A number corresponding to a player.
+ function check_for_win(b: Board, p: u8) -> bool {
+ return
+ (b.r1.c1 == p && b.r1.c2 == p && b.r1.c3 == p) || // row 1
+ (b.r2.c1 == p && b.r2.c2 == p && b.r2.c3 == p) || // row 2
+ (b.r3.c1 == p && b.r3.c3 == p && b.r3.c3 == p) || // row 3
+ (b.r1.c1 == p && b.r2.c1 == p && b.r3.c1 == p) || // column 1
+ (b.r1.c2 == p && b.r2.c3 == p && b.r3.c2 == p) || // column 2
+ (b.r1.c3 == p && b.r2.c3 == p && b.r3.c3 == p) || // column 3
+ (b.r1.c1 == p && b.r2.c2 == p && b.r3.c3 == p) || // diagonal
+ (b.r1.c3 == p && b.r2.c2 == p && b.r3.c1 == p); // other diagonal
+ }
+
+ // Returns an updated tic tac toe board with a move made by a player.
+ // Returns a `u8` corresponding to the player who won the game, or 0 if no one has won yet.
+ // - `player` : A number corresponding to a player.
+ // - `row` : The row of the move.
+ // - `col` : The column of the move.
+ // - `board` : A tic tac toe board.
+ // Assumes that `player` is either 1 or 2.
+ // Assumes that `row` and `col` are valid indices into the board.
+ // If an entry is already occupied, the move is invalid and the board is returned unchanged.
+ transition make_move(player: u8, row: u8, col: u8, board: Board) -> (Board, u8) {
+ // Check that inputs are valid.
+ assert(player == 1u8 || player == 2u8);
+ assert(1u8 <= row && row <= 3u8);
+ assert(1u8 <= col && col <= 3u8);
+
+ // Unpack the entries in the board into variables.
+ let r1c1: u8 = board.r1.c1;
+ let r1c2: u8 = board.r1.c2;
+ let r1c3: u8 = board.r1.c3;
+ let r2c1: u8 = board.r2.c1;
+ let r2c2: u8 = board.r2.c2;
+ let r2c3: u8 = board.r2.c3;
+ let r3c1: u8 = board.r3.c1;
+ let r3c2: u8 = board.r3.c2;
+ let r3c3: u8 = board.r3.c3;
+
+ // Update the appropriate entry with the given move.
+ if row == 1u8 && col == 1u8 && r1c1 == 0u8 {
+ r1c1 = player;
+ } else if row == 1u8 && col == 2u8 && r1c2 == 0u8 {
+ r1c2 = player;
+ } else if row == 1u8 && col == 3u8 && r1c3 == 0u8 {
+ r1c3 = player;
+ } else if row == 2u8 && col == 1u8 && r2c1 == 0u8 {
+ r2c1 = player;
+ } else if row == 2u8 && col == 2u8 && r2c2 == 0u8 {
+ r2c2 = player;
+ } else if row == 2u8 && col == 3u8 && r2c3 == 0u8 {
+ r2c3 = player;
+ } else if row == 3u8 && col == 1u8 && r3c1 == 0u8 {
+ r3c1 = player;
+ } else if row == 3u8 && col == 2u8 && r3c2 == 0u8 {
+ r3c2 = player;
+ } else if row == 3u8 && col == 3u8 && r3c3 == 0u8 {
+ r3c3 = player;
+ }
+
+ // Construct the updated game board.
+ let updated: Board = Board {
+ r1: Row { c1: r1c1, c2: r1c2, c3: r1c3 },
+ r2: Row { c1: r2c1, c2: r2c2, c3: r2c3 },
+ r3: Row { c1: r3c1, c2: r3c2, c3: r3c3 },
+ };
+
+ // Check if the game is over.
+ if check_for_win(updated, 1u8) {
+ return (updated, 1u8);
+ } else if check_for_win(updated, 2u8) {
+ return (updated, 2u8);
+ } else {
+ return (updated, 0u8);
+ }
+ }
+}