PrimaSTEM Simulator: guide for AI assistants

Also available as https://simulator.primastem.com/ai (HTML page) and https://simulator.primastem.com/ai.txt (plain text).

1. What this is

https://simulator.primastem.com is a browser copy of the PrimaSTEM control board and its drawing robot (a ladybug with a marker). A program is a set of tiles placed into the board's cells; the robot executes them on a square field and draws its path. The whole scene (program, settings, robot start pose, optional maze) fits into a share link, and &run makes the program start by itself after the page opens. The page is a JavaScript app, so you cannot "use" it by reading it; you build the link from the rules below.

How to answer a user

  1. Translate the task into board tiles (sections 3 and 4).
  2. Pick a robot start pose that keeps the whole figure on the field (section 5).
  3. Give the user one complete link that ends with &run. It opens the simulator, loads the program and starts it about 4 seconds later.
  4. In plain words, say what the program does and where the tiles sit ("top row: Function x10; function row: Forward 100, Right 36"), so the user can rebuild it on a real board. The user can press the round Start button to run it again.

Copy the structure of a worked example (section 6) and change only what you need. Every example link there was opened and checked in a browser.

Before you answer: self-check (mandatory)

https://simulator.primastem.com/#top=<pairs>&fn=<pairs>&s=<8 chars>&r=<x>-<y>-<heading>[&m=<maze>][&sh=<shape>][&lang=<xx>]&run

Everything after # is a fragment; parameters may come in any order. No URL-encoding is needed: all characters are a-z 0-9 . , - & = #.

ParamValueMeaning
topup to 6 pairs, separated by ,The top row (the main program), pairs 1-6 from the left.
fnup to 5 pairs, separated by ,The function row (a subroutine), pairs 1-5. Leave fn out when the program has no Function tile.
s8 characters, read by positionView settings (table below). If omitted: light theme, marker on, grid ON, speed x1, field 6x6, flat view.
rx-y-headingRobot start: centre in mm and heading in degrees. Use integers, heading 0-359. Always include it: without r the robot starts in a random cell.
mdigit pairs crOptional maze (section 6.8). Turns the grid and maze mode on.
shsquare triangle star house circle spiralOptional "Repeat the shape" task: turns the grid off and challenge on, shows that target contour and puts the robot on its start (the task sets the start, so r is ignored). A run that draws the contour within 15 mm gets the win card. A maze (m) wins if both are given.
langen fr es it nl de sv nb pl ru uk da ca pt fi tr ja he arOptional UI language. Without it the page follows the visitor's saved choice or browser language.
run&run or &run=NStart the program automatically, N seconds (default 1, at most 3600) after the 3-second splash. Needs at least one non-empty pair in the top row.
embed&embed=play or &embed=fullOnly for a link placed in an <iframe> on another site. play shows the board and field run-only (Start replays from the start pose, nothing can be edited); full shows the whole simulator, editable, starting from the link's scene. Leave it out of links the user opens directly.

Pairs

The board has a top row of 6 pairs and a function row of 5 pairs; each pair holds a command tile and, optionally, one value tile. In the link a pair is written as

Pairs are separated by commas and fill the row from the left: top=cfor.n400,crig,cfor.n300 is Forward 400 in pair 1, Right in pair 2, Forward 300 in pair 3; pairs 4-6 stay empty. Nothing needs counting: write only the pairs you use. Examples:

Two commas in a row (cfor,,crig) leave an empty pair in between, which the robot skips; you never need that. More than 6 pairs in top (or 5 in fn) do not fit on the board and are ignored. A pair with more than two codes, two commands, or a value without a command is an error pair (red LED, skipped), as on the real board.

The older 22-field p= form still works (section 9). If a link has both, p= wins and top/fn are ignored.

The 8 characters of s

#CharValuesMeaning
1themel light, d dark, w white (print)Look only.
2marker1 pen down, 0 pen upMust be 1 to draw.
3grid1 on, 0 offGrid on = map/maze look with cell lines. Off = plain sheet for drawings. Does not change how commands move.
4speed1 2 4 8Speed multiplier. 1 is the real robot's pace.
5age4 (ages 4-6), 7 (ages 7-10)Which tiles the tray offers. Use 7 when the program has numbers or arithmetic.
6field4-9Field is N x N cells of 150 mm. Default 6.
7map opacity0 1 2Background map 100/66/33 %. Use 0.
8view2 flat, 3 3D tiltUse 2 unless the user wants the 3D look.

