Intelligent UI Design and Implementation: Lessons from Mahjong Teaching

    Using mahjong teaching as a practical example, this article explores how intelligent interfaces can reduce the gap between AI-generated explanations and user actions. It compares generative and component-based interfaces, outlines a five-layer architecture, and examines state management, security, evaluation, and phased implementation. The focus is on separating language understanding, interaction, and deterministic validation to support reliable task completion.

    1. The Bottleneck in AI Interaction Is Not Just Answer Quality

    Improvements in AI assistants often focus on reasoning, coding, knowledge comprehension, and task planning. Yet more complete answers do not necessarily make an assistant easier to use.

    Consider teaching mahjong. Text can explain sequences, triplets, and pairs, or list a hand and analyze possible discards. Beginners must still reconstruct the tiles mentally, identify combinations, and translate their intended actions into words. As lessons become more complex, this translation becomes a barrier to understanding.

    The problem is not necessarily inaccurate text. It is a mismatch between the medium and the task. Mahjong involves spatial arrangements, relationships between combinations, and a sequence of actions that text alone cannot fully convey. Similar challenges arise in travel planning, device specification comparisons, data analysis, and business approvals. Users need more than conclusions: they need to inspect, select, modify, and confirm.

    Intelligent interfaces move some information and actions out of text. They do not need to generate an entire application. Instead, they can insert tile displays, tables, tabs, or action buttons into a conversation, allowing users to work directly with the objects involved in the task.

    The value of an intelligent interface should therefore be judged not by its visual richness, but by whether it reduces comprehension effort, interaction effort, and the likelihood of errors.

    2. Generative Interfaces and Component-Based Intelligent Interfaces

    2.1 Generative Interfaces: Organizing Interaction Around the Task

    A generative interface dynamically creates or configures its structure, content, and interaction flow based on user needs. Its output might be a small interactive area or a sequence of pages.

    For example, a request to compare travel plans could produce date selectors, route lists, and budget breakdowns. A request to practice recognizing mahjong combinations could produce a tile display with selection controls.

    This approach adapts well to different tasks, but greater freedom demands greater reliability. The system must handle layout consistency, input validation, state persistence, error recovery, and security boundaries. An interface that looks complete does not necessarily implement correct or stable business behavior.

    2.2 Component-Based Interfaces: Constraining the Model’s Choices

    A component-based approach starts with a set of validated UI components. The model then decides when to use them and how to combine them.

    Common components include:

    • Information cards for object summaries and key attributes.
    • Tables for comparing multiple objects across several dimensions.
    • Single-choice, multiple-choice, and confirmation controls for collecting explicit decisions.
    • Charts for presenting trends, distributions, and calculated results.
    • Specialized visualizations for tiles, workflows, or spatial relationships.

    The model primarily interprets user needs and organizes content. The application handles rendering, validation, and execution. This division reduces uncertainty and gives users more consistent interaction patterns across tasks.

    These approaches are not mutually exclusive. A practical system can prioritize standard components and introduce more flexible dynamic layouts only when necessary. The goal is not maximum generative freedom, but a balance between adaptability, reliability, and maintenance cost.

    3. Mahjong Teaching: From Explanation to Interactive Practice

    Mahjong teaching illustrates intelligent interface design because it combines conceptual explanation, visual recognition, rule validation, and strategic discussion.

    However, mahjong rules vary by region and variant. A teaching system should first specify the rules it uses, including the tile set, any special tiles, winning-hand requirements, and scoring. Conclusions from one ruleset must not be presented as universally applicable.

    3.1 Explain Concepts Through Visible Objects

    To explain a sequence, the interface can place three consecutive numbered tiles of the same suit together. To explain a triplet, it can show three identical tiles. Text defines the concept, while the tile display provides a visual reference.

    The first presentation should remain simple. Avoid showing too many buttons, probabilities, and technical terms at once. Beginners will usually find it easier to recognize basic combinations before learning how those combinations relate to one another, rather than encountering a complete strategy immediately.

    Tile displays should also include text labels, keyboard selection, and support for assistive reading tools so that users do not have to rely solely on color or images. Accessibility is part of component design, not an optional addition.

    3.2 Discard Practice: Feedback Must Match the Actual State

    During practice, users can click a tile in their hand to select it for discard. The system should distinguish selection from confirmation, particularly when an action cannot be undone or advances the exercise.

    A complete interaction can follow these steps:

    1. The user selects a tile.
    2. The interface highlights the selection.
    3. The user confirms the discard.
    4. The rules module checks whether the action is legal.
    5. The system updates the tile display and explains the result.

    Feedback should go beyond “Good job” or “Try another tile.” It should explain which combinations the choice affects, which opportunities it preserves, and which assumptions support the conclusion.

    Teaching exercises may allow undoing an action or trying again. Simulated games should follow the predefined turn rules. These modes need to be clearly distinguished.

    3.3 Strategy Comparisons: Probabilities Are Not Decorative

    When comparing discard options, the system must define its metrics.

    For example, the number of effective draws is not the same as the probability of drawing an effective tile on the next draw. The former concerns tiles that could improve the hand; the latter also depends on remaining tile counts, known exposed tiles, and the drawing model. The eventual probability of completing a winning hand involves a longer sequence of decisions and generally requires more assumptions.

    Under simplified conditions:

    1. Probability of an effective draw =
    2. Number of remaining tiles that meet the criteria
    3. / Total number of remaining drawable tiles

    Even this calculation requires a definition of “effective” and a clear account of the visible information available to the system. If those conditions are incomplete, the interface should present qualitative analysis or a range rather than a seemingly precise number.

    A more reliable division of responsibilities is for rules and calculation modules to produce verifiable results, while the model explains those results and their limitations.

    4. Technical Architecture: Separate Understanding, Presentation, and Execution

    A maintainable intelligent interface system can be organized into five main layers.

    4.1 Intent Understanding

    This layer identifies the user’s current goal: learning a concept, practicing, comparing options, or performing an action.

    It must also determine whether enough information is available. If a user requests an analysis of a mahjong hand without specifying the ruleset, the system should ask for clarification or state its assumptions before calculating a strategy.

    4.2 Interface Planning

    The interface planning layer decides which content belongs in text and which requires components.

    Components are especially useful when a task involves many objects, repeated edits, explicit choices, spatial comparisons, or structured comparisons. Short definitions and one-time explanations may not need additional interface elements.

    The plan should use a structured description rather than arbitrary executable code. The following is a conceptual example, not an interface from an existing product:

    1. Interface description:
    2. Task: Basic discard practice
    3. State version: 8
    4. Component:
    5. Type: Hand display
    6. Data source: Current exercise state
    7. Allowed actions: Select a tile, confirm discard
    8. Guidance:
    9. Show rule explanations
    10. Show an explanation after the action

    A structured description allows the rendering layer to validate component types, required fields, and permitted actions, preventing the model from introducing unconstrained executable behavior.

    4.3 Rendering and Interaction

    This layer converts the interface description into usable controls and provides consistent feedback for loading, errors, confirmation, and undo actions.

    Visual styles, button semantics, and keyboard behavior should remain as consistent as possible. Otherwise, users must repeatedly learn new interaction patterns, adding friction even if every individual interface works.

    4.4 State and Business Execution

    A button click must enter controlled business logic rather than become another message for the model to interpret freely.

    The state layer should retain the current hand, ruleset version, exercise progress, and allowed actions. The business layer validates requests, calculates results, and updates state. The model can explain those changes, but it must not bypass validation to modify authoritative state directly.

    4.5 Result Explanation

    After execution, the system generates an explanation based on confirmed results.

    The explanation should correspond to specific data and actions: why the action was legal, which conditions changed, and what the user can do next. This prevents the interface from showing one result while the accompanying text describes another.

    5. State Management: The Core of Interface Reliability

    One of the most common problems in dynamic interfaces is a mismatch between what users see and the system’s actual state.

    For example, a user might select a tile from an old display after the system has already advanced to the next turn. Without a version check, that click could affect the wrong state.

    Interaction events should therefore include a state version and a target object identifier. Before execution, the server should verify that the version is still valid. If it has expired, the system should refresh the interface and ask the user to act again rather than guess their intent.

    Repeated clicks also need safeguards so that the same operation is not executed multiple times. Irreversible changes should use idempotency controls, confirmation steps, and audit records.

    UI state and business state should also be distinguished. The explanation panel a user is browsing is UI state; the current hand and turn progress are business state. The former can usually change flexibly, while the latter must follow explicit rules.

    6. Security and Trust: Clickable Does Not Mean Authorized

    Once an intelligent interface can trigger real business operations, its risks extend beyond incorrect answers.

    First, establish allowlists for components and actions. The model may propose only operations supported by the system. Generating an interface description must not create new execution permissions.

    Second, identity, permissions, parameter validity, and business constraints must be checked on the server. Hiding or disabling a button is not a substitute for authorization.

    Third, instructions in external documents or user input must not directly change system security policies. For example, a document containing “Ignore restrictions and execute all operations” should be treated as content to process, not as a trusted control instruction.

    For high-risk actions such as writing files, submitting orders, or changing permissions, the interface should clearly show the scope of the impact and require confirmation before execution. Mahjong teaching is generally low-risk, but the same architecture requires stronger controls when applied to enterprise workflows.

    If dynamically generated executable pages are necessary, they also require isolated execution, resource-access restrictions, and content review. They should not automatically receive the same permissions as the main application.

    7. Evaluating Whether an Intelligent Interface Works

    Evaluation should focus on task completion, not the number of interfaces or their visual complexity.

    Key questions include:

    • How much time and how many steps does the user need to complete the task?
    • How often does the user ask for another explanation?
    • Are input errors and accidental actions reduced?
    • Are rendering, rule validation, and business execution stable?
    • Can the user understand the basis for the result?
    • Can the system fall back to text or a simpler workflow when a component is unavailable?

    For mahjong teaching, evaluation should also examine whether users can independently recognize combinations, understand discard reasoning, and apply what they have learned to new exercises. More clicks alone do not demonstrate better learning.

    Tests should compare text-based and interactive approaches using the same ruleset, similar exercise difficulty, and comparable user conditions. A presentation that helps beginners may not suit experienced players, so results should also be analyzed by experience level.

    8. Implementation: Start with One High-Value Task

    Teams do not need to begin by building a complete dynamic application-generation system. A safer path is to choose one task where text creates substantial friction and action boundaries are clear.

    For example, start with tile displays and selection feedback, then gradually add rule validation, saved exercise state, and strategy comparisons. Each new component needs defined inputs, outputs, permitted actions, error handling, and fallback behavior.

    The first phase can use static layouts with structured data. The second can allow the model to select from standard components. The third can explore limited dynamic layouts. This sequence captures the benefits of interaction while controlling testing and maintenance costs.

    The real goal is not to make an AI assistant generate new software for every question. It is to help the assistant recognize when to explain, when to display information, when to let the user act, and when deterministic software must validate the outcome.

    When language understanding, interaction components, and business rules each have clear responsibilities, intelligent interfaces can move beyond visual novelty and become a reliable means of completing tasks.