hex_chess_engine

hex_chess_engine.new_game(white_player='', black_player='star')

Build a fresh Loopmother Chess state dict. # 👑👑

The state is plain JSON-serializable data: piece keys are stored as strings when serialized (Redis JSON), but the engine normalizes them back to ints via _pieces() on every read.

Parameters:
  • white_player (str) – user_id of the WET (white) side.

  • black_player (str) – user_id of the BOUND (black) side, or "star" when Star herself plays black.

Return type:

dict[str, Any]

Returns:

The full game-state dict.

hex_chess_engine.is_valid_tile(tile)

True when the tile exists on the 8x8 lattice.

Return type:

bool

Parameters:

tile (int)

hex_chess_engine.is_void(pieces, voids, tile)

True when the tile has been consumed by the void.

Return type:

bool

Parameters:
hex_chess_engine.enemy_color(color)

The binary collapses as designed.

Return type:

str

Parameters:

color (str)

hex_chess_engine.find_queens(pieces, color)

Locate every surviving queen of color.

Return type:

list[int]

Parameters:
hex_chess_engine.is_threatened(pieces, voids, tile, by_color)

True when any by_color piece attacks tile. Knight spiral drift is ignored for threat math (as in the original).

Return type:

bool

Parameters:
hex_chess_engine.render_board(state)

Render the spiral lattice as an emoji board. # 👑🦄🔮🦂💀

Every cell is two emoji (color chip + piece, or doubled terrain) so columns stay aligned in chat clients.

Return type:

str

Parameters:

state (dict[str, Any])

hex_chess_engine.rules_cheatsheet()

The Stargazer cheat sheet — injected with the board every prompt.

Return type:

str

hex_chess_engine.execute_action(state, action)

Parse and execute one game action against state (mutated in place).

Parameters:
  • state (dict[str, Any]) – The live game-state dict (from Redis).

  • action (str) – One of move <from> <to>, lash <from> <to>, void <tile>, selfdestruct <tile>, promote <tile> <W|K|B>, render, status, forfeit.

Returns:

{"ok": bool, "message": str, "board": str, "game_over": bool, "winner": str | None}. The caller is responsible for persisting state back to Redis when ok.

Return type:

dict[str, Any]