2026年2月22日日曜日

Atron Script -1-

 Atron Scriptとか作っちゃう。

なにかというとね、アソシアトロンって
アルゴリズムじゃないのさ、
(笑)


普通は
入力
→ 手順(アルゴリズム)
→ 出力

決められた答えを出す機械って感じっしょ?

でもアソシアトロンってのは

状態が変わる
経験が蓄積する
同じ入力でも反応が変わる
個体ごとに違う
世の中のAIの動きと真逆の方向に進んでいるからね、うちはw

計算結果を出すシステムではなく、状態が変わる存在だから
この前turboCやってて思ったんだけど、アルゴリズムを前提にすると
頭の中がおかしな方向に行っちゃうのよ。

で、プログラム言語なんて大そうなものは作れないから(マジ誰か考えて)
超ミニスクリプトを考えちゃおう!ということよ。

神経回路
生物
学習システム
アソシアトロン

手順よりも、更新ルールが大事なのさ。
attractor、competition、reinforcement、decay
数学的にいうと動力学系とか最適化とか、なんだ?確率過程の世界で、
目的→手順つーか、状態の空間を設計しなきゃいけないんですよ。

Transformerだってアルゴリズムじゃないじゃん。
重み空間の中の状態変換だから、、、
うちのは、もっと生物にちかい、そう、なまもの。
100年前のベル研の人ってそういう感じだったじゃん。
中野博士はご健在じゃないし、森田先生だって俺なんか相手にするわけないし
聞くが人居ない。


ということで自分なりに設計として使用してみる。


AtronScript v1 (2026.2.23生まれだ)

10ブロック:

  1. scene(出来事単位)

  2. actors(登場者)

  3. roles(人×案件=立場)

  4. cues(外界入力)

  5. outer(外輪ルール)

  6. inner(内輪経験)

  7. memory(記憶ノード+memory weight)★

  8. competition(競合・勝者選択)★

  9. attractor(安定点・収束条件)★

  10. policy(行動とAuto強弱=personality)★

learn は v1では memory の更新規則に吸収します(散らさないため)。


少な!


文法の雰囲気(とりあえずこんな・・)

  • 1つの scene が 1つのエピソード(案件)

  • roles が「人の次元」と「案件の次元」を繋ぐ“関係テーブル”

  • memory重み を持つ(ここが核)

  • competition意味の取り合い

  • attractor落ち着き先(収束)

  • policy実行(+Autoの性格)





「ライオンで “A = 危険” が育つ」みたいな・・・

-----Script(YAML)-------- lion_v1.yaml ----------


scene LionEncounter_v1 actors: r1 r2 roles: r1 = witness r2 = companion cues: vision: lion sound: shout distance: near outer: rule danger_if vision==lion rule avoid_if danger==true inner: pain += 3 when distance==near and vision==lion arousal += 2 when sound==shout memory: # ノード(概念や属性)と、その結合重み node A node danger node flee link (lion -> A) weight 0.20 link (A -> danger) weight 0.10 link (danger -> flee) weight 0.60 # 重み更新 update: hebb: +0.05 when coactive decay: -0.01 per scene clamp: [0.00, 1.00] competition: # cuesから候補を立て、競合させる candidates: - A from lion via (lion->A) - danger from A via (A->danger) - flee from danger via (danger->flee) rule: score = sum(weighted_support) + inner.arousal*0.05 - inner.pain*0.00 winner take_top 1 inhibit losers by 0.15 attractor: # 収束:同じ結合が一定以上・一定回数で安定化 condition: stable_if (A->danger) >= 0.80 for 5 scenes effect: lock (A->danger) softness 0.10 # 完全固定じゃなく少し揺らぎOK policy: # 行動 if winner==flee then act flee # personality(Auto強弱) personality: auto_send: 0.70 # 外に送る(ログ/LLM/親)しきい値 auto_learn: 0.85 # 学習を強くするしきい値 caution: 0.60 # 危険寄りの性格(逃げやすい)







