art.games
chess boards from FEN, playing cards, dice faces
Example results generated on 2026-10-08. Ones using
now,todayor randomness will differ when you run them: press Run on any example to run it in your browser, after editing it if you like.
Functions
| function | description |
|---|---|
chess(fen?: str) | a chess board from the piece part of a FEN string; the starting position by default |
card(c: str) | a playing card like “A♠”, “10h” or “qd” (suits ♠♥♦♣ or s h d c); “?” is the back |
cards(hand: list) | playing cards side by side |
dice(faces: int|list) | die faces with pips, 1-6, side by side for a list |
chess
chess(fen?: str): a chess board from the piece part of a FEN string; the starting position by default
chess()
# → 8 ♜ ♞ ♝ ♛ ♚ ♝ ♞ ♜
# → 7 ♟ ♟ ♟ ♟ ♟ ♟ ♟ ♟
# → 6 · · · ·
# → 5 · · · ·
# → 4 · · · ·
# → 3 · · · ·
# → 2 ♙ ♙ ♙ ♙ ♙ ♙ ♙ ♙
# → 1 ♖ ♘ ♗ ♕ ♔ ♗ ♘ ♖
# → a b c d e f g h
chess("8/8/8/4k3/8/8/4P3/4K3 w - - 0 1")
# → 8 · · · ·
# → 7 · · · ·
# → 6 · · · ·
# → 5 · · ♚ ·
# → 4 · · · ·
# → 3 · · · ·
# → 2 · · ♙ · ·
# → 1 · · ♔ ·
# → a b c d e f g h
See also: card
card
card(c: str): a playing card like “A♠”, “10h” or “qd” (suits ♠♥♦♣ or s h d c); “?” is the back
card("Q♥")
# → ┌─────┐
# → │Q │
# → │ ♥ │
# → │ Q│
# → └─────┘
cards
cards(hand: list): playing cards side by side
cards(["As", "Kh", "?"])
# → ┌─────┐ ┌─────┐ ┌─────┐
# → │A │ │K │ │░░░░░│
# → │ ♠ │ │ ♥ │ │░░░░░│
# → │ A│ │ K│ │░░░░░│
# → └─────┘ └─────┘ └─────┘
See also: card
dice
dice(faces: int|list): die faces with pips, 1-6, side by side for a list
dice(5)
# → ┌───────┐
# → │ ● ● │
# → │ ● │
# → │ ● ● │
# → └───────┘
dice([1, 2, 3])
# → ┌───────┐ ┌───────┐ ┌───────┐
# → │ │ │ ● │ │ ● │
# → │ ● │ │ │ │ ● │
# → │ │ │ ● │ │ ● │
# → └───────┘ └───────┘ └───────┘
More examples
games
# what you rolled
dice(roll("3d6").rolls)
# → ┌───────┐ ┌───────┐ ┌───────┐
# → │ ● ● │ │ ● │ │ │
# → │ │ │ │ │ ● │
# → │ ● ● │ │ ● │ │ │
# → └───────┘ └───────┘ └───────┘
# a royal flush
cards(["10♠", "J♠", "Q♠", "K♠", "A♠"])
# → ┌─────┐ ┌─────┐ ┌─────┐ ┌─────┐ ┌─────┐
# → │10 │ │J │ │Q │ │K │ │A │
# → │ ♠ │ │ ♠ │ │ ♠ │ │ ♠ │ │ ♠ │
# → │ 10│ │ J│ │ Q│ │ K│ │ A│
# → └─────┘ └─────┘ └─────┘ └─────┘ └─────┘
# the opening position
chess()
# → 8 ♜ ♞ ♝ ♛ ♚ ♝ ♞ ♜
# → 7 ♟ ♟ ♟ ♟ ♟ ♟ ♟ ♟
# → 6 · · · ·
# → 5 · · · ·
# → 4 · · · ·
# → 3 · · · ·
# → 2 ♙ ♙ ♙ ♙ ♙ ♙ ♙ ♙
# → 1 ♖ ♘ ♗ ♕ ♔ ♗ ♘ ♖
# → a b c d e f g h