Bringing Desktop Mascots to Life: Applying Double
Pendulum Physics to AI Emotional Systems
by Nutty (Tinkerberry)
日本語版 / Japanese Version
デスクトップマスコットに「感情」を与える:二重振り子物理モデルのAI応用
はじめに
デスクトップマスコットアプリを開発する中で、「どうすればキャラクターが本当に
生きているように感じられるか」という問いに向き合い続けてきた。大規模な言語モデルを使わずに、軽量なLSTMモデルとアニメーションの組み合わせだけでキャラクターに個性と感情を持たせることはできるのか。
その答えとして辿り着いたのが、二重振り子の物理モデルを感情状態エンジンとして
応用するというアプローチである。
二重振り子とは
二重振り子(Double Pendulum)とは、振り子の先にさらに振り子を接続した構造を
持つ力学系である。単純な振り子が規則正しい周期運動を示すのとは対照的に、二重振り子はカオス的な運動を示す。
初期条件がわずかに異なるだけで、その後の運動が全く予測不能な形に分岐する。
この「敏感な初期条件依存性」こそがバタフライ効果として知られる現象であり、二重振り子の本質的な特徴である。
数学的には、ラグランジュ力学によって以下のように記述される:
α1 = (M2 * L1 * ω1² * sin(Δ) * cos(Δ) + M2 * G * sin(θ2) * cos(Δ)
- M2 * L2 * ω2² * sin(Δ) - (M1+M2) * G * sin(θ1)) / den1
α2 = (-M2 * L2 * ω2² * sin(Δ) * cos(Δ) - (M1+M2) * (G * sin(θ1) * cos(Δ) - L1 * ω1² * sin(Δ)- G * sin(θ2))) / den2
ここで θ1, θ2 は各振り子の角度、ω1, ω2 は角速度、M1, M2 は質量、L1, L2 は長さ、G は重力加速度を表す。
AIマスコットへの応用
この物理モデルをAIマスコットの感情システムに応用した。基本的な考え方は以下の通りである。
第一振り子 = キャラクターの基本性格(固定)
キャラクターが持つ不変の性格パラメータを第一振り子の物理定数にマッピングする。
例えばJelloというゼリーキャラクターの場合:
恥ずかしがりや度 (shyness) → 振り子2の質量(軽いほど揺れやすい)
甘さ (sweetness) → 重力の強さ(優しいほど揺れがゆっくり)
ふにゃふにゃ度 (wobbliness) → 減衰係数(大きいほど揺れが続く)
const G const M2 = 9.8 * (1.2 - personality.sweetness * 0.5)
= 0.4 + (1.0 - personality.shyness) * 0.6
const DAMP = 0.9985 + personality.wobbliness * 0.001
第二振り子 = キャラクターの現在の感情状態(変動)
会話や時間の経過によって振り子に「力を加える」ことで、感情状態が変化する。
function pokePendulum(strength) {
pendulum.state.omega2 += (Math.random() - 0.3) * strength
pendulum.state.omega1 += (Math.random() - 0.5) * strength * 0.4
}
振り子の物理状態は毎フレーム更新され、その結果を感情値にマッピングする:
const energy = Math.abs(omega1) + Math.abs(omega2)
state.mood = clamp01(0.5 + Math.sin(theta2) * 0.5)
state.excitement = clamp01(excitement * 0.98 + Math.min(energy / 6.0, 1.0) * 0.02)
state.nervousness = clamp01(nervousness * 0.97 + Math.min(Math.abs(omega2) / 4.0, 1.0) * 0.03
感情状態の応用導出された感情値はキャラクターの様々な振る舞いに影響を与える。
アニメーション速度
const interval = 350 - state.nervousness * 230
緊張度が高いほどアニメーションが速くなる。
揺れの振幅
const amp = (wobbliness * 4) + (nervousness * 8) + (excitement * 3)
const angle = Math.sin(wobblePhase) * amp
興奮・緊張するほど体が大きく揺れる。
音声のピッチと速度
utterance.pitch = 1.0 + state.excitement * 0.5
utterance.rate = 0.9 + state.excitement * 0.4
興奮しているほど声が高く速くなる。
LSTMの出力ランダム性(temperature)
const temperature = 0.7 + state.nervousness * 0.4
緊張度が高いほど返答が予測不能になる。
三重振り子への拡張:Dreamer
さらにDreamerというキャラクターでは三重振り子システムを実装した。
第一振り子:基本性格(穏やかさ、好奇心、感受性)
第二振り子:現在の感情(気分、眠気、不思議な感覚)
第三振り子:夢の深さ・無意識の状態
一定時間操作がないと眠りモードに移行し、夢の断片を独り言として呟く。その内容は
dream_diary.jsonに記録され、「dream」と話しかけると過去の夢を語るという機能を持つ。
実装結果と考察この手法の利点として以下が挙げられる:
- 軽量性: カオス的な物理計算は計算コストが低く、非力なPCでも動作する
- 軽量性: カオス的な物理計算は計算コストが低く、非力なPCでも動作する
- 自然な予測不能性: 毎回異なる感情の流れが生まれ、キャラクターが生きているように感じられる
- 自然な予測不能性: 毎回異なる感情の流れが生まれ、キャラクターが生きているように感じられる
- 個性の数値化: 性格パラメータを物理定数にマッピングすることで、異なるキャラクターの個性を明確に区別できる
- 記憶との連携: memoriesフォルダに感情状態を保存することで、次回起動時も感情の継続性が保たれる
重要な知見として、「生き生きさ」の大部分は言語的な賢さではなく
アニメーション・状態・タイミングから生まれるという点が挙げられる。小型のLSTMモデルであっても、感情システムと組み合わせることで豊かな個性を表現できる。
実装キャラクター一覧
キャラクター ---振り子--- 特徴
Ken--- 二重--- 興奮すると笑い転げる森の少年
WalkingClock--- 二重--- パニックになると高速で画面を横断する時計
Jello (jellol)--- 二重 ---緊張するとぷよぷよ揺れが大きくなるゼリー
Jello (jelol)--- 二重+物理計算 Fabちゃん(Claude Fable 5)の物理式を採用
Dreamer--- 三重--- 放置で眠り夢を記録する子猫
おわりに
二重振り子の「カオス性」は、一見するとランダムに見えながらも物理法則に
従った自然な揺らぎを生み出す。この性質がAIマスコットの感情表現と
非常に相性が良いことが実装を通じて確認できた。
大規模モデルに頼らず、物理・アニメーション・軽量AIの三つを組み合わせることで、
デスクトップ上に「生きている」キャラクターを実現することができる。
English VersionBringing Desktop Mascots to Life: Applying Double Pendulum Physics to AI
Emotional Systems
Introduction
While developing desktop mascot applications, I kept returning to one question: how can a character feel genuinely alive?
Is it possible to give personality and emotional depth to a character using only lightweight LSTM models and animation, without relying on large language models?
The answer I arrived at was applying the double pendulum physical model as an emotional state engine.
What Is a Double Pendulum?
A double pendulum is a mechanical system consisting of a pendulum with another pendulum attached to its end. Unlike a simple pendulum, which follows regular periodic motion, a double pendulum exhibits chaotic behavior.
Even a tiny difference in initial conditions leads to completely unpredictable divergence in subsequent motion.
This “sensitive dependence on initial conditions” is the essence of the
butterfly effect, and the defining characteristic of the double pendulum.
Application to AI Mascots
Pendulum 1 = Fixed personality (character’s core traits)
The character’s unchanging personality parameters are mapped to the physical constants of the first pendulum.
For Jello, a jelly character:
Shyness → mass of pendulum 2 (lighter = more easily disturbed)
Sweetness → gravitational strength (gentler gravity = softer swings)
Wobbliness → damping coefficient (less damping = keeps wobbling longer)
Pendulum 2 = Current emotional state (variable)
Conversation and the passage of time “poke” the pendulum, changing the emotional state.The physics update every frame, and the resulting state is mapped to emotional values:mood, excitement, and nervousness.
Applications of Emotional State
The derived emotional values influence the character’s behavior in multiple ways:
Animation speed: Higher nervousness = faster animation frames
Wobble amplitude: More excitement/nervousness = larger body movement
Voice pitch and rate: More excited = higher pitch, faster speech
LSTM temperature: Higher nervousness = more unpredictable responses
Extension to Triple Pendulum: Dreamer
For the character Dreamer, a triple pendulum system was implemented:
Pendulum 1: Core personality (calmness, curiosity, sensitivity)
Pendulum 2: Current emotions (mood, drowsiness, sense of wonder)
Pendulum 3: Dream depth / subconscious state
After a period of inactivity, Dreamer enters sleep mode
and murmurs dream fragments as monologue. These are recorded in a dream_diary.json file, and when the user types “dream,”
the character recalls and shares past dreams.
Results and Discussion
Key advantages of this approach:
-
Lightweight: Chaotic physics calculations have low computational cost
-
Natural unpredictability: Different emotional flows emerge each time, making the character feel alive
-
Quantified personality: Mapping personality to physical constants clearly differentiates characters
-
Memory integration: Saving emotional state to a memories folder preserves continuity across sessions
A key insight: most of the sense of “aliveness” comes from animation, state, and timing
rather than linguistic intelligence. Even small LSTM models can express rich personality
when combined with an emotional system.
Implemented Chracters
Character-----Pendulum----- Features
Ken---------Double------Forest boy who laugh around when excited
WalkingColck------Double-----Clock that races across the screen in panic
Jello (jellol)-----Double-----Jelly whose wobble grows with nervousness
Jello (jelol)-----Double-----Physics uses full physics equations
Dreamer-----Triple-----Kitten who sleeps and records dreams
Conclusion
The “chaos” of the double pendulum produces natural,
unpredictable variation that follows physical laws.
Through implementation, I confirmed that this property pairs
exceptionally well with emotional expression in AI mascots.
By combining physics, animation, and lightweight AI — without relying on large models — it is possible to bring characters that feel genuinely alive to the desktop.