BAHAMA Insight v13.5 | 職人の「注ぎ」をAIが学習する、次世代ビール計算機
「理論値通りに注いでいるのに、なぜか泡が安定しない……」
そんな現場のジレンマを解消するために生まれた、マルコフ過程やベイズ定理、ポアズイユの法則 カルマンフィルタ、モンテカルロ法などを織り込んだプロ注ぎ手のための適応型計算アプリです。注ぐたびに学習ボタンを押すことで、世界に一つだけの自分のタップ専用AIが育ちます。
1. 「答え一発」を超えた、現場適応型ロジック
従来の計算機は、物理定数に基づいた「固定の正解」しか出しません。しかし、ビールの状態は樽の個体差、設備の劣化、そして注ぎ手の技術によって刻々と変化します。
BAHAMA Insightは、カルマンフィルターを用いたAI学習機能を搭載。現場での「注ぎの結果」をボタン一つでフィードバックすることで、あなた専用の機材環境に合わせた「真の推奨値」へと自動調整されます。
2. 「泡」を科学的に仕分ける教育機能
単に「泡が多い」という現象を、AIが二つの側面から分析します。
物理的衝突(暴れる): 勢いが強すぎる抵抗不足。AIは「ホースを長く」と判断。
化学的分離(分離する): ホース内でのガス湧き。AIは「流速を上げ滞留を防ぐ(ホースを短く)」と判断。
この仕分けにより、単なる長さ調整ではない、本質的なトラブルシューティングを可能にします。
3. プロの視点をテレメトリ化
[MC] 成功確率: モンテカルロ法により、現在の設定での成功率をシミュレーション。
[HMM] 流体状態: 隠れマルコフモデルを用い、ホース内が「安定層流」か「ガス抜け」かをリアルタイム推論。
ARビジョン機能: 📷カメラを起動し、計器や現場の風景に画面を重ねて操作可能。
4. 「樽残量 (Barrel Level)」の導入:
樽が満タンのときは、ビールの自重(液位圧)により、実際にはガス圧以上の圧力がかかっています。これが空に近づくと圧がわずかに下がる現象をシミュレートし、微細な流速変化を補正します。
※残杯数予測の容量は1杯380cc計算です。
【開発者 Ejiri より】
「既存の計算機は、物理学を語るが『現場』を語らない。このアプリは、僕らがカウンターで感じる『なんか違うな』という違和感を学習し、最高の1杯を導き出すための『相棒』です。ビールを愛するすべての注ぎ手に、この進化を届けます。
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>BAHAMA Insight v13.6 | 樽残量管理統合版</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
:root { --accent: #00d4ff; --gold: #d4a017; --bg: #0f172a; --card: rgba(30, 41, 59, 0.9); --text: #f8fafc; }
body { font-family: 'Hiragino Kaku Gothic ProN', sans-serif; background: var(--bg); color: var(--text); margin: 0; padding: 0; }
#video-bg { position: fixed; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; z-index: -1; display: none; background: #000; }
.container { max-width: 480px; margin: auto; padding: 15px; display: flex; flex-direction: column; min-height: 100vh; }
.glass-card { background: var(--card); backdrop-filter: blur(15px); border-radius: 28px; padding: 20px; border: 1px solid rgba(255,255,255,0.1); flex: 1; }
header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.vision-toggle { background: var(--accent); border: none; padding: 8px 15px; border-radius: 20px; font-weight: bold; cursor: pointer; font-size: 0.7rem; }
.vision-toggle.active { background: #ff4757; color: #fff; }
.selector-label { font-size: 0.65rem; color: #94a3b8; margin: 8px 0 4px 5px; display: block; }
.selector-group { display: flex; gap: 6px; margin-bottom: 12px; }
.sel-btn { flex: 1; padding: 10px 5px; border: 1px solid #334155; background: rgba(0,0,0,0.3); color: #94a3b8; border-radius: 12px; cursor: pointer; font-size: 0.7rem; font-weight: bold; }
.sel-btn.active { background: var(--accent); color: #000; border-color: var(--accent); }
.param-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 15px; }
.param-group { background: rgba(0,0,0,0.4); padding: 10px; border-radius: 16px; border: 1px solid rgba(255,255,255,0.05); }
label { display: block; font-size: 0.6rem; color: #94a3b8; margin-bottom: 4px; }
.val-disp { font-weight: bold; color: var(--gold); font-family: monospace; font-size: 1rem; }
input[type="range"] { width: 100%; accent-color: var(--gold); cursor: pointer; }
.inference-box { text-align: center; border: 2px solid var(--gold); background: rgba(212, 160, 23, 0.15); padding: 15px; border-radius: 20px 20px 0 0; border-bottom: none; }
.rec-val { font-size: 3.5rem; font-weight: bold; color: var(--gold); }
.telemetry { background: #000; padding: 12px; border-radius: 0 0 20px 20px; border: 2px solid var(--gold); border-top: 1px dashed var(--gold); font-family: monospace; font-size: 0.6rem; color: #4ade80; margin-bottom: 15px; }
.tel-row { display: flex; justify-content: space-between; margin-bottom: 3px; }
.keg-bar-container { width: 100%; height: 6px; background: #334155; border-radius: 3px; margin-top: 8px; overflow: hidden; }
#kegBar { height: 100%; background: var(--gold); width: 100%; transition: 0.3s; }
.feedback-label { font-size: 0.6rem; color: var(--gold); text-align: center; margin-bottom: 5px; font-weight: bold; letter-spacing: 1px; }
.feedback-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 15px; }
.fb-btn { border: none; padding: 10px; border-radius: 12px; color: #fff; font-weight: bold; font-size: 0.75rem; cursor: pointer; transition: 0.2s; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.2; text-align: center;}
.fb-btn small { font-size: 0.5rem; opacity: 0.8; font-weight: normal; margin-top: 2px; }
.how-to { background: rgba(255,255,255,0.05); padding: 15px; border-radius: 20px; font-size: 0.72rem; color: #cbd5e1; line-height: 1.5; margin-bottom: 10px; }
.how-to h3 { margin: 0 0 8px 0; font-size: 0.8rem; color: var(--accent); border-bottom: 1px solid var(--accent); display: inline-block; }
.how-to ol, .how-to ul { margin: 5px 0; padding-left: 15px; }
.how-to li { margin-bottom: 3px; }
.how-to b { color: var(--gold); }
footer { text-align: center; padding: 10px; font-size: 0.7rem; color: #64748b; letter-spacing: 4px; font-weight: bold; }
</style>
</head>
<body>
<video id="video-bg" autoplay playsinline></video>
<div class="container">
<div class="glass-card">
<header>
<button id="visionBtn" class="vision-toggle" onclick="toggleVision()">📷 ビジョン起動</button>
<h1 style="font-size:0.9rem; color:var(--gold); margin:0;">BAHAMA Insight v13.6</h1>
<div style="width:20px"></div>
</header>
<div class="how-to">
<h3>⚙️ 操作・セットアップ</h3>
<ol>
<li>機材環境と樽サイズ・残量をセット。</li>
<li>中央の<b>推奨ホース長</b>を確認。</li>
<li>テレメトリで<b>残りの杯数</b>を予測。</li>
<li>違和感を<b>学習ボタン</b>でAIに教える。</li>
</ol>
</div>
<span class="selector-label">▼ タップの選択</span>
<div class="selector-group">
<button id="t_swg" class="sel-btn active" onclick="setTap('swg')">スイングカラン<br>(低抵抗)</button>
<button id="t_std" class="sel-btn" onclick="setTap('std')">普通タップ<br>(高抵抗)</button>
</div>
<div class="param-grid">
<div class="param-group"><label>内径 <span class="val-disp" id="idDisp">9.0</span>mm</label><input type="range" id="innerDia" min="3" max="12" step="0.5" value="9" oninput="infer()"></div>
<div class="param-group"><label>液温 <span class="val-disp" id="tDisp">8.0</span>℃</label><input type="range" id="temp" min="0" max="25" step="0.5" value="8" oninput="infer()"></div>
<div class="param-group"><label>ガス圧 <span class="val-disp" id="pDisp">0.14</span>Mpa</label><input type="range" id="press" min="0.05" max="0.40" step="0.01" value="0.14" oninput="infer()"></div>
<div class="param-group"><label>巻径(Coil) <span class="val-disp" id="coilDisp">17</span>cm</label><input type="range" id="coil" min="5" max="100" step="1" value="17" oninput="infer()"></div>
<div class="param-group"><label>樽サイズ <span class="val-disp" id="kegSizeDisp">10</span>L</label><input type="range" id="kegSize" min="5" max="20" step="1" value="10" oninput="infer()"></div>
<div class="param-group"><label>残量 <span class="val-disp" id="remainDisp">100</span>%</label><input type="range" id="kegRemain" min="0" max="100" step="1" value="100" oninput="infer()"></div>
</div>
<div class="inference-box">
<div style="font-size: 0.6rem; color: var(--gold); font-weight: bold;">推奨ホース長</div>
<div class="rec-val"><span id="recLen">--</span><span style="font-size: 1.2rem; margin-left:5px;">m</span></div>
</div>
<div class="telemetry" id="telemetry">
<div class="tel-row"><span>[MC] 成功確率:</span> <span id="mcProb">--%</span></div>
<div class="tel-row"><span>[INV] 推定残り杯数:</span> <span id="poursDisp">-- 杯</span></div>
<div class="tel-row"><span>[KF] 推定抵抗定数:</span> <span id="kalmanGain">--</span></div>
<div class="keg-bar-container"><div id="kegBar"></div></div>
</div>
<div class="feedback-label">▼ 現場学習 / システムリセット</div>
<div class="feedback-grid">
<button class="fb-btn" style="background:#059669" onclick="update('good')">完璧<small>精度維持</small></button>
<button class="fb-btn" style="background:#d97706" onclick="update('turbulence')">暴れる<small>出口で衝突</small></button>
<button class="fb-btn" style="background:#7c3aed" onclick="update('separation')">分離する<small>ホース内泡</small></button>
<button class="fb-btn" style="background:#dc2626" onclick="update('flat')">気抜け<small>飲んだら気抜</small></button>
<button id="resetBtn" class="fb-btn" style="background:#475569; grid-column: span 2;" onmousedown="startReset()" onmouseup="stopReset()" onmouseleave="stopReset()" ontouchstart="startReset()" ontouchend="stopReset()">AI学習リセット<small>長押し2秒</small></button>
</div>
<div class="how-to">
<h3>📖 学習ロジック解説</h3>
<ul>
<li><b>暴れる:</b> 抵抗不足と学習し、<b>ホースを長く</b>算出。</li>
<li><b>分離する:</b> 滞留を防ぐため、<b>ホースを短く</b>算出。</li>
<li><b>シャバい:</b> 圧力バランスを補正。</li>
</ul>
</div>
<footer>©BAHAMA</footer>
</div>
</div>
<script>
const INITIAL_BASE = 0.00728;
let state = { vision: false, tap: 'swg', bias: 0.0, R_base: INITIAL_BASE, P_cov: 0.1 };
let resetTimer;
async function toggleVision() {
const v = document.getElementById('video-bg');
const b = document.getElementById('visionBtn');
if (!state.vision) {
try { const s = await navigator.mediaDevices.getUserMedia({ video: { facingMode: 'environment' } });
v.srcObject = s; v.style.display = 'block'; b.innerText = '📷 ビジョン停止'; b.classList.add('active'); state.vision = true;
} catch (e) { alert("カメラ許可が必要です"); }
} else {
const s = v.srcObject; if(s) s.getTracks().forEach(t => t.stop());
v.style.display = 'none'; b.innerText = '📷 ビジョン起動'; b.classList.remove('active'); state.vision = false;
}
}
function setTap(t) {
state.tap = t;
document.getElementById('t_std').classList.toggle('active', t === 'std');
document.getElementById('t_swg').classList.toggle('active', t === 'swg');
infer();
}
function infer() {
// 基本演算
const D = parseFloat(document.getElementById('innerDia').value);
const T = parseFloat(document.getElementById('temp').value);
const P = parseFloat(document.getElementById('press').value);
const C = parseFloat(document.getElementById('coil').value);
const KSize = parseFloat(document.getElementById('kegSize').value);
const KRem = parseFloat(document.getElementById('kegRemain').value);
const dF = Math.pow(9 / D, 4.5);
const curveF = Math.pow(17 / C, 0.85);
const tapF = (state.tap === 'swg') ? 0.85 : 1.25;
const R_eff = state.R_base * dF * curveF * tapF;
let L = (P + state.bias - 0.01) / R_eff;
// UI更新
document.getElementById('idDisp').innerText = D.toFixed(1);
document.getElementById('tDisp').innerText = T.toFixed(1);
document.getElementById('pDisp').innerText = P.toFixed(2);
document.getElementById('coilDisp').innerText = C;
document.getElementById('kegSizeDisp').innerText = KSize;
document.getElementById('remainDisp').innerText = KRem;
document.getElementById('recLen').innerText = Math.max(0.3, L).toFixed(1);
// テレメトリ(残量計算:1杯380ml換算)
const remainingLitres = KSize * (KRem / 100);
const pours = Math.floor(remainingLitres / 0.38);
document.getElementById('poursDisp').innerText = pours + " 杯";
document.getElementById('kegBar').style.width = KRem + "%";
document.getElementById('kegBar').style.background = KRem < 20 ? "#ff4757" : "var(--gold)";
let mc = 0; for(let i=0; i<100; i++) { if(P+(Math.random()*0.02-0.01) >= (T+(Math.random()*2-1))*0.0075+0.075) mc++; }
document.getElementById('mcProb').innerText = mc + "%";
document.getElementById('kalmanGain').innerText = R_eff.toFixed(5);
}
function update(f) {
const K = state.P_cov / (state.P_cov + 0.05);
if (f === 'turbulence') state.R_base += K * 0.0002;
else if (f === 'separation') state.bias -= K * 0.004;
else if (f === 'flat') state.bias -= K * 0.008;
else if (f === 'good') state.P_cov *= 0.9;
state.P_cov = (1 - K) * state.P_cov + 0.001;
const t = document.getElementById('telemetry');
t.style.borderColor = "#4ade80"; setTimeout(() => t.style.borderColor = "#d4a017", 300);
infer();
}
function startReset() {
const b = document.getElementById('resetBtn');
b.style.background = "#ff4757"; b.innerText = "リセット中...";
resetTimer = setTimeout(() => {
state.R_base = INITIAL_BASE; state.bias = 0.0; state.P_cov = 0.1;
alert("学習データを初期化しました。");
stopReset(); infer();
}, 2000);
}
function stopReset() {
clearTimeout(resetTimer);
const b = document.getElementById('resetBtn');
b.style.background = "#475569"; b.innerHTML = "AI学習リセット<small>長押し2秒</small>";
}
window.onload = infer;
</script>
</body>
</html>