Tic-tac-toe, noughts and crosses, or Xs and Os is a paper-and-pencil game for two players who take turns marking the spaces in a three-by-three grid with X or O. The player who succeeds in placing three of their marks in a horizontal, vertical, or diagonal row is the winner. Wikipedia
This project was created as my submisssion for the Rust Smart Contract 101 Challenge organized by Dacade x Internet Computer. I decided on this project because I wanted to deploy a canister on the Internet Computer using Rust. Rust seems to be gaining a lot of popularity and so I figured that this would be great time to kill 2 birds with one stone 😁.
-
Play a move by calling the
play_move
canister function. This canister function takes 2 arguments:- The id of the game
- The coordinates of the move in the format
x,y
where x is thex
coordinate of the move andy
is y coordinate of the move
-
You can view the game start by calling the
get_game
canister function and passing in the canister id -
Take turns in playing the game until a winner emerges... or the game ends in a draw; either way works 🤷
-
I added in some more functions for convenience. They pretty much do what their names imply. Note that the
get_games
and theget_player_games
function both take in a page number as their sole argument
You can interact with it here: https://a4gq6-oaaaa-aaaab-qaa4q-cai.raw.icp0.io/?id=tt2ty-dyaaa-aaaao-a2u2q-cai