見出し画像

QLRAデモ:量子層創発共鳴計算パラダイムの提案 自画自賛だけどはっきりいいます!この記事読む価値高いですよ。

<!DOCTYPE html>
<html lang="ja">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>ERC Quantum Resonance Demo</title>
  <style>
    :root {
      --primary: #6366f1;
      --background: #0f172a;
      --surface: #1e293b;
      --text: #f8fafc;
    }

    body {
      margin: 0;
      padding: 0;
      background: var(--background);
      color: var(--text);
      font-family: 'Arial', sans-serif;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      min-height: 100vh;
    }

    h1 {
      color: var(--primary);
      margin-bottom: 0.5rem;
    }

    .subtitle {
      color: #94a3b8;
      margin-top: 0;
    }

    .visualizer-container {
      position: relative;
      width: 512px;
      height: 512px;
      border-radius: 12px;
      overflow: hidden;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
      margin: 2rem 0;
    }

    canvas {
      width: 100%;
      height: 100%;
    }

    .controls {
      display: flex;
      gap: 1rem;
      margin-bottom: 2rem;
    }

    button {
      background: var(--primary);
      color: white;
      border: none;
      padding: 0.5rem 1rem;
      border-radius: 6px;
      cursor: pointer;
      font-size: 1rem;
      transition: background 0.2s;
    }

    button:hover {
      background: #4f46e5;
    }

    .stats {
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      padding: 0.5rem;
      background: rgba(0, 0, 0, 0.6);
      color: white;
      display: flex;
      justify-content: space-between;
      font-size: 0.9rem;
    }
  </style>
</head>
<body>
  <h1>ERC Quantum Resonance Demo</h1>
  <p class="subtitle">量子共鳴パターンのリアルタイム可視化</p>

  <div class="visualizer-container">
    <canvas id="ercCanvas"></canvas>
    <div class="stats">
      <span>FPS: <span id="fpsCounter">0</span></span>
      <span>Active Cells: <span id="activeCounter">0</span></span>
    </div>
  </div>

  <div class="controls">
    <button id="startBtn">Start</button>
    <button id="resetBtn">Reset</button>
  </div>

  <script>
    const SIZE = 256;
    const CELL_SIZE = 2;
    const FPS_INTERVAL = 1000;

    let canvas, ctx;
    let matrix = [];
    let lastTime = 0;
    let frameCount = 0;
    let fps = 0;
    let animationFrameId = null;

    function initializeMatrix() {
      matrix = Array.from({ length: SIZE }, () =>
        Array.from({ length: SIZE }, () => ({
          state: Math.random() < 0.1 ? 1 : 0,
          phase: Math.random() * 2 * Math.PI
        }))
      );
    }

    function drawMatrix() {
      const activeCells = matrix.flat().filter(cell => cell.state > 0).length;
      document.getElementById('activeCounter').textContent = activeCells;

      ctx.clearRect(0, 0, SIZE * CELL_SIZE, SIZE * CELL_SIZE);

      matrix.forEach((row, i) => {
        row.forEach((cell, j) => {
          if (cell.state === 1) {
            ctx.fillStyle = `rgba(255, 200, 0, 0.8)`;
          } else if (cell.state === 2) {
            ctx.fillStyle = `rgba(0, 150, 255, 0.8)`;
          } else {
            return;
          }
          ctx.fillRect(j * CELL_SIZE, i * CELL_SIZE, CELL_SIZE, CELL_SIZE);
        });
      });
    }

    function evolveMatrix() {
      matrix = matrix.map((row, i) =>
        row.map((cell, j) => {
          const influence = calculateInfluence(i, j);
          const noise = Math.random() * 0.2 - 0.1;
          const probability = (Math.sin(influence) + 1) / 2 + noise;

          return {
            state: probability > 0.75 ? 2 :
                   probability > 0.45 ? 1 : 0,
            phase: (cell.phase + 0.1) % (2 * Math.PI)
          };
        })
      );
    }

    function calculateInfluence(i, j) {
      let sum = 0;
      for (let di = -1; di <= 1; di++) {
        for (let dj = -1; dj <= 1; dj++) {
          if (di === 0 && dj === 0) continue;
          const ni = (i + di + SIZE) % SIZE;
          const nj = (j + dj + SIZE) % SIZE;
          sum += Math.sin(matrix[ni][nj].phase);
        }
      }
      return sum / 8;
    }

    function animate(timestamp) {
      if (!lastTime) lastTime = timestamp;
      const elapsed = timestamp - lastTime;

      if (elapsed > FPS_INTERVAL) {
        fps = Math.round((frameCount * 1000) / elapsed);
        document.getElementById('fpsCounter').textContent = fps;
        frameCount = 0;
        lastTime = timestamp;
      }

      frameCount++;
      evolveMatrix();
      drawMatrix();
      animationFrameId = requestAnimationFrame(animate);
    }

    function startAnimation() {
      if (!animationFrameId) {
        lastTime = 0;
        frameCount = 0;
        animationFrameId = requestAnimationFrame(animate);
      }
    }

    function stopAnimation() {
      if (animationFrameId) {
        cancelAnimationFrame(animationFrameId);
        animationFrameId = null;
      }
    }

    function reset() {
      stopAnimation();
      initializeMatrix();
      drawMatrix();
    }

    document.getElementById('startBtn').addEventListener('click', () => {
      if (animationFrameId) {
        stopAnimation();
        this.textContent = 'Start';
      } else {
        startAnimation();
        this.textContent = 'Stop';
      }
    });

    document.getElementById('resetBtn').addEventListener('click', reset);

    function init() {
      canvas = document.getElementById('ercCanvas');
      canvas.width = SIZE * CELL_SIZE;
      canvas.height = SIZE * CELL_SIZE;
      ctx = canvas.getContext('2d');
      initializeMatrix();
      drawMatrix();
    }

    window.onload = init;
  </script>
