← Hub
♟ PAWN TO CODE
Train your AI. Then face it.

TOOLBOX

IF (Conditions)

My King is in check Enemy piece is capturable Enemy Queen capturable My Queen is threatened A Pawn can be promoted My piece is threatened Center is open Always

THEN (Actions)

Escape check Capture the piece Capture the Queen Move Queen to safety Promote the Pawn Develop a piece Control the center Castle if possible Make a random move

YOUR RULES (evaluated top → bottom)

    PIECE VALUES

    How much is each piece worth to your AI? Higher = it fights harder to capture or protect it.

    Pawn
    Knight
    Bishop
    Rook
    Queen

    STRATEGY FOCUS

    AI personality knobs. These kick in when no IF/THEN rule fires, and affect capture priority.

    Opening Style Balanced
    King Safety Center Control
    Playstyle Balanced
    Defensive Aggressive

    AS PYTHON

    These variables are auto-injected into your Python code — use them directly.

    
              
    1

    AVAILABLE API

    # Board helpers:
    board.get_legal_moves(color) # all legal moves
    board.get_captures(color) # capturing moves only
    board.is_in_check(color) # True/False
    board.get_piece(square) # e.g. "e4" → piece or None
    board.get_threatened_squares(color)
    # Move properties:
    move.to_square # e.g. "e4"
    move.piece_type # "pawn","knight",etc.
    move.captured_piece # piece type or None
    # Injected from Values tab:
    PIECE_VALUES # {"pawn":1,"knight":3,...}
    STRATEGY_CONFIG # {"opening":..., "aggression_multiplier":...}
    You (White) vs. Your AI (Black)

    CHECKMATE!

    The AI wins this round.