Skip to content

Commit

Permalink
Update tictactoe.ny
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenreup committed Jun 6, 2024
1 parent e49b848 commit 9bee1c7
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions examples/games/tictactoe.ny
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
mawu[] board = ["","","","","","","","",""];
mawu currentPlayer = "X";
nambala isRunning = zoona;

ndondomeko printBoard() {
console.lemba(" 1 | 2 | 3 ");
za (nambala i = 0; i < 3; i++) {
console.lemba("---------");
console.lemba(" 4 | 5 | 6 ");
console.lemba("---------");
console.lemba(" 7 | 8 | 9 ");
lembanzr("---------");
lembanzr(board[0] + " | " + board[1] + " | " + board[2]);
lembanzr("---------");
lembanzr(board[3] + " | " + board[4] + " | " + board[5]);
lembanzr("---------");
lembanzr(board[6] + " | " + board[7] + " | " + board[8]);
lembanzr("---------");
}

ndondomeko move(player, position) {
board[position] = player;
ngati (player == "X") {
currentPlayer = "O";
} kapena {
currentPlayer = "X";
}
}

ndondomeko playGame() {
mawu currentPlayer = "X";
nambala isRunning = zoona;
console.lemba(isRunning);
lembanzr(isRunning);
pamene(isRunning) {
printBoard();
isRunning = bodza;
nambala move = console.landira();
lembanzr(move);
move(currentPlayer, move);
// console.fufuta();
}
}

Expand Down

0 comments on commit 9bee1c7

Please sign in to comment.