Examples

Learn ChessLang through practical examples

King of the Hill

Win by moving your King to the center squares (d4, d5, e4, e5).

Try it
victory conditionzoneslevel 1
game: "King of the Hill"
extends: "Standard Chess"

board:
  zones:
    hill: [d4, d5, e4, e5]

# OR 결합: checkmate OR hill
victory:
  add:
    hill: King in zone.hill

Three-Check

Win by giving check three times.

Try it
victory conditionstate trackinglevel 1
game: "Three-Check"
extends: "Standard Chess"

# OR 결합: checkmate OR three_checks
victory:
  add:
    three_checks: checks >= 3

Amazon

Define a piece that combines Queen and Knight moves.

Try it
custom piecespatternslevel 2
piece Amazon {
  move: slide(orthogonal) | slide(diagonal) | leap(2, 1)
  capture: =move
  traits: [jump]
  value: 12
}

Cannon (포)

Xiangqi-style piece that hops over one piece to capture.

Try it
custom pieceshoplevel 2
piece Cannon {
  move: slide(orthogonal)
  capture: hop(orthogonal)
  value: 5
}

Vampire

Converts captured pieces to your side!

Try it
custom piecestriggersstatelevel 2
piece Vampire {
  move: step(any) | leap(2, 0)
  capture: =move
  traits: [jump]
  state: { thralls: 0 }
  value: 6
}

trigger vampiric_conversion {
  on: capture
  when: piece.type == Vampire and captured.type != King
  do: {
    set captured.owner = piece.owner
    set piece.state.thralls = piece.state.thralls + 1
  }
}

Necromancer

Collects souls to summon Zombies!

Try it
custom piecestriggerssummoninglevel 2
piece Necromancer {
  move: step(diagonal)
  capture: =move
  state: { souls: 0 }
  value: 6
}

piece Zombie {
  move: step(forward) | step(orthogonal)
  capture: step(any) where enemy
  value: 1
}

trigger collect_soul {
  on: capture
  do: set Necromancer.state.souls += 1
}

trigger raise_zombie {
  on: turn_start
  when: any Necromancer where state.souls >= 3
  do: {
    create Zombie at empty adjacent to Necromancer
    set Necromancer.state.souls -= 3
  }
}

Medusa

Freezes enemies in her diagonal line of sight!

Try it
custom pieceseffectscontrollevel 2
piece Medusa {
  move: step(any)
  capture: slide(diagonal)
  state: { gazeActive: true }
  value: 5
}

effect frozen {
  blocks: [all]
  duration: 2
  visual: highlight(cyan, 0.5)
}

trigger medusa_gaze {
  on: turn_start
  when: any Medusa
  do: mark pieces in line(diagonal) from Medusa where enemy with frozen
}

Time Bomb

Explodes after 3 turns, destroying nearby pieces!

Try it
custom piecestriggersdelayedlevel 2
piece TimeBomb {
  move: step(orthogonal)
  capture: none
  state: { timer: 3 }
  value: 1
}

trigger countdown {
  on: turn_end
  when: any TimeBomb
  do: set piece.state.timer -= 1
}

trigger explode {
  on: turn_start
  when: any TimeBomb where state.timer <= 0
  do: {
    remove pieces in radius(2) from TimeBomb where not King
    remove TimeBomb
  }
}

Guardian

Protects adjacent friendly pieces from capture.

Try it
custom piecestriggersdefensivelevel 2
piece Guardian {
  move: step(any)
  capture: =move
  state: { protected: 0 }
  value: 4
}

trigger protection {
  on: capture
  when: any Guardian adjacent to captured where Guardian.owner == captured.owner
  do: {
    cancel  # Block the capture
    set Guardian.state.protected += 1
  }
}

Jester

Swaps positions with target instead of capturing.

Try it
custom piecestriggerspositionallevel 2
piece Jester {
  move: step(any)
  capture: none
  state: { swapsUsed: 0 }
  value: 4
}

trigger jester_swap {
  on: move
  when: piece.type == Jester and target has piece
  do: {
    let targetPiece = piece_at(target)
    move targetPiece to origin
    set piece.state.swapsUsed += 1
  }
}

Trap Effect

Mark squares with effects that affect movement.

Try it
effectstriggerslevel 2
effect trap {
  blocks: [enemy]
  visual: highlight(red)
}

trigger place_trap {
  on: move
  when: piece.type == Trapper
  do: mark origin with trap
}

Atomic Chess

Captures cause explosions that destroy nearby pieces!

Try it
triggersexplosionlevel 2
trigger atomic_explosion {
  on: capture
  do: {
    remove piece
    remove captured
    remove pieces in radius(1) from target where not Pawn
  }
}

victory:
  add:
    king_exploded: opponent.King == null

Want More?

Check out the documentation for a complete language reference.

Read the Docs