View on GitHub

makecode-torch

A Torch-like extension for MakeCode Arcade that enables neural networks, supporting Linear and Convolutional layers, activation functions, and PyTorch model conversion for AI-powered game mechanics or other AI uses.

Torch - Neural Network Library for MakeCode Arcade

Torch is a lightweight neural network library designed for use within MakeCode Arcade. It provides essential tensor operations, basic neurons, and layer-based training to build small-scale neural networks.

πŸš€ Features

πŸ“Œ See Full Version History πŸ“Œ See How to Update Models

πŸ”— Installation & Usage

βœ… Use as an Extension

This repository can be added as an extension in MakeCode Arcade.

  1. Open MakeCode Arcade
  2. Click New Project
  3. Open Extensions under the gearwheel menu
  4. Search for https://github.com/killercraft-thecoder/makecode-torch and import

✏ Edit this Project

To edit this repository directly within MakeCode:

  1. Open MakeCode Arcade
  2. Click Import, then Import URL
  3. Paste https://github.com/killercraft-thecoder/makecode-torch and click Import

🌍 GitHub Repository

You can explore the full project here:
https://killercraft-thecoder.github.io/makecode-torch/

πŸ”„ PyTorch Model Conversion (convert.py)

Torch now includes a conversion tool that allows users to convert saved PyTorch models into MakeCode Arcade-compatible TypeScript.

Usage

  1. Run convert.py and provide the path to your saved PyTorch model (.pth file).
  2. The script will extract weights and convert layers into a structured TypeScript format.
  3. The generated file can be imported into your MakeCode Arcade project!

Example Command:

python convert.py

πŸ”Ή GitHub Syncing Tip for MakeCode Arcade

Did you know? MakeCode Arcade only pulls changes affecting managed project files, but ignores externally added files like history.md.
This means you can:

If you need to make non-code updates, doing them externally can keep the project cleaner while still benefiting from GitHub’s commit tracking!