Library for simple Match3 games. It can work with a solid grid of figures and spill them only in columns.

Forest walk


Create the enum for all kinds of figures:

typealias MyGrid = Grid<Shape>
typealias MyController = Controller<Shape, Generator<Shape>, Matcher<Shape>>

enum Shapes: String, GridFilling {
    case square
    case circle
    case triangle

    var pattern: Pattern {
        Pattern(indices: [])

Create a grid controller with configurations:

let controller = MyController(
    size: Size(columns: 6, rows: 6),
    basic: [.square, .circle, .triangle],
    bonuse: [],
    obstacles: []

Create UI based on the grid that the controller generated:

for index in allIndices {
    let cell = controller.grid.cell(at: index)
    setupUI(for: cell, at: index)

Swap figures after the user interaction:

func swap(source: Index, target: Index) {
    if controller.canSwapCell(at: source, with: target) {
        swapUI(source, target)
        if controller.shouldSwapCell(at: source, with: target) {
            let indices = controller.swapAndMatchCell(at: source, with: target)
            let match = controller.match(indices: indices, swapIndices: [source, target], refill: .spill)
        } else {
            swapUI(source, target)

Used in:

Forest walk

Forest walk


  • Add more examples with bonuses
  • Add a demo project


  • Swift Tools 5.6.0
View More Packages from this Author


  • None
Last updated: Fri Feb 16 2024 01:09:26 GMT-1000 (Hawaii-Aleutian Standard Time)