Every character is read by its position, so write all 8. An invalid character leaves that setting at its default.

Ready-made values:

3. Tile codes

CodeTilePairs with
cforForward (move, mm)nothing, a repeat, a number or arithmetic
cbacBack (move backwards, mm)same as Forward
clefLeft (turn counter-clockwise, degrees)same as Forward
crigRight (turn clockwise, degrees)same as Forward
cwatPause (seconds)same as Forward
cfunFunction: run the 5 function-row pairsnothing or a repeat. A number/arithmetic is an ERROR
crndRandom move: one cell (150 mm) forward, back, or turn 90 then forwardnothing or a repeat. A number/arithmetic is an ERROR
r002-r999Repeat N times (r002-r006 are the dotted tiles)one command
rrndDice repeat: random 1-6 times each runone command
n001-n999Number: sets the command's amountForward, Back, Left, Right, Pause
a001-a999Arithmetic: add N to the command's saved amountsame as a number
s001-s999Arithmetic: subtract Nsame
m001-m999Arithmetic: multiply by Nsame
d001-d999Arithmetic: divide by Nsame
e001-e999Arithmetic: raise to the power Nsame
sqrtArithmetic: square rootsame

Values are always 3 digits with leading zeros: 45 is n045, 7 repeats is r007. An unknown code becomes a red error cell.

4. Program rules

Timing at x1: 150 mm takes 1.75 s, a 90 turn about 0.8 s, plus a 0.14 s beat after every pair and before each function call. Speed x2/x4/x8 divides all of it. The robot speaks only when a person presses Start at x1; the &run start is always silent.

5. Geometry

x, y, h = start
for each step: if move d: x += d*sin(h deg); y -= d*cos(h deg); track min/max
               if turn a: h += a   (right +, left -)

6. Worked examples

All on a 6x6 field. Each link was opened in a browser, ran to the end and stayed on the field.

6.1 Square (side 300 mm)

Top row: Function x4. Function row: Forward 300, Right (default 90). Start (300, 600), heading 0; the square spans x 300-600, y 300-600.

https://simulator.primastem.com/#top=cfun.r004&fn=cfor.n300,crig&s=l1047602&r=300-600-0&run

For ages 4-6 (no numbers): cfor alone gives 150 mm sides, crig alone 90.

6.2 Equilateral triangle (side 400 mm)

Function x3: Forward 400, Right 120. Start (250, 623), heading 30, so the base is horizontal.

https://simulator.primastem.com/#top=cfun.r003&fn=cfor.n400,crig.n120&s=l1047602&r=250-623-30&run

6.3 Decagon (side 100 mm)

Function x10: Forward 100, Right 36. R = 161.8, apothem 153.9; start (400, 296), heading 90 centres it at (450, 450).

https://simulator.primastem.com/#top=cfun.r010&fn=cfor.n100,crig.n036&s=l1047602&r=400-296-90&run

6.4 Five-point star

Function x5: Forward 400, Right 144 (5 x 144 = 720, two full turns, so it closes). Start (250, 405), heading 90; the star spans x 250-650, y 260-640.

https://simulator.primastem.com/#top=cfun.r005&fn=cfor.n400,crig.n144&s=l1047602&r=250-405-90&run

6.5 Circle (36-gon)

Function x36: Forward 25, Right 10. Radius about 143 mm; start (438, 307), heading 90 centres it at (450, 450).

https://simulator.primastem.com/#top=cfun.r036&fn=cfor.n025,crig.n010&s=l1047602&r=438-307-90&run

6.6 Square spiral (arithmetic)

Top row: Forward 30, then Function x20. Function row: Right (90), Forward +30. Each pass the side grows by 30 mm (60, 90, ... 630). Start (450, 465), heading 0; the spiral spans x 150-750, y 135-765. The first pair cfor.n030 resets Forward, so pressing Start again draws the same spiral.

https://simulator.primastem.com/#top=cfor.n030,cfun.r020&fn=crig,cfor.a030&s=l1047602&r=450-465-0&run

