{"id":70008,"date":"2026-11-09T07:39:57","date_gmt":"2026-11-09T02:09:57","guid":{"rendered":"https:\/\/www.quickonlinetips.com\/archives\/games\/gomoku\/"},"modified":"2026-11-09T07:39:57","modified_gmt":"2026-11-09T02:09:57","slug":"gomoku","status":"publish","type":"page","link":"https:\/\/www.quickonlinetips.com\/archives\/games\/gomoku\/","title":{"rendered":"Gomoku: Play Five in a Row Online"},"content":{"rendered":"<p>Play <strong>Gomoku<\/strong> free online, the classic five in a row game. Take turns placing dark and light stones on a 15 by 15 board, and be the first to line up five of your stones across, down or diagonally. Play against the computer on three levels or with a friend on the same device.<\/p>\n<style>.qgm-wrap{width:min(560px,100%);margin:14px auto 0} .qgm-b{display:grid;grid-template-columns:repeat(15,1fr);background:#E3C98F;border:10px solid #C9A764;border-radius:8px;box-shadow:0 2px 6px rgba(0,0,0,.2);user-select:none;-webkit-user-select:none;touch-action:manipulation} .qgm-c{position:relative;aspect-ratio:1;cursor:pointer;display:flex;align-items:center;justify-content:center} .qgm-star{width:22%;height:22%;border-radius:50%;background:#6B5536} .qgm-s{width:88%;height:88%;border-radius:50%;box-shadow:0 1px 2px rgba(0,0,0,.45);position:relative;z-index:1} .qgm-k{background:radial-gradient(circle at 35% 30%,#64748B,#1E293B 55%,#0B1120)} .qgm-p{background:radial-gradient(circle at 35% 30%,#FFFFFF,#EEF2F6 55%,#B8C2CF)} .qgm-last::after{content:\"\";position:absolute;left:36%;top:36%;width:28%;height:28%;border-radius:50%;background:#E11D48} .qgm-win{box-shadow:0 0 0 3px #F59E0B,0 1px 2px rgba(0,0,0,.45)} .qgm-e:hover .qgm-ghost{opacity:.45} .qgm-ghost{position:absolute;width:80%;height:80%;border-radius:50%;opacity:0;pointer-events:none} .qgm-msg{text-align:center;font-size:19px;font-weight:700;color:#215387;min-height:1.5em;margin:6px 0 0} .qgm-sw{display:inline-block;width:14px;height:14px;border-radius:50%;vertical-align:-2px;margin-right:4px}<\/style>\n<div class=\"qt-tool\" id=\"qgm\"><p class=\"qt-label\" style=\"font-size:1.15em;margin:0 0 10px\"><strong>Step 1:<\/strong> Choose your opponent<\/p> <div class=\"qt-grid\" style=\"grid-template-columns:repeat(auto-fit,minmax(200px,1fr))\"><div class=\"qt-field\"><label for=\"qgm-mode\">Opponent<\/label><select id=\"qgm-mode\"><option value=\"1\">Computer: easy<\/option><option value=\"2\" selected>Computer: medium<\/option><option value=\"3\">Computer: hard<\/option><option value=\"2p\">Friend (2 players)<\/option><\/select><\/div> <div class=\"qt-field\"><label for=\"qgm-side\">You play<\/label><select id=\"qgm-side\"><option value=\"1\" selected>Dark stones (you move first)<\/option><option value=\"-1\">Light stones (computer moves first)<\/option><\/select><\/div><\/div> <p class=\"qt-label\" style=\"font-size:1.15em;margin:18px 0 10px\"><strong>Step 2:<\/strong> Tap a point to place a stone. Get five in a row to win<\/p> <p class=\"qgm-msg\" id=\"qgm-msg\" aria-live=\"polite\"><\/p> <div class=\"qgm-wrap\"><div class=\"qgm-b\" id=\"qgm-b\" role=\"grid\" aria-label=\"Gomoku board, 15 by 15\"><\/div><\/div> <div class=\"qt-stats\" style=\"grid-template-columns:repeat(3,1fr)\"><div class=\"qt-stat\"><span class=\"qt-num\" id=\"qgm-mv\">0<\/span><span class=\"qt-lab\">Stones played<\/span><\/div><div class=\"qt-stat\"><span class=\"qt-num\" id=\"qgm-w1\">0<\/span><span class=\"qt-lab\" id=\"qgm-l1\">Your wins<\/span><\/div><div class=\"qt-stat\"><span class=\"qt-num\" id=\"qgm-w2\">0<\/span><span class=\"qt-lab\" id=\"qgm-l2\">Computer wins<\/span><\/div><\/div> <div class=\"qt-row\" style=\"justify-content:center\"><button type=\"button\" class=\"qt-btn qt-btn-big\" id=\"qgm-new\">New game<\/button><button type=\"button\" class=\"qt-btn qt-btn-ghost\" id=\"qgm-undo\">Undo move<\/button><\/div> <p class=\"qt-note\"><strong>Private by design:<\/strong> the game and the computer player run in your own browser. Nothing is sent to QuickOnlineTips or stored.<\/p><\/div>\n<script>(function () { function qtReady(fn) { if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', fn); } else { fn(); } } function qtRand32() { var c = window.crypto || window.msCrypto; if (c) { if (c.getRandomValues) { var a = new Uint32Array(1); c.getRandomValues(a); return a[0]; } } return Math.floor(Math.random() * 4294967296); } function qtRandInt(range) { var limit = Math.floor(4294967296 \/ range) * range; var x = qtRand32(); while (x >= limit) { x = qtRand32(); } return x % range; } qtReady(function () { var root = document.getElementById('qgm'); if (!root) { return; } function $(id) { return document.getElementById('qgm-' + id); } var N = 15, B = $('b'), cells = [], bd = [], turn = 1, over = false, busy = false, hist = [], last = -1, wins = [0, 0], tmr = 0, winLine = []; var DIR = [[0, 1], [1, 0], [1, 1], [1, -1]], WA = [0, 2, 14, 120, 1500, 200000], STAR = [48, 56, 112, 168, 176]; function at(b, r, c) { if (0 > r || r >= N || 0 > c || c >= N) { return 9; } return b[r * N + c]; } function five(b, i, s) { var r = Math.floor(i \/ N), c = i % N, res = null; DIR.forEach(function (d) { if (res) { return; } var line = [i], k; for (k = 1; at(b, r + d[0] * k, c + d[1] * k) === s; k++) { line.push((r + d[0] * k) * N + c + d[1] * k); } for (k = 1; at(b, r - d[0] * k, c - d[1] * k) === s; k++) { line.push((r - d[0] * k) * N + c - d[1] * k); } if (line.length >= 5) { res = line; } }); return res; } function score(b, i, s) { var r = Math.floor(i \/ N), c = i % N, total = 0; DIR.forEach(function (d) { for (var off = -4; 0 >= off; off++) { var own = 1, bad = false; for (var k = 0; 5 > k; k++) { if (off + k === 0) { continue; } var v = at(b, r + d[0] * (off + k), c + d[1] * (off + k)); if (v === 9 || v === -s) { bad = true; break; } if (v === s) { own++; } } if (!bad) { total += WA[own]; } } }); return total; } function cands(b) { var out = [], any = false, i, r, c, dr, dc; for (i = 0; N * N > i; i++) { if (b[i] !== 0) { any = true; continue; } r = Math.floor(i \/ N); c = i % N; var near = false; for (dr = -2; 2 >= dr; dr++) { for (dc = -2; 2 >= dc; dc++) { var v = at(b, r + dr, c + dc); if (v === 1 || v === -1) { near = true; } } } if (near) { out.push(i); } } if (!any) { out.push(112); } return out; } function ranked(b, s, dw) { return cands(b).map(function (i) { var a = score(b, i, s), d = score(b, i, -s); return { i: i, a: a, v: a * 1.1 + d * dw }; }).sort(function (p, q) { return q.v - p.v; }); } function aiMove(s) { var lvl = $('mode').value, list; if (lvl === '1') { list = ranked(bd, s, 0.55); if (list[0].a >= 200000) { return list[0].i; } var top = list.slice(0, Math.min(6, list.length)); return top[qtRandInt(top.length)].i; } list = ranked(bd, s, 1); if (lvl === '2') { var tie = list.filter(function (x) { return x.v >= list[0].v * 0.97; }); return tie[qtRandInt(tie.length)].i; } if (list[0].a >= 200000) { return list[0].i; } var best = list[0].i, bv = -Infinity; list.slice(0, 10).forEach(function (m) { var nb = bd.slice(); nb[m.i] = s; var opp = ranked(nb, -s, 1)[0], ov = opp ? opp.a * 1.1 + score(nb, opp.i, s) : 0; var v = m.v - 0.7 * ov; if (v > bv) { bv = v; best = m.i; } }); return best; } function vsAI() { return $('mode').value !== '2p'; } function human() { return Number($('side').value); } function name(s) { return s === 1 ? 'Dark' : 'Light'; } function say(t) { $('msg').textContent = t; } function count() { var n = 0; bd.forEach(function (v) { if (v !== 0) { n++; } }); return n; } function draw() { var mine = !over; if (busy) { mine = false; } if (vsAI()) { if (turn !== human()) { mine = false; } } for (var i = 0; N * N > i; i++) { var c = cells[i]; c.textContent = ''; c.classList.toggle('qgm-e', mine ? bd[i] === 0 : false); if (bd[i] !== 0) { var s = document.createElement('div'); s.className = 'qgm-s ' + (bd[i] === 1 ? 'qgm-k' : 'qgm-p'); if (i === last) { s.classList.add('qgm-last'); } if (winLine.indexOf(i) > -1) { s.classList.add('qgm-win'); } c.appendChild(s); c.setAttribute('aria-label', name(bd[i]) + ' stone'); } else { if (STAR.indexOf(i) > -1) { var st = document.createElement('div'); st.className = 'qgm-star'; c.appendChild(st); } if (mine) { var g = document.createElement('div'); g.className = 'qgm-ghost ' + (turn === 1 ? 'qgm-k' : 'qgm-p'); c.appendChild(g); } c.setAttribute('aria-label', 'Empty point'); } } $('mv').textContent = count(); } function finish(s) { over = true; busy = false; var t; if (s === 0) { t = 'The board is full. It is a draw.'; } else if (vsAI()) { if (s === human()) { wins[0]++; t = 'Five in a row. You win! \ud83c\udf89'; } else { wins[1]++; t = 'The computer got five in a row. Try again!'; } } else { if (s === 1) { wins[0]++; } else { wins[1]++; } t = name(s) + ' gets five in a row and wins! \ud83c\udf89'; } $('w1').textContent = wins[0]; $('w2').textContent = wins[1]; draw(); say(t); } function prompt() { draw(); if (over) { return; } if (vsAI()) { if (turn !== human()) { busy = true; draw(); say('Computer is thinking...'); tmr = setTimeout(function () { busy = false; place(aiMove(turn)); }, 380); return; } say('Your turn (' + name(turn).toLowerCase() + ' stones).'); return; } say(name(turn) + ' to play.'); } function place(i) { bd[i] = turn; last = i; var w = five(bd, i, turn); if (w) { winLine = w; finish(turn); return; } if (count() === N * N) { finish(0); return; } turn = -turn; prompt(); } function click(i) { if (over || busy) { return; } if (vsAI()) { if (turn !== human()) { return; } } if (bd[i] !== 0) { return; } hist.push({ bd: bd.slice(), turn: turn, last: last }); place(i); } function lines(i) { var r = Math.floor(i \/ N), c = i % N, col = '#6B5536', hx = c === 0 ? '100%' : '0', hw = (c === 0 || c === N - 1) ? '50%' : '100%', vy = r === 0 ? '100%' : '0', vh = (r === 0 || r === N - 1) ? '50%' : '100%'; return 'linear-gradient(' + col + ',' + col + ') ' + hx + ' 50% \/ ' + hw + ' 1px no-repeat, linear-gradient(' + col + ',' + col + ') 50% ' + vy + ' \/ 1px ' + vh + ' no-repeat'; } function reset() { clearTimeout(tmr); bd = []; for (var i = 0; N * N > i; i++) { bd.push(0); } turn = 1; over = false; busy = false; hist = []; last = -1; winLine = []; $('l1').textContent = vsAI() ? 'Your wins' : 'Dark wins'; $('l2').textContent = vsAI() ? 'Computer wins' : 'Light wins'; $('side').disabled = !vsAI(); prompt(); } for (var i = 0; N * N > i; i++) { (function (k) { var c = document.createElement('div'); c.className = 'qgm-c'; c.setAttribute('role', 'gridcell'); c.style.background = lines(k); c.addEventListener('click', function () { click(k); }); B.appendChild(c); cells.push(c); })(i); } $('new').addEventListener('click', reset); $('undo').addEventListener('click', function () { if (!hist.length) { say('Nothing to undo yet.'); return; } clearTimeout(tmr); busy = false; over = false; winLine = []; var h = hist.pop(); bd = h.bd; turn = h.turn; last = h.last; prompt(); }); $('mode').addEventListener('change', function () { wins = [0, 0]; $('w1').textContent = 0; $('w2').textContent = 0; reset(); }); $('side').addEventListener('change', reset); reset(); }); })();<\/script>\n<div class=\"qt-next\"><p class=\"qt-next-h\">Play next<\/p><div class=\"qt-next-g\"><a href=\"https:\/\/www.quickonlinetips.com\/archives\/games\/tic-tac-toe\/\">Tic Tac Toe<\/a><a href=\"https:\/\/www.quickonlinetips.com\/archives\/games\/reversi\/\">Reversi<\/a><a href=\"https:\/\/www.quickonlinetips.com\/archives\/games\/checkers\/\">Checkers<\/a><a href=\"https:\/\/www.quickonlinetips.com\/archives\/games\/dots-and-boxes\/\">Dots and Boxes<\/a><a href=\"https:\/\/www.quickonlinetips.com\/archives\/games\/mancala\/\">Mancala<\/a><a href=\"https:\/\/www.quickonlinetips.com\/archives\/games\/nim\/\">Nim<\/a><\/div><\/div>\n<p><strong>Quick answer:<\/strong> Tap any empty point to place a stone. Dark moves first, then players take turns. The first player to get five stones in an unbroken line, across, down or diagonally, wins. Block your opponent whenever they have four in a row, or an open row of three.<\/p>\n<h2>How to play Gomoku<\/h2>\n<ol>\n<li>The board starts empty. Dark places the first stone, usually near the centre.<\/li>\n<li>Players take turns placing one stone on any empty point where the lines cross. Stones never move and are never captured.<\/li>\n<li>Make a line of five of your stones in a row, across, down or diagonally, to win. In this version, a line of six or more also wins.<\/li>\n<li>If the board fills up with no five in a row, the game is a draw.<\/li>\n<\/ol>\n<h2>Gomoku strategy tips<\/h2>\n<ul>\n<li><strong>Watch for open threes.<\/strong> Three stones in a row with both ends empty will become an open four next turn, and an open four cannot be stopped. Block open threes straight away.<\/li>\n<li><strong>Always block a four.<\/strong> If your opponent has four in a row with one empty end, place your stone there.<\/li>\n<li><strong>Build double threats.<\/strong> A move that makes two threats at once, such as two open threes or a four and an open three, usually wins because your opponent can block only one.<\/li>\n<li><strong>Stay close to the action.<\/strong> Stones near the centre and near other stones are worth more than stones on the edge.<\/li>\n<\/ul>\n<h2>Computer levels<\/h2>\n<table class=\"qt-ref\">\n<thead>\n<tr>\n<th>Level<\/th>\n<th>How it plays<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Easy<\/td>\n<td>Spots wins but often misses your threats. Good for learning.<\/td>\n<\/tr>\n<tr>\n<td>Medium<\/td>\n<td>Attacks and defends well, one move at a time.<\/td>\n<\/tr>\n<tr>\n<td>Hard<\/td>\n<td>Also checks your best reply before it moves, so it rarely leaves you a double threat.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>More strategy games: <a href=\"https:\/\/www.quickonlinetips.com\/archives\/games\/tic-tac-toe\/\">Tic Tac Toe<\/a> is the quick three in a row version, or try <a href=\"https:\/\/www.quickonlinetips.com\/archives\/games\/reversi\/\">Reversi<\/a> and <a href=\"https:\/\/www.quickonlinetips.com\/archives\/games\/checkers\/\">checkers<\/a>. See all our <a href=\"https:\/\/www.quickonlinetips.com\/archives\/games\/\">free online games<\/a>.<\/p>\n<h2>FAQ<\/h2>\n<h3>Is Gomoku the same as five in a row?<\/h3>\n<p>Yes. Gomoku is the traditional name of the five in a row game, which is played on a grid with stones that never move.<\/p>\n<h3>Does dark have an advantage?<\/h3>\n<p>Yes. The first player has a real advantage in Gomoku, which is why tournaments use special opening rules. Take turns being dark when you play a friend, or choose light stones to give the computer the first move.<\/p>\n<h3>Is it free?<\/h3>\n<p>Yes. It is free with no sign-up and no download, on phones, tablets and computers.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Play Gomoku free online, the classic five in a row game. Take turns placing dark and light stones on a 15 by 15 board, and be the first to line up five of your stones across, down or diagonally. Play against the computer on three levels or with a friend on the same device. Quick&#8230;<\/p>\n","protected":false},"author":7,"featured_media":0,"parent":66148,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"class_list":["post-70008","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/pages\/70008","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/comments?post=70008"}],"version-history":[{"count":0,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/pages\/70008\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/pages\/66148"}],"wp:attachment":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/media?parent=70008"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}