開発日記 ・ 2026年10月24日
どの端末でも同じ盤面にする工夫:sin の答えはブラウザごとに違う
Wind Pop では、世界中の全員が同じ日に同じ盤面で遊びます。そして、友達がシェアしたリプレイのリンクを開くと、その人の1発が自分の画面でもまったく同じように再生されます。当たり前に見えるこの仕組みには、実はちょっとした落とし穴がありました。
盤面は「日付」から作られる
Wind Pop の盤面は、サーバーから送られてくるのではなく、遊ぶ人の端末の中で毎回計算して作っています。材料は日付だけです。たとえば 2026年10月25日なら「20261025」という数字を種にして、決まった手順で乱数を作り、100個の風船の位置と動き、うずの数や動き方、突風のタイミングを決めます。
同じ種からは、必ず同じ乱数の並びが出てきます。だから、日付が同じなら、誰の端末でも同じ盤面ができる……はずでした。
落とし穴:ブラウザごとに「sin」の答えが違う
風の計算には、三角関数(sin、cos)や指数関数(exp)をたくさん使います。うずの周りを回る動きは sin と cos で、うずから離れるほど風が弱くなる様子は exp で表しています。
ここに問題がありました。JavaScript の仕様では、Math.sin や Math.exp の答えは「だいたい正しければよい」ことになっていて、最後の桁の値はブラウザによって違ってかまわないのです。Chrome と Safari で、同じ Math.sin(1.234) がほんのわずかに違う値を返すことがあります。
差は小数点以下15〜16桁目くらいの、本当にわずかなものです。ところが、Wind Pop は1秒間に120回、100個の風船の位置を少しずつ動かしていきます。わずかな差が何千回も積み重なると、30秒後には風船の位置がはっきりずれ、連鎖が届くかどうかが変わってしまいます。「自分の端末では80個割れたのに、友達の端末でリプレイを見たら75個だった」ということが起こりうるのです。
解決:足し算・掛け算・平方根だけで作り直す
一方で、コンピューターの数の計算には、どの環境でも結果が完全に一致すると決まっている操作があります。足し算・引き算・掛け算・割り算、そして平方根です。これらは国際規格(IEEE 754)で「正確な値にいちばん近い数に丸める」ことが決められていて、ブラウザによる違いが出ません。
そこで Wind Pop では、sin や exp などの関数を、この5つの操作だけを使って自分で作り直しました。たとえば sin は、角度を小さな範囲に折りたたんでから、「x − x³/6 + x⁵/120 − …」という級数を決まった回数だけ足し合わせて計算します。exp や逆正接(atan2)も、同じ考え方で作っています。
こうして作った関数は、ブラウザの組み込み関数より少し遅いですが、どの端末でも1ビットも違わない答えを返します。風の計算は、すべてこの自作の関数で行っています。
もう1つの工夫:時間を刻む幅を固定する
もう1つずれの原因になるのが、画面の書き換えの速さです。1秒間に60回書き換える端末もあれば、120回の端末もあり、重いときには間隔が乱れます。もし「前回の書き換えから何秒たったか」を使って風船を動かすと、端末ごとに計算の刻み方が変わり、結果がずれてしまいます。
Wind Pop は、画面の速さとは関係なく、必ず「120分の1秒」ずつ時間を進めて計算しています。画面の書き換えが遅い端末では、1回の書き換えの間に計算を何回かまとめて進めるだけです。これで、速い端末でも遅い端末でも、計算の中身はまったく同じになります。
リプレイは「いつ・どこを押したか」だけ
ここまでの工夫のおかげで、リプレイはとても小さなデータで済んでいます。シェアのリンクに入っているのは、次の情報だけです。
- 盤面の日付
- 何回目の計算の刻みでタップしたか
- タップした場所(0.1ピクセル単位)
- そのときの結果(何個割れたか)
リンクを開いた端末は、日付から同じ盤面を作り、同じ刻みで同じ場所をタップします。計算が完全に一致するので、連鎖も1個残らず同じように再生されます。動画を送るのではなく、「同じ問題を、同じ手で解き直す」仕組みです。
時差への対応:日付が変わる時刻は国によって違うので、日本ではまだ今日でも、相手の国ではもう明日、ということがあります。そのため、リプレイのリンクは1日先の日付まで開けるようにしています。
公平さは、目に見えないところで作られる
「全員が同じ条件で遊ぶ」というのは、デイリーゲームのいちばん大事な約束です。その約束は、画面の見た目ではなく、小数点以下16桁の世界で守られています。友達のリプレイを見て「本当にこのタイミングでこんなに割れるのか」と驚いたら、ぜひ同じ瞬間を自分でも狙ってみてください。同じ場所を同じ瞬間に押せば、必ず同じ結果になります。
今日の盤面で遊ぶ
Dev diary · October 24, 2026
Same board on every device: why sin() differs between browsers
In Wind Pop, everyone in the world plays the same board on the same day. Open a friend's replay link and their exact shot plays out on your screen. That sounds obvious, but there was a hidden trap.
The board is built from the date
The board isn't sent from a server. Your device builds it every time, using only the date. For October 25, 2026, the number 20261025 seeds a random number generator, which decides the positions and motion of the 100 balloons, the number and paths of the whirls, and when gusts blow. The same seed always gives the same sequence, so the same date should give the same board on every device.
The trap: “sin” gives different answers in different browsers
The wind uses a lot of sine, cosine and exponential functions. But JavaScript's specification only asks Math.sin and Math.exp to be approximately right, so the last digits can differ between browsers. Chrome and Safari may return very slightly different values for the same Math.sin(1.234).
The difference sits around the 15th or 16th decimal place. But Wind Pop moves 100 balloons 120 times a second. After thousands of steps, tiny differences add up, balloons drift apart, and a chain might reach on one device and stop on another. Your 80-pop replay could show 75 on a friend's phone.
The fix: rebuild everything from + − × ÷ and √
Some operations are guaranteed to give identical results everywhere: addition, subtraction, multiplication, division and square root. The IEEE 754 standard requires each of them to round to the nearest representable number, so no browser can differ.
So we rewrote sine, exp and the rest using only those five operations. Sine, for example, folds the angle into a small range and then adds a fixed number of terms of the series x − x³/6 + x⁵/120 − …. These functions are a bit slower than the built-in ones, but they return bit-for-bit identical answers on every device, and all the wind physics uses them.
A fixed time step
Screen refresh rates differ: 60 times a second on some devices, 120 on others, and uneven when the device is busy. If balloons moved by “time since the last frame,” every device would slice time differently. Wind Pop always advances in steps of exactly 1/120 of a second, regardless of the screen. A slower screen simply runs several steps per frame.
A replay is just “when and where you tapped”
Thanks to all this, a share link only needs the board's date, the step number of your tap, the tap position (to 0.1 pixel), and your result. The device that opens it rebuilds the board from the date and taps the same spot at the same step. Because the math matches exactly, every single pop replays the same way. It doesn't send a video; it solves the same puzzle again with the same move.
Time zones: the date changes at different moments around the world, so replay links also open for a board up to one day ahead.
Fairness lives where you can't see it
“Everyone plays under the same conditions” is the core promise of a daily game, and it's kept down at the 16th decimal place. If a friend's replay surprises you, try the same moment yourself: the same tap at the same time always gives the same result.
Play today's board