6.7 Heptagon (turn of 360/7, not an integer)

Top row: Right 360 (one spin), Right ÷7 (turns 51.43 and saves it), Function x7. Function row: Forward 200, Right (reuses 51.43). Start (350, 232), heading 39: after the spin and the 51.43 turn the robot faces right (90.4).

https://simulator.primastem.com/#top=crig.n360,crig.d007,cfun.r007&fn=cfor.n200,crig&s=l1047602&r=350-232-39&run

6.8 Drive to a cell (maze, grid on)

The maze param m lists cells as two digits each, column then row (0-based, from the top-left): the first pair is the goal flag, the rest are obstacles. Here: goal at column 4 row 1 (41, on screen E2), obstacles at (1,3), (2,3), (3,3) (B4, C4, D4). The robot starts in the bottom-left cell (75, 825) facing up. Program, no numbers (ages 4-6): Forward x4, Right, Forward x4.

https://simulator.primastem.com/#top=cfor.r004,crig,cfor.r004&s=l1144602&r=75-825-0&m=41132333&run

In maze mode a run is a game: entering an obstacle cell or bumping the field edge is a crash; ending on the goal cell is a win. The win/crash card appears after the run, whether it was started by &run or by the Start button. Maze digits must be smaller than the field size. If the start pose sits on the goal or an obstacle, the robot is moved to the nearest free cell.

6.9 House (square with an equilateral roof, one line)

Side 300. The function row draws the square (Forward 300, Right); the top row calls it 4 times, then drives up the left wall again and draws the roof: Forward (reuses 300), Right 30, Forward, Right 120, Forward. That is 6 top-row pairs, the limit. Start (300, 730), heading 0.

RowPairIn the linkMeaning
top1cfun.r004Function x4 (the square)
top2cforForward 300 (saved) up the left wall
top3crig.n030Right 30 (heading 30)
top4cforForward 300 to the apex
top5crig.n120Right 120 (heading 150)
top6cforForward 300 down to the top-right corner
fn1cfor.n300Forward 300
fn2crigRight 90

Trace: (300,730) -> (300,430) -> (600,430) -> (600,730) -> (300,730) [square done, heading 0] -> (300,430) -> apex (450,170) -> (600,430). All within [60, 840].

https://simulator.primastem.com/#top=cfun.r004,cfor,crig.n030,cfor,crig.n120,cfor&fn=cfor.n300,crig&s=l1047602&r=300-730-0&run

6.10 Letter П (two legs down from a top bar)

One line: up the left leg, along the bar, down the right leg. Top row only: Forward 400, Right, Forward 300, Right, Forward 400. Start (300, 650), heading 0 (the bottom of the left leg).

Trace: (300,650) -> (300,250) -> (600,250) -> (600,650). All within [60, 840]. Note the start is the BOTTOM of a leg: starting at y = 400 instead would put the top bar at y = 0 and the robot would stop at the edge.

https://simulator.primastem.com/#top=cfor.n400,crig,cfor.n300,crig,cfor.n400&s=l1047602&r=300-650-0&run

7. Common mistakes

8. Self-check again before you send

9. Advanced: the 22-field p= form

The share links the simulator itself writes (Share button, QR code) use an older form: #p= followed by all 22 board cells joined by -, empty cells included. It works and keeps working, but it is easy to miscount, so do not write it yourself; use top/fn. Read it only to understand a link a user pastes. If a link has p=, any top/fn in it is ignored.

The 22 cells in link order: top-row pairs 1-6 (slots 1-12), then function-row pairs 1-5 (slots 13-22); in each pair the top cell comes first.

SlotRowPairCellSlotRowPairCell
1top1top12top6bottom
2top1bottom13function1top
3top2top14function1bottom
4top2bottom15function2top
5top3top16function2bottom
6top3bottom17function3top
7top4top18function3bottom
8top4bottom19function4top
9top5top20function4bottom
10top5bottom21function5top
11top6top22function5bottom

An empty cell is an empty field, so empty cells show up as --; 21 hyphens in all. The square from 6.1 in this form (the same program as #top=cfun.r004&fn=cfor.n300,crig):

https://simulator.primastem.com/#p=cfun-r004-----------cfor-n300-crig-------&s=l1047602&r=300-600-0&run

10. Also useful