---------Python------ run_assoc_v1.py ----------------------


from __future__ import annotations import math from dataclasses import dataclass from typing import Dict, Tuple, Any, List import yaml # pip install pyyaml LinkKey = Tuple[str, str] @dataclass class Runtime: inner: Dict[str, float] outer: Dict[str, Any] winner: str | None stable_counter: int def match_when(cues: Dict[str, Any], when: Dict[str, Any]) -> bool: """All key-value pairs in 'when' must match cues exactly (tiny v1).""" for k, v in when.items(): if cues.get(k) != v: return False return True def clamp(x: float, lo: float, hi: float) -> float: return max(lo, min(hi, x)) def build_memory(script: Dict[str, Any]) -> Dict[LinkKey, float]: mem = {} for lk in script["memory"]["links"]: mem[(str(lk["from"]), str(lk["to"]))] = float(lk["weight"]) return mem def apply_outer(cues: Dict[str, Any], outer_spec: Dict[str, Any]) -> Dict[str, Any]: """Compute a minimal 'danger' boolean from rules.""" rule = outer_spec.get("rule", {}) danger_if = rule.get("danger_if", {}) danger = all(cues.get(k) == v for k, v in danger_if.items()) # avoid_if not used directly here; policy uses winner==flee return {"danger": bool(danger)} def apply_inner(cues: Dict[str, Any], inner_spec: Dict[str, Any], inner: Dict[str, float]) -> None: """Add pain/arousal if conditions match.""" for name, spec in inner_spec.items(): add = float(spec.get("add", 0.0)) when = spec.get("when", {}) if match_when(cues, when): inner[name] = inner.get(name, 0.0) + add def decay_memory(mem: Dict[LinkKey, float], decay: float, lo: float, hi: float) -> None: for k in list(mem.keys()): mem[k] = clamp(mem[k] - decay, lo, hi) def hebb_update(mem: Dict[LinkKey, float], active: List[str], hebb: float, lo: float, hi: float) -> None: """ Tiny Hebb: if a->b is in memory and both a and b are active in this scene, strengthen it. We'll consider 'lion' always active when vision==lion; plus any winners/derived nodes. """ aset = set(active) for (a, b), w in list(mem.items()): if a in aset and b in aset: mem[(a, b)] = clamp(w + hebb, lo, hi) def competition(script: Dict[str, Any], cues: Dict[str, Any], rt: Runtime, mem: Dict[LinkKey, float]) -> str | None: """ Minimal candidate propagation: - if vision==lion: lion active - if (lion->A) exists: candidate A with score weight - if (A->danger): candidate danger with score chained weight - if (danger->flee): candidate flee with score chained weight Apply small personality bias (caution) to danger/flee. """ candidates: Dict[str, float] = {} active_base = [] if cues.get("vision") == "lion": active_base.append("lion") # 1-hop for (a, b), w in mem.items(): if a in active_base: candidates[b] = max(candidates.get(b, 0.0), w) # chain A -> danger if "A" in candidates and ("A", "danger") in mem: candidates["danger"] = max(candidates.get("danger", 0.0), candidates["A"] * mem[("A", "danger")]) # chain danger -> flee if "danger" in candidates and ("danger", "flee") in mem: candidates["flee"] = max(candidates.get("flee", 0.0), candidates["danger"] * mem[("danger", "flee")]) # inner contribution (arousal raises overall readiness a bit) arousal = rt.inner.get("arousal", 0.0) for k in list(candidates.keys()): candidates[k] += arousal * 0.01 # personality caution biases danger/flee up caution = float(script.get("personality", {}).get("caution", 0.0)) if "danger" in candidates: candidates["danger"] += caution * 0.05 if "flee" in candidates: candidates["flee"] += caution * 0.08 if not candidates: return None # winner take top-N (here N=1) winner = max(candidates.items(), key=lambda kv: kv[1])[0] # inhibit losers (toy: just reduce their scores next time is not modeled; skip) return winner def step(script: Dict[str, Any], mem: Dict[LinkKey, float], rt: Runtime) -> None: cues = dict(script.get("cues", {})) # OUTER + INNER rt.outer = apply_outer(cues, script.get("outer", {})) apply_inner(cues, script.get("inner", {}), rt.inner) # MEMORY UPDATE (decay + hebb using active set) upd = script["memory"]["update"] hebb = float(upd.get("hebb", 0.0)) decay = float(upd.get("decay", 0.0)) lo, hi = map(float, upd.get("clamp", [0.0, 1.0])) decay_memory(mem, decay, lo, hi) # COMPETITION rt.winner = competition(script, cues, rt, mem) # active set for hebb active = [] if cues.get("vision") == "lion": active.append("lion") if rt.winner: active.append(rt.winner) # also include implied nodes if present if ("lion", "A") in mem: active.append("A") if ("A", "danger") in mem: active.append("danger") # stronger learning when auto_learn high (toy multiplier) auto_learn = float(script.get("personality", {}).get("auto_learn", 0.5)) hebb_eff = hebb * (1.0 + max(0.0, auto_learn - 0.5)) # 0.5→1.0 range hebb_update(mem, active, hebb_eff, lo, hi) # ATTRACTOR check: (A->danger) >= ge for N scenes st = script.get("attractor", {}).get("stable_if", {}) (a, b) = st.get("link", ["A", "danger"]) ge = float(st.get("ge", 0.8)) for_scenes = int(st.get("for_scenes", 5)) w = mem.get((a, b), 0.0) if w >= ge: rt.stable_counter += 1 else: rt.stable_counter = 0 locked = rt.stable_counter >= for_scenes # POLICY pol = script.get("policy", {}) if rt.winner == pol.get("if_winner_is"): act = pol.get("act", "none") else: act = "none" print(f"winner={rt.winner:>6} act={act:>4} pain={rt.inner.get('pain',0):.1f} arousal={rt.inner.get('arousal',0):.1f} w(A->danger)={w:.2f} stable={rt.stable_counter}/{for_scenes} locked={locked}") def main(): import argparse ap = argparse.ArgumentParser() ap.add_argument("yaml_path", help="Associatron Script v1 YAML path") ap.add_argument("--scenes", type=int, default=20) args = ap.parse_args() with open(args.yaml_path, "r", encoding="utf-8") as f: script = yaml.safe_load(f) mem = build_memory(script) rt = Runtime(inner={}, outer={}, winner=None, stable_counter=0) print(f"=== Scene: {script.get('scene','(unnamed)')} ===") for i in range(args.scenes): print(f"[{i+1:02d}]", end=" ") step(script, mem, rt) if __name__ == "__main__": main()



---------------------------------
Script(YAML)を書く
PythonでYAMLを読み込む

cues → outer → inner → memory update → competition → attractor → policy の順に1ステップ回す

それを「シーン回数ぶん」繰り返す(経験の反復=学習)


独自のYAML(AtronScript)を書くことで迷子にならなくて済むということ。
料理で言えばレシピみたいなもの。
Pythonは料理人の動きとか、脳の力学、火加減、経験、知識


cues

competition(どれが勝つか)

activeノード決定

Hebb強化

Decay忘却

Clamp


Associatron的に見ると

Hebb → 経験
Decay → 忘却
Competition → 意味の選択
Attractor → 習慣・性格

つまり、Python = 心の物理法則

Hebbだけでは収束が弱いので
実際には競争した勝者を強化するような感じになる。





0 件のコメント:

コメントを投稿

outlawだってさ。ありがとよ。 - Associatronと一人称自律

 オランダからメールが来たよ。 「Atraもいいけど、outlawだろ、」ってさ 最高だよ。 outlaw architecture ってのは間違いないよねw 実際、僕は、流れや制度・分類・学派・評価体系の外にいる者だし、そういうのあまり大切にしていない。今の大学の事は分からない...