"Neural network" is often used as a synonym for "AI," but the underlying math is very concrete: additions, multiplications, and a threshold function, repeated thousands of times. This article explains the perceptron (the simplest neuron), what changes in a CNN, and then shows it with a real production case rather than a whiteboard diagram: the ~11,500-parameter network that decides the moves of an AI bot in a strategy game.
An artificial neural network is a mathematical function that learns from examples instead of following hand-written rules. It takes numbers as input (the price of a product, the pixels of an image, or the positions of units on a game map), combines them across several layers of "neurons," and produces an output: a prediction, a classification, a decision. What makes the network "learn" is training: adjusting thousands or millions of internal numbers (the weights) so that, for a given input, the output gets closer and closer to the correct result.
Long before today's deep networks came the perceptron (1958, Frank Rosenblatt): a single artificial neuron. Its entire math comes down to three steps:
Each input x has its own weight w, which measures how much that input matters for the decision. z is simply the sum of all the inputs multiplied by their weights. f(z) turns that number into the actual output — in the original perceptron, a plain yes/no depending on whether z crosses a threshold. The third line is the learning: if the network got it wrong, each weight is nudged in the direction that reduces the error, scaled by a learning rate η (eta). Repeated thousands of times over thousands of examples, the weights converge to values that, taken together, "know" how to solve the problem.
A real limitation of the perceptron: a single neuron can only separate data with a straight line. For more complex patterns you need to stack neurons into layers — which is, literally, what the "deep" in "deep learning" means: several layers of neurons, each learning a different combination of what the previous layer detected.
A convolutional neural network (CNN) is a network designed specifically for data with spatial structure: images, maps, anything where relative position matters. The key difference from a dense layer (where every neuron looks at all the inputs at once) is that a convolutional neuron only looks at a small local window — say, a 3×3 block of pixels — and that same filter slides across the whole image, looking for the same pattern at every position. This has two practical advantages: far fewer connections to learn (the filter is reused instead of having a separate weight for every pixel at every position), and pattern detection regardless of where the pattern appears in the image.
A typical CNN stacks several of these convolutional layers (each detecting more complex patterns than the last: edges, then shapes, then objects), interleaved with "pooling" layers that summarize and shrink the information, and ends in one or more ordinary dense layers that take that condensed information and produce the final decision.
To keep this from staying theoretical, here is what a real CNN looks like — small, but genuinely in production: the model that controls the AI bots in CraftWar (a 1v1 RTS developed in-house), playing real matches against other players and bots, on a Linux server, with no GPU, in milliseconds per move.
Each bot "move" starts by converting the match map into a tiny 16×16-pixel image with 4 channels — just as an ordinary photo has 3 channels (red/green/blue), this one has: my units, enemy units, neutral units, and tree density. On top of that come 13 standalone numbers (gold, wood, population, which enemy wave they're on, combat stats). That image then goes through the network:
| Layer | What it does | Parameters |
|---|---|---|
| conv1 | 8 filters of 3×3, detects basic local patterns | 296 |
| conv2 | 16 filters of 3×3, combines what conv1 saw | 1,168 |
| pooling | condenses the 16×16 map into a 4×4 summary | 0 (no weights) |
| dense layer (fc1) | 269 inputs → 32 neurons | 8,640 |
| 9 output heads | 9 separate decisions in parallel (what to build, attack or retreat, etc.) | 1,419 |
| Total | ≈11,523 parameters |
Two real design decisions are worth highlighting. First, 9 output heads in parallel instead of just one: the trunk of the network (the conv1/conv2/fc1 layers) is computed only once per move, and from there 9 independent mini-classifiers answer 9 different questions at the same time — which unit to train, whether to build a tower, whether the hero should fight or retreat — instead of nine full passes through the network. Second, and less common: inference uses integer math, not floating point. Every weight is stored as a 16-bit integer in fixed-point format (the real value multiplied by 256), and the entire network runs without a single "float." The reason is specific to the product: CraftWar is multiplayer with a simulation synchronized between both players (lockstep); if the network used ordinary decimals, two different computers could round slightly differently and knock the match out of sync. With integers, the result is bit-for-bit identical, every time.
Carlos Montiel is an enterprise AI solutions architect. He implements LLMs, Agents, RAG, and orchestrators for companies across Guatemala and Latin America. Reach out for a consultation.
Contact Carlos Montiel