LearnBuild toward a chatbotObstacle 3: no addresses

Obstacle 3: no addresses

Aim. At the end of this lesson one piece of program does its job at 512 places on the tape, a total travels along with the pointer, and you can fetch a number from far away.

Where the lessons are going

Multiplying, adding, dividing, rounding and clamping all work now, but only in a handful of cells at the start of the tape. A model has to do it for a great many numbers, lying all along the tape.

The same job at many places

Try it: the job is the rounding of step 5 of lesson 5, written out once for every number. Drag the slider to 512 numbers and watch the length of the program:

The program is characters long.

length

Figure 1. The length of a program that rounds every number with its own copy of the text. The grey box shows the start of that text. (interactive)

One copy that walks

Try it: three sums lie on the tape: 11,868, 5,290 and −6,330. Press Play, or go to the last step, and watch where the pointer is:

Figure 2. One copy of the rounding in a loop that walks. The strip on top shows which frame the pointer is in. (interactive)

Carry a total along

Try it: press Play and follow the cell called "total". Change the four numbers if you like:

Figure 3. A total that travels. Watch the cell called "total" move one frame to the right each round. (interactive)

Fetch a number from far away

Try it: fetch record 60 with short hops only: go to the last step and read how many steps it took. Then switch to "long and short hops" and fetch it again:

Each square is one record of 6 cells. Filled: where the pointer is. Green border: every eighth record, where a long hop lands. The table has 64 records; the real one has 65,664.

Figure 4. A table of 64 records. The map shows where the pointer is; the step counter shows what the trip costs. (interactive)

What you can do now

Do one job at every place of the tape with one copy of the program, carry values along, and fetch a number from far away. The rounding of the sum now works for every sum, wherever it lies. The third obstacle is gone.

The last obstacle is the sheer size. The model has 135 million weights. Where do they go?

How the real program differs

The cost of walking. About three extra steps per frame. The program for 512 frames is still longer than for 3, because planting 512 markers takes some text, but it hardly grows.

The scratch cells travel too. Every frame of step 2 has its own ten scratch cells. In the real program a gap of empty cells moves through the data instead: the program takes the frame next to the gap, works on it with the gap as scratch paper, and puts it down on the other side.

The real table. To turn your typed question into word pieces, the chat program looks up pairs of pieces in a table of 65,664 records on the tape. It hops 128 records at a time, not 8. One lookup costs about 2,600 steps. The table of step 4 is a small version of it. For nearby records the long hops cost more than they save, because splitting the record number takes steps too.