# one-random-human/stro4k architecture

> Architecture diagram of the GitHub repository one-random-human/stro4k, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/one-random-human/stro4k
- Repository: https://github.com/one-random-human/stro4k

## Overview

Main Components to Include:

##### Core Engine Components
- Management (position.rs)
- Move Generation (movegen.rs)
- Move Ordering (moveorder.rs)
- Evaluation (evaluate.rs)
- Search (search.rs, search/threads.rs)
- Transposition Table (tt.rs)

##### Interface Layer
- UCI (Universal Chess Interface) implementation (uci.asm)
- Game state management (game.rs, game.asm)

##### Architecture Patterns
- Parallel processing architecture (Lazy SMP)
- Search tree structure with:
- Principal Variation Search
- Aspiration Windows
- Various pruning techniques

##### Use a Layered Approach
- [UCI Interface Layer]
- ↕
- [Game Management Layer]
- ↕
- [Core Engine Layer]
- Position Management
- Move Generation
- Search Component
- Thread Management
- Evaluation System

- How information flows between components
- Search tree expansion
- Parallel processing paths

##### Evaluation Features Section
- Material evaluation
- Positional features
- Pawn structure analysis
- Mobility assessment

Implementation Notes:
- Size constraints (4096 bytes) as a notable constraint
- Both the STRO (full version) and STRO4K (size-constrained) variants
- AVX-512 optimization paths where applicable

Technical Stack Indicators:
- Rust implementation (stro)
- Assembly implementation (stro4k)
- Build system components
- Threading model

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Interface
        UCI["UCI Interface"]:::interface
        Game["Game State Management"]:::game
    end

    subgraph Core["Core Engine Components"]
        Position["Position Management"]:::core
        MoveGen["Move Generation"]:::core
        MoveOrder["Move Ordering"]:::core
        Eval["Evaluation"]:::core
        Search["Search"]:::core
        TT["Transposition Table"]:::core
        Threads["Thread Management"]:::core
    end

    subgraph Optimization["Optimization Techniques"]
        direction TB
        MVVLVA["MVV-LVA"]:::opt
        Killer["Killer Heuristic"]:::opt
        History["History Heuristic"]:::opt
        Pruning["Pruning Methods"]:::opt
    end

    subgraph Evaluation["Evaluation Features"]
        direction TB
        Material["Material Score"]:::eval
        Position["Positional Features"]:::eval
        Pawns["Pawn Structure"]:::eval
        Mobility["Mobility Assessment"]:::eval
    end

    %% Interface connections
    UCI --> Game
    Game --> Position

    %% Core component connections
    Position --> MoveGen
    Position --> Eval
    MoveGen --> Search
    MoveOrder --> Search
    Eval --> Search
    Search --> Threads
    Search --> TT

    %% Optimization connections
    MoveOrder --> MVVLVA
    MoveOrder --> Killer
    MoveOrder --> History
    Search --> Pruning

    %% Evaluation connections
    Eval --> Material
    Eval --> Position
    Eval --> Pawns
    Eval --> Mobility

    %% Click events for component mapping
    click UCI "https://github.com/ONE-RANDOM-HUMAN/STRO4K/blob/master/stro4k/src/uci.asm"
    click Game "https://github.com/ONE-RANDOM-HUMAN/STRO4K/blob/master/stro/src/game.rs"
    click Position "https://github.com/ONE-RANDOM-HUMAN/STRO4K/blob/master/stro/src/position.rs"
    click MoveGen "https://github.com/ONE-RANDOM-HUMAN/STRO4K/blob/master/stro/src/movegen.rs"
    click MoveOrder "https://github.com/ONE-RANDOM-HUMAN/STRO4K/blob/master/stro/src/moveorder.rs"
    click Eval "https://github.com/ONE-RANDOM-HUMAN/STRO4K/blob/master/stro/src/evaluate.rs"
    click Search "https://github.com/ONE-RANDOM-HUMAN/STRO4K/blob/master/stro/src/search.rs"
    click Threads "https://github.com/ONE-RANDOM-HUMAN/STRO4K/blob/master/stro/src/search/threads.rs"
    click TT "https://github.com/ONE-RANDOM-HUMAN/STRO4K/blob/master/stro/src/tt.rs"

    %% Styling
    classDef interface fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef game fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#FFB6C1,stroke:#333,stroke-width:2px
    classDef opt fill:#FFD700,stroke:#333,stroke-width:2px
    classDef eval fill:#DDA0DD,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        direction TB
        L1["Interface Components"]:::interface
        L2["Game Management"]:::game
        L3["Core Components"]:::core
        L4["Optimization"]:::opt
        L5["Evaluation"]:::eval
    end
```