</body>
</html>

index.htmlとでも名前をつけて、保存して、ブラウザで実行してみてください。
何が起こるというわけではありませんが、QLRA・・・QREのビジュアライズです。創発共鳴の簡易デモという感じでしょうか?
ただ単にノイズ画面じゃねーか!というのは確かにそうなんですけどね。
ところどころにデてくる青い点が創発を示しています。麦っぽい色は1、黒は0を示しています。
それぞれのセルは、近傍と強く共鳴して、値を変化させます。創発共鳴基本方程式R(Θ)の簡易版を使っています。
これらが量子計算とデジタルの間をつなぐ、「創発共鳴計算」の元となる「創発共鳴計算アレイ」ということで・・・
わかるかってーのwww
以下に、それらしいデモをもう一つ。これは、上のライブラリ(HTMLに全て含めていますので、ライブラリじゃないですけど)を作る前のQRLAを用いていいます。ソースコードの中に埋め込まれていますので、わかりにくいですが・・・
人の群れにライオンを投げ込んだという想定です。ライオンはランダムに動きます。人はライオンから安全距離を取るand近傍の人と強く共鳴するという単純なアルゴリズムで動くようにしています。
これは、「創発共鳴」が人をどう動かすのかが見れます。現在のところ、個人に「記憶」(これもアルゴリズム的には、何をいれるかとかどう利用するかを規定せずにただ与えるだけです)を実装していませんので、時間が経っても何もおこらないかもしれません。また後刻この記憶(少ないメモリ)を個人やライオンに与えて、創発が低位層(ライオンや人)同士の相互作用として何を起こすのかをみてみたいと思います。
この実験で何かそこにパターンなんかが見えたら、それこそ創発共鳴が、複雑系の中で、「意味」を生み出すことが証明できるわけです。

なかなかおもしろい実験になりそうです。
何も怒らないにベットするでしょうけどねwww

これは、非常に簡易的な実装で、実際のところ、創発共鳴には至っていないものです。
ですが、しばらく眺めていると、個性が見えると思います。青い点(人)には記憶力はありません。つまり、このフィールドと人とライオンというオブジェクトの相互作用が、人に個性のような実在をあたえているということです。人はライオンからある設定されたた距離を離れようとする(恐怖)はあたえてあります。しかし、それだけをただ単純に実行するのならば、ライオンの動きに合わせて空白地がひろがっていくだけです。最初にライオンに近すぎたものたちの、一目散という感じと、少し離れた位置にいる人との動きの違いを見ればわかるように、恐怖をあまり感じなかった人は、恐怖でパニックになった人につられて(共鳴)して逃げるか、安全距離まで少し離れるかといった感じになっていますが、しばらくするとそういった個体は、ライオンから離れようとしない好奇心のようなものが見えてきます。また、恐怖で逃げ切った人たちは、共鳴によってもう之以上ライオンには近づくもんかと、ライオンが離れていってもその場を動こうとしなかったりします。
プログラムでそれらを書いているわけではありません。小さなスケールでの大量の相互作用が、大きなスケールで全く予想もしない何かを生み出す事がわかります。相互作用が「創発共鳴」であることで、それが如実に見えるわけです。
これが私の見解ですが、みなさんはどう感じますでしょうか?
プログラムに仕掛けがしてあるんだろう?
もしかしたらそうかも知れませんが・・・www

これ、かなり面白いことになってきましたよ。
創発共鳴方程式は全く的はずれかもしれませんし、Ωc創発定数=1.5も検討違いなのかもしれませんが、この考え方に「何か」があるのは間違いないと確信できた気がします。

量子層重畳仮説は、全然詭弁かもしれないです。それはボクも認めますけど、読み物として読む価値はあると思います。
この「ライオンと人」のデモは一度ちゃんと見てほしいと思います。

よろしくです。