docs: design, plan, and the execution record
The thinking behind the organism, versioned alongside the three code repos rather than living only on one machine. - AILED_General_Specification.md, the authoritative design, and the implementation plan the code was built from - AGENTS.md, the project-wide rules, including the two that were learned the hard way: this is not a performance benchmark, and a null recorded early beats a claim propped up later - the nine superseded module specs, each carrying a banner naming what replaced it - .sdd/, the execution ledger and every task brief and report: each ruling taken, what it would cost if wrong, every correction, and every number verified independently The three code repos are siblings, each its own repository, and are git-ignored here so nothing is nested. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KAWnnPg2qvmLNySamE2k85
This commit is contained in:
47 files changed
+7498
No files matched your search
@@ -0,0 +1,144 @@
|
||||
# Reflexes & Instinct: The Dual-Process Decision Engine
|
||||
> **Superseded (2026-09-01):** reduced to two rows of §6 of the general spec. The policy side lives in the ailed-chess EQ chain. See `AILED_General_Specification.md`.
|
||||
|
||||
## Technical Specification for Cognitive Control and Survival
|
||||
|
||||
**Project Context:** AILED Organism
|
||||
**Module Type:** Decision Logic / Behavioral Controller
|
||||
**Mathematical Focus:** Threshold-based triggering and Multi-objective Utility Optimization.
|
||||
|
||||
---
|
||||
|
||||
## 1. Concept Overview: The Dual-Process Theory
|
||||
|
||||
To move from a mere "calculator" to a "living agent", the organism must implement two distinct modes of existence, inspired by Kahneman's Dual Process Theory:
|
||||
|
||||
1. **System 1 (S1) - Intuition:** Fast, automatic, and pattern-based. This is the direct output of the **Relational Perceptron (RP)**. It is cheap and efficient but prone to "intuitive errors" under pressure.
|
||||
2. **System 2 (S2) - Deliberation:** Slow, analytical, and corrective. It is a "safety check" that activates only when the environment becomes critical.
|
||||
|
||||
The bridge between these two is the **Instinct**, which modulates the agent's priorities between "Advancement" (Winning) and "Homeostasis" (Survival).
|
||||
|
||||
---
|
||||
|
||||
## 2. Mathematical Formalism
|
||||
|
||||
### 2.1. Reflex Triggering (S1 vs S2)
|
||||
|
||||
The agent does not run S2 for every move (to save "metabolic energy"). Instead, it uses a threshold-based trigger. S2 is activated if the internal state is unstable or if the environment undergoes a shock.
|
||||
|
||||
$$\text{Trigger} = \begin{cases} \text{S2 (Verification)} & \text{if } (\psi < \theta_{\text{panic}}) \lor (\Delta \text{Tension} > \theta_{\text{shock}}) \\ \text{S1 (Intuition)} & \text{otherwise} \end{cases}$$
|
||||
|
||||
Where:
|
||||
- $\theta_{\text{panic}}$: Threshold for psychological collapse.
|
||||
- $\theta_{\text{shock}}$: Threshold for sudden environmental change (e.g., a check or sudden loss of material).
|
||||
- $\Delta \text{Tension}$: The rate of change in the board's tension.
|
||||
|
||||
### 2.2. Instinct: The Homeostatic Utility Function
|
||||
|
||||
The "Instinct" is implemented as a biased selection process. Instead of maximizing the raw evaluation $Q(a)$, the agent maximizes a **Biased Utility** $U(a)$ that balances ambition with survival.
|
||||
|
||||
$$U(a) = [1 - \alpha(\psi)] \cdot \text{Eval}(a) + \alpha(\psi) \cdot \text{Stability}(a, \psi)$$
|
||||
|
||||
Where:
|
||||
- $\text{Eval}(a)$: The raw quality/advantage of move $a$.
|
||||
- $\text{Stability}(a, \psi)$: A metric of how much move $a$ stabilizes the current $\psi$ (e.g., retreating the king, solidifying the center).
|
||||
- $\alpha(\psi)$: The **Fear Factor**. A non-linear function that maps the Psyche to a weight:
|
||||
$$\alpha(\psi) = \text{clamp}\left( \frac{100 - \psi}{200}, 0, 1 \right)$$
|
||||
|
||||
**Behavioral Outcomes:**
|
||||
- **$\psi \to +100$ (Confidence):** $\alpha \to 0$. The agent is purely ambitious, seeking maximum advantage.
|
||||
- **$\psi \to -100$ (Panic):** $\alpha \to 1$. The agent is purely survivalist, seeking moves that stabilize the state, even if they lose material.
|
||||
|
||||
---
|
||||
|
||||
## 3. Comparison with Standard Engines
|
||||
|
||||
| Feature | Standard Engine (Stockfish) | AILED Organism |
|
||||
| :--- | :--- | :--- |
|
||||
| **Decision Goal** | Maximize $V(s)$ (Mathematical Value). | Maximize $U(a)$ (Stability + Ambition). |
|
||||
| **Resource Usage** | Constant (Fixed depth/time). | Variable (S1 vs S2 complexity). |
|
||||
| **Error Profile** | Calculation error (Hard errors). | Cognitive/Emotional error (Soft errors). |
|
||||
| **Adaptability** | Static strategy. | Dynamic strategy (Aggressive vs. Survivalist). |
|
||||
|
||||
---
|
||||
|
||||
## 4. Minimal Implementation (Python + NumPy)
|
||||
|
||||
This implementation shows how the `MoveSelector` uses $\psi$ to balance ambition and stability.
|
||||
|
||||
```python
|
||||
import numpy as np
|
||||
|
||||
class InstinctiveMoveSelector:
|
||||
"""
|
||||
Implements the Instinct-driven decision making using
|
||||
the biased Utility function.
|
||||
"""
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def _calculate_stability(self, move_idx: int, board_state: dict) -> float:
|
||||
"""
|
||||
Simulates a stability metric.
|
||||
In reality, this checks if a move reduces tension.
|
||||
"""
|
||||
# Dummy stability scores for demo
|
||||
# 1.0 is very stable, -1.0 is very risky
|
||||
return np.random.uniform(-0.5, 1.0)
|
||||
|
||||
def select_move(self, logits: np.ndarray, eval_scores: np.ndarray,
|
||||
psyche: float, board_state: dict) -> int:
|
||||
"""
|
||||
Selects a move by maximizing the biased Utility U(a).
|
||||
"""
|
||||
num_moves = len(logits)
|
||||
|
||||
# 1. Calculate Fear Factor alpha(psi)
|
||||
# psi: [-100, 100] -> alpha: [1, 0]
|
||||
alpha = (100.0 - psyche) / 200.0
|
||||
alpha = np.clip(alpha, 0.0, 1.0)
|
||||
|
||||
# 2. Calculate Stability for each move
|
||||
stability_scores = np.array([self._calculate_stability(i, board_state)
|
||||
for i in range(num_moves)])
|
||||
|
||||
# 3. Compute Utility U(a)
|
||||
# U(a) = (1-alpha)*Eval(a) + alpha*Stability(a)
|
||||
utility = (1.0 - alpha) * eval_scores + alpha * stability_scores
|
||||
|
||||
# 4. Apply Softmax to Utility (to allow for probabilistic selection)
|
||||
# We use utility as the logit base
|
||||
probs = np.exp(utility) / np.sum(np.exp(utility))
|
||||
|
||||
# 5. Select move
|
||||
return np.random.choice(num_moves, p=probs)
|
||||
|
||||
# --- DEMO ---
|
||||
if __name__ == "__main__":
|
||||
selector = InstinctiveMoveSelector()
|
||||
|
||||
# 3 possible moves
|
||||
# move_evals: [Move 0: Aggressive/Risky, Move 1: Balanced, Move 2: Defensive/Safe]
|
||||
move_evals = np.array([0.9, 0.4, -0.2])
|
||||
|
||||
# Case A: High Psyche (The Engine is confident/ambitious)
|
||||
print("--- Scenario: HIGH PSYCHE (Confidence) ---")
|
||||
for _ in range(5):
|
||||
move = selector.select_move(None, move_evals, psyche=80.0, board_state={})
|
||||
print(f"Selected Move: {move} (Targeting high Eval)")
|
||||
|
||||
# Case B: Low Psyche (The Engine is in panic/survival mode)
|
||||
print("\n--- Scenario: LOW PSYCHE (Panic/Survival) ---")
|
||||
for _ in range(5):
|
||||
move = selector.select_move(None, move_evals, psyche=-80.0, board_state={})
|
||||
print(f"Selected Move: {move} (Targeting high Stability)")
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. Implementation Roadmap
|
||||
|
||||
1. **Integrating S2:** Implement a callback that triggers a deeper search (or a second-pass filter) when $\psi$ drops below a threshold.
|
||||
2. **Stability Metric:** Develop a heuristic that quanterizes "stability" (e.g., reduction in piece contact, king safety delta).
|
||||
3. **$\alpha$-Sensitivity Tuning:** Fine-tune the non-linearity of $\alpha(\psi)$ to ensure the transition from "Aggressor" to "Defender" feels natural and not robotic.
|
||||
```
|
||||
Reference in new issue
Block a user