A Perceptron in Age of Empires II

In-game constructions of NAND gates and a perceptron (forward prop and training) as described in in 'If LLMs Have Human-Like Attributes, Then So Does Age of Empires II'. We begin by proving that Age of Empires II is functionally- and Turing- complete. Then we build a perceptron and a circuit to train it in-game. With that, we argue that changing the substrate (representation) of an LLM also alters the perception of their attributes. We then show that research in LLM anthropomorphic attributes cannot be done starting by assuming that these attributes exist (or not) in the system; even if you aim to conclude that they do not exist. This assumption can happen even when you do not make it explicitly! It also shows that there are ways to do good, sound research without needing to make that assumption. If you're looking for the actual artefacts (code and so on), these are here.

All products, company names, brand names, trademarks, and images are properties of their respective owners. The images are used under Fair Use for educational purposes.
Read the paper

Contents

An operational NAND gate in Age of Empires II An operational perceptron in Age of Empires II An operational ansatz-based training circuit in Age of Empires II

Operational NAND gate

An operational NAND gate in Age of Empires II, built with the game's scenario editor. This one can also be built within the game in a two-player setup but it's a lot easier (so to speak) to just script it.

This one is designed to show its internal workings, and much simpler implementations are possible. Every bit is represented by two rails (grass for 0, a bridge for 1). Only one rail is active at a time, with a goat acting as the signal carrier. When the gate fires, the bit-goats are removed (they ded) and a new bit-goat is placed in its respective output rail.

To avoid race conditions, 'gate ready' rails (ice) are set, with a signal-goat in the rail closest to the gate indicating that it can start the calculation. In the above: in order for the AND gate to be active, the leftmost and bottom-most bit goats need to be near the pens (towards the inside of the map). This says that the gate is ready, but not that the UPSTREAM gate is ready. For that, the goat in the middle ice patch needs to be near the AND pen. When the gate fires, the goats are sent 'away' towards their upstream/downstream gates to signal readiness.

To read the gate: leftmost grass/bridge rails: 0/1 left-input for AND. Rightmost grass/bridge rails: right-input for AND. Middle rails: output of AND, input for NOT. In the gif, it computes AND(0, 1), places a goat in the middle grass rail (0), and NOT places a gate on the bridge (1).

An operational NAND gate in Age of Empires II
An operational NAND gate in Age of Empires II, accounting for race conditions with the ice rails.

An operational 1-bit perceptron

An operational perceptron in Age of Empires II using the same logic (as in, the same core concepts) as the NAND gate above.

This is meant to be a VERY simple perceptron, so it is a bipolar 1-bit implementation. It is composed of two XNOR gates doing most of the inner product stuff, and an AND gate as the threshold (it is meant to be learning AND, but it doesn't affect this).

This particular implementation omits the bias term and simply hardcodes it in the step function, but a bias adder is also possible. Note how for every bit on the rightmost circuit there are two bit-goats on the leftmost. This is more complex but allows for concurrency control, since otherwise the gates do weird things.

To read the perceptron: for an input \([ x_1, x_2]^T\), the perceptron with weights \([w_1, w_2]^T\) will have in the topmost XNOR as inputs \(x_1, w_1\) (blue-green patch and rocky patch), and same for bottom-most XNOR. Goats act as bits and as ready signals. The output of the XNOR gates can be seen in that middle section with three rails, which is in turn the input to the AND gate. In the GIF it computes \(x = [1, 1]^T\) for \(w = [1, 1]^T\), and obviously predicts 1 since this weight assignment is the correct answer.

An operational perceptron in Age of Empires II
An operational perceptron in Age of Empires II, with goats acting as the signal carriers.

Perceptron-training circuit

An ansatz-based training circuit in Age of Empires II.

The ansatz algorithm is just a regular perceptron circuit and a bunch of XNORs/ANDs/ORs to determine the new weights. Check the paper for the actual circuit.

This one is quite complex to explain, so bear with me. The inputs are (top to bottom in the watery patch): true label \(t\), and input \(x\) and current weights \(w\) vectors. The perceptron is on the first two levels from the left, and the remaining circuit computes the error and returns the new weights. To simplify the branching of the inputs, when the weights / inputs / labels are 'activated', the goats are teleported to their respective gates, but they are put on hold until the rest of the computation is done (via the ice goats).

The gates use the environment as coding. Bamboo is for XNOR, regular forests for AND, baobabs for OR, deep water for NOT, and the usual rails you know and love.

Note: I tested this in verilog and works, and now I'm working on scripting it. It's just a pain and it's not like I have unlimited free time (but I'll add it to the repo and here!)

A built and soon-to-be-fully-scripted ansatz-based training circuit for a perceptron in Age of Empires II.