generated from pixelaw/app_template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
13 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
We built this immersive game starting with the smart contract 'app.cairo,' which lays down the rules and mechanics for the game within PixeLAW's ecosystem. The players interact with the game using simple grid selections that translate their moves into state changes in the contract. Our ML bot was initially trained on a conventional ML setup and was meticulously transpiled into Cairo with Giza. This innovative process allows it to run inference entirely on-chain for responsive gameplay. | ||
|
||
The development of the ML model followed these steps: | ||
|
||
1. A simple TensorFlow neural network model was trained using a TicTacToe Jupyter notebook template provided by Gizatech. | ||
2. This TensorFlow model was then converted into an ONNX file. | ||
3. Giza-cli transpiled the ONNX file into a neural network within the Orion framework, which supports ML functionalities in Cairo. Each neural network layer and bias is represented as different contracts executing matrix operations. The sequential combination of these operations mirrors the output generated by the Python model. The AI Bot uses this output to determine the best next move. | ||
4. Dojo game logic calls the ML inference code to generate the AI's move. | ||
|
||
The TicTacToe game is rooted in the PixeLAW world by registering the game with personalized game dynamics and iconography. Using Dojo, we set up the world contract to keep track of the ongoing game states between players and the ML bot. Actions such as initiating a game, player's moves, and the bot's responses leverage Dojo's world dispatcher to maintain consistency and enforce game rules within the contracts. | ||
|
||
The React frontend delivers an engaging experience for the users by letting them interact with the game's user interface in their web browsers. Our contract ensures that moves are legal and executed in turns, maintaining the integrity of the game's progression and outcomes. | ||
Handling an ML bot on-chain required overcoming the computational and gas limitations of smart contracts. We achieved a balance between complexity and performance, ensuring the game remains fast and cost-effective for the players. Overall, our game showcases the practicality of integrating machine learning into smart contracts and offers a fun, interactive way for the community to engage with blockchain technology. |