Artificial Intelligence for the Z80 | dfsantos.com
Understand artificial intelligence by programming it from scratch in BASIC. A practical journey through algorithms, data and neural networks on 8-bit computers.
Understand artificial intelligence by programming it from scratch in BASIC. A practical journey through algorithms, data and neural networks on 8-bit computers.
2026 · BASIC · Z80
12 chaptersTwo editions: Spanish / English
THE BOOK
What happens when we bring the foundations of artificial intelligence to an 8-bit machine? This book takes a learning-by-building approach: write the algorithms, observe their results and understand the decisions behind each program. BASIC turns ideas into instructions that can be followed, changed and run on a Spectrum, a Spectrum Next or an emulator.
The journey begins with AI history and a practical question: how to make the most of a computer with limited memory and speed. Comparing sorting algorithms and measuring their execution times prepares the ground for expert systems, an ELIZA-inspired chatbot and a tic-tac-toe player using Minimax and alpha-beta pruning.
Knowledge then moves from rules to data. Linear regression works with real CO₂ measurements; k-NN and Naive Bayes classify role-playing characters; k-means discovers groups without labels. The perceptron and multilayer networks take learning as far as digit recognition, explaining weights, errors, activation functions and backpropagation.
The Game of Life closes the book with another kind of complexity: behavior emerging from simple rules, without training. Complete listings and experiments invite readers to change parameters and see what happens. The narrative can be followed from beginning to end, with the code available whenever a closer look is useful; the programs are also available in the book’s repository.
THE JOURNEY
A look at each chapter, with images from the book. Select an image to enlarge it.
CHAPTER 01
A journey through AI history, its main branches and our working laboratory: the Z80, the Spectrum and the Spectrum Next. The starting point for understanding what we will build and why BASIC is a useful way to explore it.
CHAPTER 02
Timing Bubble sort, Shell sort and Quicksort makes algorithmic complexity visible. Performance plots show why increasing the clock speed cannot replace choosing an efficient algorithm.
CHAPTER 03
Facts, rules and an inference engine form a small diagnostic system. Separating knowledge from the reasoning mechanism makes it possible to extend the rules and explain how a conclusion was reached.
CHAPTER 04
An implementation of ELIZA transforms text through patterns and responses. Normalization, keywords and substitutions build a conversation while revealing the difference between simulating dialogue and understanding it.
CHAPTER 05
Tic-tac-toe provides a way to represent states and explore decision trees. Depth-first search, Minimax and alpha-beta pruning show how to look ahead and reduce the work required to choose a move.
CHAPTER 06
The move from rules to data begins by fitting a line and measuring error. An example using Mauna Loa CO₂ data applies least squares to a real problem, calculated and plotted in BASIC.
CHAPTER 07
Wizards, warriors and rangers become feature vectors. A classifier decides from the nearest examples, showing how distance, data representation and the choice of k affect the result.
CHAPTER 08
The same world of characters is now explored through counts and probabilities. Naive Bayes contrasts a decision based on proximity with one based on evidence and assumptions about independence.
CHAPTER 09
Without predefined labels, the program looks for groups in a cloud of points. Assigning examples and moving centroids makes it possible to follow the iterative process visually until convergence.
CHAPTER 10
An artificial neuron combines inputs, weights and a threshold, then corrects its mistakes during training. Experiments with lines and digits introduce generalization and the limits of a linear boundary, including XOR.
CHAPTER 11
Specialized perceptrons lead to hidden layers, the sigmoid function and backpropagation. A digit-recognition project on a 6 × 6 grid brings training, weights and prediction together.
CHAPTER 12
The final chapter explores how simple local rules produce complex behavior. A toroidal 20 × 20 universe, two arrays and a visual editor make it possible to experiment with patterns, oscillators and moving structures.
FROM PAGE TO SCREEN / CHAPTER 12
Each cell lives or dies according to its eight neighbors. A living cell survives with two or three neighbors; a dead cell is born with exactly three. All cells change at the same time. These rules produce stable structures, oscillators and moving patterns.
The book’s example uses a toroidal 20 × 20 board: opposite edges connect. Two arrays keep the current generation separate from the next so the calculation order cannot change the result.
ES / EN
Choose your preferred edition. Both are collected on this page.
Spanish edition
English edition
The examples are organized by chapter in the AI_Z80 repository. Study the listings and experiment on real hardware or in an emulator.
Texto de dfsantos.com tal como lo publicó, leído de su página y mostrado aquí con el formato de El Autómata. El original, en dfsantos.com · Volver a la noticia de El Autómata