> For the complete documentation index, see [llms.txt](https://sbscripts.gitbook.io/sb-scripts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sbscripts.gitbook.io/sb-scripts/sb-minigames/games-memory.md).

# Games: Memory

### ColorMatch

A target colour swatch and a colour *word* are shown. The word is printed in some ink colour, and the word itself is a distraction. Answer whether the **ink colour** matches the swatch. Wrong and slow answers fail.

**Controls:** `Y` for match, `N` for no match, or the buttons

```lua
exports['sbminigames']:ColorMatch({ rounds = 8, speed = 1100 }, cb)
```

Positional: `ColorMatch(rounds, speed, callback)`

| Option   | Type | Default | Range       | What it does                    |
| -------- | ---- | ------- | ----------- | ------------------------------- |
| `rounds` | int  | `6`     | 3 to 10     | Prompts to answer               |
| `speed`  | int  | `1400`  | 600 to 2500 | Milliseconds allowed per prompt |

### PatternMirror

The left grid shows a pattern. Rebuild it on the right grid **as a mirror image**, then confirm. With `showTime`, the pattern disappears and you have to remember it.

**Controls:** mouse, `Enter` to confirm

```lua
exports['sbminigames']:PatternMirror({ gridSize = 5, showTime = 3000, time = 25 }, cb)
```

Positional: `PatternMirror(gridSize, time, callback)`

| Option     | Type | Default | Range     | What it does                                              |
| ---------- | ---- | ------- | --------- | --------------------------------------------------------- |
| `gridSize` | int  | `4`     | 3 to 5    | Columns per grid (always 3 rows)                          |
| `showTime` | int  | `0`     | 0 to 5000 | Milliseconds the pattern is visible (`0` = stays visible) |
| `time`     | int  | `20`    | 0 to 600  | Seconds before failing (`0` = no limit)                   |

### CardMatch

Cards are shown face up for a moment, then flipped down. Flip two at a time to find every pair. A wrong pair costs a life.

**Controls:** mouse

```lua
exports['sbminigames']:CardMatch({ pairs = 8, peek = 1500, lives = 5 }, cb)
```

Positional: `CardMatch(pairs, time, callback)`

| Option  | Type | Default | Range     | What it does                                  |
| ------- | ---- | ------- | --------- | --------------------------------------------- |
| `pairs` | int  | `6`     | 3 to 8    | Pairs on the board                            |
| `peek`  | int  | `1200`  | 0 to 3000 | Milliseconds the cards are shown at the start |
| `lives` | int  | `6`     | 1 to 10   | Wrong pairs allowed                           |
| `time`  | int  | `40`    | 0 to 600  | Seconds before failing (`0` = no limit)       |

### SlidePuzzle

A classic sliding puzzle. Slide the tiles into numerical order, with the gap in the bottom-right corner.

**Controls:** mouse or arrow keys

```lua
exports['sbminigames']:SlidePuzzle({ size = 3, shuffleSteps = 30, time = 60 }, cb)
```

Positional: `SlidePuzzle(size, shuffleSteps, time, callback)`

| Option         | Type | Default | Range    | What it does                              |
| -------------- | ---- | ------- | -------- | ----------------------------------------- |
| `size`         | int  | `3`     | 3 to 4   | `3` is the 8-puzzle, `4` is the 15-puzzle |
| `shuffleSteps` | int  | `20`    | 10 to 80 | Random moves used to scramble the board   |
| `time`         | int  | `0`     | 0 to 600 | Seconds before failing (`0` = no limit)   |
