main.cpp

examples/pychess/main.cpp

@file main.cpp @brief PyChess — play chess against a local LLM via the entropic C API.

Owners: @tvanfossen

game_loop

static void game_loop(entropic_handle_t handle)

Run the interactive chess game loop.

examples/pychess/main.cpp:430

Show on the map →

Called by run_game

Calls display_board, init_board, play_ai_turn, play_human_turn

Source · 11 lines
static void game_loop(entropic_handle_t handle)
{
    GameState state{};
    init_board(state);
    std::printf("PyChess — You are White, AI is Black.\n");
    std::printf("Enter moves in UCI notation (e.g. e2e4). Type 'quit' to exit.\n");
    display_board(state.board);
    while (play_human_turn(state) && play_ai_turn(handle, state)) {
        /* continue until quit or error */
    }
}
Activity · 6 steps
lines 432–432GameState state{};lines 433–433init_board(state);lines 434–434std::printf("PyChess — You are White, AI is Black.\n");lines 435–435std::printf("Enter moves in UCI notation (e.g. e2e4). Type 'quit' to exit.\n");lines 436–436display_board(state.board);lines 437–437◇ while (play_human_turn(state) && play_ai_turn(handle, state))

Flows

main

int main(int argc, char *argv[])

Entry point.

examples/pychess/main.cpp:477

Show on the map →

Called by none

Calls run_game

Source · 6 lines
int main(int argc, char* argv[])
{
    (void)argc;
    (void)argv;
    return run_game();
}
Activity · 3 steps
lines 479–479(void)argc;lines 480–480(void)argv;lines 481–481return run_game();

Flows

run_game

static int run_game()

Run the pychess game.

examples/pychess/main.cpp:455

Source · 11 lines
static int run_game()
{
    entropic_handle_t handle = setup_engine(".pychess");
    if (!handle) {
        return EXIT_FAILURE;
    }
    game_loop(handle);
    entropic_destroy(handle);
    std::printf("Goodbye!\n");
    return EXIT_SUCCESS;
}
Activity · 7 steps
lines 457–457entropic_handle_t handle = setup_engine(".pychess");lines 458–458◇ if (!handle)lines 459–459return EXIT_FAILURE;lines 461–461game_loop(handle);lines 462–462entropic_destroy(handle);lines 463–463std::printf("Goodbye!\n");lines 464–464return EXIT_SUCCESS;

Flows