Skip to content

expitau/MineNewt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MineNewt: Neural Networks in Minecraft

MineNewt is a neural network created from scratch in Minecraft using redstone. The network is first compiled using a custom rust library, and is then dynamically generated into a Minecraft world. This allows users to train neural networks on arbitrary functions and import them into Minecraft, effectively acting as a Rust compiler targeting Minecraft.

Gallery

Overview

An example network

This is a network with 64 total neurons that adds two binary numbers and computes their modulus in base 3, 5, and 7. It could in theory compute any compatible Rust function though



Top-Section

Closer view of example network

You can see the different components that make up the network, including the activation functions (purple), the weight functions (green), clock lines (blue), and inputs and outputs (orange/yellow)



Adder

Weight & Addition

This is one component of a neuron. It is responsible for computing instant-carry addition on a binary input with either -1 or 1, given a weighted input



Neuron

Full Neuron

This is the equivalent of one neuron. It takes in 8 inputs, and multiplies each by a weight. It then computes its activation and applies a smoothing function

The Software

Architecture

MineNewt is composed of three main components:

  1. Training: A neural network library built in Rust that compiles Rust functions into deep neural networks and exports them as .newt files, which represent the network's weights and biases.

  2. Simulation: This stochastic neural network simulator takes in a .newt file and simulates the accuracy of the Minecraft-based neural network. By running thousands of simulations, it provides insight into the network's robustness and accuracy in the Minecraft environment.

  3. Generation: A Python library that modifies Minecraft world data, building the neural network from scratch given a .newt file. This creates a world file with the final neural network.

The Math

The following is an introductory explanation that assumes you have a basic understanding of neural networks, binary, and boolean algebra

Minecraft redstone is an exceptionally limited way to encode a neural network. It is barely turing-complete via Pierce Logic, and has an operation time of 0.1s. This means that time and space complexity it critical to the design of the network.

The biggest challenge in building a neural network in Minecraft is the representation of accurate floating point numbers. A binary representation like IEEE-754 would be unweildly, due to the complexity of implementing floating point operations in Minecraft. This could take seconds to compute even a single operation, and would require a massive amount of space (as each of the 768 connections would require an individual bus to represent its state). Thus, we utilize stochastic computing, where instead of representing a floating point number as any fixed set of bits, we sample the line at various intervals and use the probability of it being on to represent the number.

Stochastic

We will represent all the floating point numbers $f \in [-1, 1]$ (decimal numbers between -1 and 1) by

$$f = 2p - 1$$

where $p$ is the probability of the line being on.