Eight connection game variants across rhombus and triangular boards, with bridge-aware MCTS search, pie rule, and the same embed and SDK every family uses.
Every game family shares one embed surface. Select the family and variant through the URL.
<iframe
src="https://engine.moddable.games/play/?embed=1&family=hex&variant=standard"
style="width:100%;max-width:560px;aspect-ratio:1/1;border:none"
title="Play Hex"
></iframe>
| Param | Values | Default |
|---|---|---|
embed | 1 | Required for embed mode |
family | hex | chess |
variant | Any variant key below | standard |
opponent | ai | human | ai |
difficulty | beginner | easy | medium | hard | expert | medium |
theme | Board theme id | classic |
Commands accept either the generic game: prefix or the family prefix, so game:undo and hex:undo both work.
iframe.contentWindow.postMessage({ type: 'game:setVariant', variant: 'y-game' }, '*')
iframe.contentWindow.postMessage({ type: 'game:setDifficulty', difficulty: 'hard' }, '*')
iframe.contentWindow.postMessage({ type: 'game:newGame' }, '*')
iframe.contentWindow.postMessage({ type: 'game:undo' }, '*')
iframe.contentWindow.postMessage({ type: 'game:pass' }, '*')
iframe.contentWindow.postMessage({ type: 'game:resign' }, '*')
iframe.contentWindow.postMessage({ type: 'game:requestState' }, '*')
window.addEventListener('message', (e) => {
switch (e.data.type) {
case 'game:ready': break // { family, variant, state }
case 'game:move': break // { move, state }
case 'game:status': break // { text, gameOver, family, variant }
case 'game:state': break // { state } in reply to requestState
}
})
All eight variants from the moddable-rules Hex hub are playable. Five are standard Hex on different board sizes; three are Y, played on a triangular board where both players must connect all three sides.
| Key | Board | Distinguishing rule |
|---|---|---|
standard | 11×11 rhombus | Tournament size; connect opposite edges; pie rule |
9x9 | 9×9 rhombus | Smaller board for faster games |
13x13 | 13×13 rhombus | Larger board; deeper strategy |
14x14 | 14×14 rhombus | International competition size |
19x19 | 19×19 rhombus | Largest standard size |
y-game | 12-side triangle | Connect all 3 sides; both players share the same objective |
y-large | 16-side triangle | Larger Y board |
y-small | 8-side triangle | Compact Y board |
The plugin is pure connection logic. All configuration arrives via frontmatter:
| Config key | Effect |
|---|---|
connect | "edges" (Hex: opposite pair) | "all-sides" (Y: all three) |
pieRule | After the first stone, second player may swap instead of replying |
shape | "rhombus" | "triangle" |
sideLength | Board size (cells per edge) |
No draws are possible on a hex grid. The search is MCTS with a bridge-aware rollout policy: if an opponent probes any bridge carrier, the defender always replies to maintain the connection.
import { createGame, createAI, listVariants } from 'moddable-engine/play'
listVariants('hex') // [{ key, label, group, board }]
const game = createGame('hex', 'standard')
game.applyMove({ action: 'place', to: '5,5' })
const ai = createAI('hex', 'standard', { difficulty: 'hard' })
ai.pickMove(game.getState().slice, 0) // MCTS with bridge-aware rollouts