Matrix workshop: reading a button bar and a game board as a matrix
Set up a button bar (Clicker Heroes buy amount) and a Connect-Four board with the Matrix workshop: colours from cells, sample point next to the label, templates from cells, find cells, detect lines.
A matrix is a grid of cells the bot reads in one go: every cell gets a state such as "yellow", "orange", "empty" or "x100". That lets you evaluate button bars, inventory slots, skill bars and game boards without building a node for every single field. Since version 1.4.0 you set everything up in the Matrix workshop and see immediately what the bot will read.
Download example bot: buy amount Download example bot: Connect Four
The idea
- Read matrix lays a grid over an area and recognises every cell.
- The data nodes Find cell, For each cell, Find line, Count matrix and Matrix cell evaluate the
matrix — each delivers the screen centre of the cell (
x,y), which you connect straight to Click. - Wait for cell and Matrix change react when something happens.
Part A — button bar: which buy amount is selected?
Clicker Heroes has the buttons x1, x10, x25, x100, MAX. The selected one is orange, the others yellow, unaffordable ones grey.
Step 1 — add Read matrix
- Capture window as usual, then attach Read matrix from Perception.
- The properties panel shows the Matrix block with a summary — click Open matrix workshop….
Step 2 — draw the grid
- The workshop shows the window. Drag a rectangle exactly around the five buttons.
- Set Rows to
1and Columns to5. If the buttons differ in width, move the cyan dividing lines. - Every cell now shows a colour dot (the sample point) — still without a name.
Step 3 — move the sample point next to the label
At first the sample point sits in the cell centre — on buttons that is exactly the label, which is why the colours scatter.
- Drag the ring (with no cell selected) to the left, e.g. to 15 % — that moves the sample point for all cells next to the label.
- If one cell needs a different point: click the cell, then drag its ring. That deviation applies only to this cell and is listed under "Sample point".
Step 4 — name the colours
- In Recognition keep Colour (palette).
- Click + Colour from cell, then a yellow button → "Colour 1" with that colour appears. Rename it to
yellow. - Likewise: orange button →
orange, grey button →grey. - Watch the badges on the cells: they now read
yellow,orange,grey. If a red?remains somewhere, raise the tolerance a little or move the sample point.
Group automatically proposes a palette from the measured cell colours ("Colour 1, 2, 3") — you only have to assign the names.
Step 5 — apply and use
Click Apply. The panel now says "1 × 5 cells · colours: 3 (yellow, orange, grey)". During a run the log shows
↳ Row 0: yellow | yellow | orange | yellow | grey.
- Find cell with label
orange→ output found,zeile/spaltetell you which amount is selected. - To click MAX: Find cell with label
MAXworks in text mode (see part C) — in colour mode use Matrix cell with column 4 and connectx/yto a Click node. - Count matrix with value
orange→anzahl= 1 means "one amount is selected".
Alternative: image mode (template per state)
If colours are not enough (e.g. buttons with icons), set Recognition to Image (template per state): click
+ Record from cell, then a cell — the crop is saved as a template and called "State 1". Repeat once per state and
assign names. The bot compares every cell with all templates; below the similarity it shows ?. The templates live
in your profile's template folder and are embedded when saving.
Part B — game board: Connect Four
A 6 × 7 board with red and yellow pieces on a dark background.
- Read matrix → workshop: rectangle around the board, Rows 6, Columns 7.
- Palette: Colour from cell on a red piece →
red, on a yellow one →yellow, on an empty field →empty. - Find line after the matrix (data cable
matrix → matrix):- Label
red, Length4, Directions all, Gap0→ output found means "red has four in a row" (horizontal, vertical or diagonal).richtungsays which. - Where do I win? The same node with Gap
1, Label of empty cellsempty, Gravity on: it finds a line of three with one gap a piece can drop into —x/ypoint to exactly that cell → Click. - Where must I block? Same settings, but Label = the opponent's colour.
- Label
- For each cell with filter
emptydelivers all free fields one after another — handy for "play anywhere free" (orderrandom).
Order matters: the bot first checks "can I win", then "must I block", then "any free field". Build that with three Find line/For each cell nodes in a row, continuing from notfound or done respectively.
Part C — numbers and text per cell (OCR)
Set Recognition to Text / number (OCR): the bot reads the text of every cell (Sudoku, tables, quantities in an
inventory, the labels of the buy-amount buttons). Tips: Magnification 3–4 for small digits, Digits only when
only values matter, Invert for light text on a dark background. The result table shows the texts read; an empty
cell reads as ·.
Part D — waiting and detecting changes
- Wait for cell (Perception): choose a matrix node, a cell (or "any") and a label and wait with a time limit until
it appears — e.g. "wait until cell [0,4] is
grey" (cooldown over). - Matrix change (Conditions): compares with the previous pass and takes geaendert on differences —
zeile/spaltename the first changed cell.
When cells show "?"
| Cause | Remedy |
|---|---|
| Sample point hits text/icon | Drag the ring next to the label (globally or only this cell) |
| Tolerance too small | Raise the "Tolerance" slider until the badges are right |
| Template larger than the cell | Record the template again from the cell (warning in the workshop) |
| Grid shifted (window moved) | Use "relative to anchor" or draw the rectangle again |