{"id":291952,"date":"2019-07-11T15:00:46","date_gmt":"2019-07-11T15:00:46","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=291952"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=291952","title":{"rendered":"Tic Tac Toe, \u0447\u0430\u0441\u0442\u044c 2"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\n<p>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/users\/nomhoi\/posts\/\">Tic Tac Toe, \u0447\u0430\u0441\u0442\u044c 1<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u043d\u0430\u0447\u0430\u043b\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u044d\u0442\u043e\u0439 \u0438\u0433\u0440\u044b \u043d\u0430 <a href=\"https:\/\/svelte.dev\/\">Svelte<\/a>. \u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0434\u043e\u0434\u0435\u043b\u0430\u0435\u043c \u0438\u0433\u0440\u0443 \u0434\u043e \u043a\u043e\u043d\u0446\u0430. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u044b <strong>Undo\/Redo<\/strong>, \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043b\u044e\u0431\u043e\u043c\u0443 \u0448\u0430\u0433\u0443 \u0438\u0433\u0440\u044b, \u043f\u043e\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0445\u043e\u0434\u044b \u0441 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u0438\u043a\u043e\u043c, \u0432\u044b\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0438\u0433\u0440\u044b, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u0431\u0435\u0434\u0438\u0442\u0435\u043b\u044f.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h6 id=\"komandy-undoredo\">\u041a\u043e\u043c\u0430\u043d\u0434\u044b Undo\/Redo<\/h6>\n<p>  <\/p>\n<p><a href=\"https:\/\/svelte.dev\/repl\/a2d99cc8cd934b60ab4b252fdb1e2d36?version=3.6.4\">\u041a\u043e\u0434 \u043d\u0430 REPL<\/a><\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u044b\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u044b Undo\/Redo. \u0412 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 <strong>history<\/strong> \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u043c\u0435\u0442\u043e\u0434\u044b <strong>push<\/strong> \u0438 <strong>redo<\/strong>. <\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">undo: () =&gt; update(h =&gt; { h.undo(); return h; }), redo: () =&gt; update(h =&gt; { h.redo(); return h; }),<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043a\u043b\u0430\u0441\u0441 <strong>History<\/strong> \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u043c\u0435\u0442\u043e\u0434\u044b <strong>push<\/strong>, <strong>redo<\/strong>, <strong>canUndo<\/strong>, <strong>canRedo<\/strong>.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">canUndo() {     return this.current &gt; 0; }  canRedo() {     return this.current &lt; this.history.length - 1; }  undo() {     if (this.canUndo())         this.current--; }  redo() {     if (this.canRedo())         this.current++; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043c\u0435\u0442\u043e\u0434 <strong>push<\/strong> \u043a\u043b\u0430\u0441\u0441\u0430 <strong>History<\/strong> \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u043e\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0434\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e. \u0415\u0441\u043b\u0438 \u043c\u044b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <strong>Undo<\/strong> \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u043a\u043b\u0438\u043a \u0432 \u0438\u0433\u0440\u043e\u0432\u043e\u043c \u043f\u043e\u043b\u0435, \u0442\u043e \u0432\u0441\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0434\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0431\u0443\u0434\u0443\u0442 \u0443\u0434\u0430\u043b\u0435\u043d\u044b \u0438\u0437 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0438 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043e \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">push(state) {     \/\/ remove all redo states     if (this.canRedo())          this.history.splice(this.current + 1);      \/\/ add a new state     this.current++;     this.history.push(state); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 <strong>App<\/strong> \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u043a\u043d\u043e\u043f\u043a\u0438 <strong>Undo<\/strong> \u0438 <strong>Redo<\/strong>. \u0415\u0441\u043b\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434 \u043d\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0442\u043e \u043e\u043d\u0438 \u0434\u0435\u0430\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u044e\u0442\u0441\u044f.<\/p>\n<p>  <\/p>\n<pre><code class=\"html\">&lt;div&gt;     {#if $history.canUndo()}     &lt;button on:click={history.undo}&gt;Undo&lt;\/button&gt;     {:else}     &lt;button disabled&gt;Undo&lt;\/button&gt;     {\/if}     {#if $history.canRedo()}     &lt;button on:click={history.redo}&gt;Redo&lt;\/button&gt;     {:else}     &lt;button disabled&gt;Redo&lt;\/button&gt;     {\/if} &lt;\/div&gt;<\/code><\/pre>\n<p>  <\/p>\n<h6 id=\"smena-hoda\">\u0421\u043c\u0435\u043d\u0430 \u0445\u043e\u0434\u0430<\/h6>\n<p>  <\/p>\n<p><a href=\"https:\/\/svelte.dev\/repl\/78da804cf59e44a2a2ecc24b76eec892?version=3.6.4\">\u041a\u043e\u0434 \u043d\u0430 REPL<\/a><\/p>\n<p>  <\/p>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u043f\u043e\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0435 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u0440\u0435\u0441\u0442\u0438\u043a\u0430 \u0438\u043b\u0438 \u043d\u043e\u043b\u0438\u043a\u0430 \u043f\u043e\u0441\u043b\u0435 \u043a\u043b\u0438\u043a\u0430 \u043c\u044b\u0448\u043a\u043e\u0439. <\/p>\n<p>  <\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <strong>clickCell()<\/strong> \u0443\u0431\u0440\u0430\u043d \u0438\u0445 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 <strong>history<\/strong>, \u0432\u0435\u0441\u044c \u043a\u043e\u0434 \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043d \u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a <strong>handleClick()<\/strong> \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 <strong>Board<\/strong>. <\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">function handleClick(event) {     let x = Math.trunc((event.offsetX + 0.5) \/ cellWidth);     let y = Math.trunc((event.offsetY + 0.5) \/ cellHeight);     let i = y * width + x;      const state = $history.currentState();     const squares = state.squares.slice();     squares[i] = state.xIsNext ? 'X' : 'O';     let newState = {         squares: squares,         xIsNext: !state.xIsNext,     };     history.push(newState); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0431\u044b\u043b\u0430 \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0430 \u0440\u0430\u043d\u0435\u0435 \u0434\u043e\u043f\u0443\u0449\u0435\u043d\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430, \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0431\u044b\u043b\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442 \u043b\u043e\u0433\u0438\u043a\u0438 \u044d\u0442\u043e\u0439 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0438\u0433\u0440\u044b. \u0421\u0435\u0439\u0447\u0430\u0441 \u044d\u0442\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0430, \u0438 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0438\u0433\u0440\u0430\u0445 \u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.<\/p>\n<p>  <\/p>\n<p>\u0420\u0430\u043d\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0448\u0430\u0433\u0430 \u0438\u0433\u0440\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u0438\u0437 9 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u0421\u0435\u0439\u0447\u0430\u0441 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438\u0433\u0440\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c xIsNext. \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0438\u0433\u0440\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">let state = {   squares: Array(9).fill(''),   xIsNext: true, };<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 \u0435\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 <strong>history<\/strong> \u0441\u0435\u0439\u0447\u0430\u0441 \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043b\u044e\u0431\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<p>  <\/p>\n<h6 id=\"proizvolnyy-dostup-k-istorii-hodov\">\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0445\u043e\u0434\u043e\u0432<\/h6>\n<p>  <\/p>\n<p><a href=\"https:\/\/svelte.dev\/repl\/02532804e896493c9e5f5d54a084a2bb?version=3.6.4\">\u041a\u043e\u0434 \u043d\u0430 REPL<\/a><\/p>\n<p>  <\/p>\n<p>\u0412 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 <strong>history<\/strong> \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 <strong>setCurrent(current)<\/strong>, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438\u0433\u0440\u044b.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">setCurrent(current) {     if (current &gt;= 0 &amp;&amp; current &lt; this.history.length)         this.current = current; }<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"javascript\">setCurrent: (current) =&gt; update(h =&gt; {      h.setCurrent(current);     return h;  }),<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 <strong>App<\/strong> \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0432\u044b\u0432\u043e\u0434 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0445\u043e\u0434\u043e\u0432 \u0432 \u0432\u0438\u0434\u0435 \u043a\u043d\u043e\u043f\u043e\u043a.<\/p>\n<p>  <\/p>\n<pre><code class=\"html\">&lt;ol&gt;     {#each $history.history as value, i}         {#if i==0}             &lt;li&gt;&lt;button on:click={() =&gt; history.setCurrent(i)}&gt;Go to game start&lt;\/button&gt;&lt;\/li&gt;         {:else}             &lt;li&gt;&lt;button on:click={() =&gt; history.setCurrent(i)}&gt;Go to move #{i}&lt;\/button&gt;&lt;\/li&gt;         {\/if}     {\/each} &lt;\/ol&gt;<\/code><\/pre>\n<p>  <\/p>\n<h6 id=\"opredelenie-pobeditelya-vyvod-statusa-igry\">\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u0431\u0435\u0434\u0438\u0442\u0435\u043b\u044f, \u0432\u044b\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0438\u0433\u0440\u044b<\/h6>\n<p>  <\/p>\n<p><a href=\"https:\/\/svelte.dev\/repl\/b18067ae927246e790f5c3b4be185396?version=3.6.4\">\u041a\u043e\u0434 \u043d\u0430 REPL<\/a><\/p>\n<p>  <\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0431\u0435\u0434\u0438\u0442\u0435\u043b\u044f <strong>calculateWinner()<\/strong> \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 <strong>helpers.js<\/strong>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">export function calculateWinner(squares) {     const lines = [         [0, 1, 2],         [3, 4, 5],         [6, 7, 8],         [0, 3, 6],         [1, 4, 7],         [2, 5, 8],         [0, 4, 8],         [2, 4, 6],     ];     for (let i = 0; i &lt; lines.length; i++) {         const [a, b, c] = lines[i];         if (squares[a] &amp;&amp; squares[a] === squares[b] &amp;&amp; squares[a] === squares[c]) {             return squares[a];         }     }     return null; }  <\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043e <a href=\"https:\/\/ru.svelte.dev\/tutorial\/derived-stores\">\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435<\/a> <strong>status<\/strong> \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0438\u0433\u0440\u044b, \u0437\u0434\u0435\u0441\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u0445\u043e\u0434 \u0438\u0433\u0440\u044b: \u043f\u043e\u0431\u0435\u0434\u0438\u0442\u0435\u043b\u044c \u0438\u043b\u0438 \u043d\u0438\u0447\u044c\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">export const status = derived(     history,     $history =&gt; {          if ($history.currentState()) {             if (calculateWinner($history.currentState().squares))                 return 1;             else if ($history.current == 9)                 return 2;         }         return 0;     } );<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 <strong>App<\/strong> \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0432\u044b\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0438\u0433\u0440\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"html\">&lt;div class=\"status\"&gt;     {#if $status === 1}         &lt;b&gt;Winner: {!$history.currentState().xIsNext ? 'X' : 'O'}&lt;\/b&gt;     {:else if $status === 2}         &lt;b&gt;Draw&lt;\/b&gt;     {:else}         Next player: {$history.currentState().xIsNext ? 'X' : 'O'}     {\/if} &lt;\/div&gt;  <\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 <strong>Board<\/strong> \u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043a\u043b\u0438\u043a\u0430 <strong>handleClick()<\/strong> \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f: \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043b\u0438\u043a \u0432 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u043e\u0439 \u043a\u043b\u0435\u0442\u043a\u0435 \u0438 \u043f\u043e \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0438 \u0438\u0433\u0440\u044b.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">const state = $history.currentState(); if ($status == 1 || state.squares[i])     return;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418\u0433\u0440\u0430 \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d\u0430! \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u044d\u0442\u043e\u0439 \u0436\u0435 \u0438\u0433\u0440\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 Command, \u0442.\u0435. \u0441 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434 Undo\/Redo \u0432\u043c\u0435\u0441\u0442\u043e \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439.<\/p>\n<p>  <\/p>\n<h6 id=\"repozitoriy-na-github\">\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u043d\u0430 GitHub<\/h6>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/nomhoi\/tic-tac-toe-part2\">https:\/\/github.com\/nomhoi\/tic-tac-toe-part2<\/a><\/p>\n<p>  <\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0438\u0433\u0440\u044b \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">git clone https:\/\/github.com\/nomhoi\/tic-tac-toe-part2.git cd tic-tac-toe-part2 npm install npm run dev<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0438\u0433\u0440\u0443 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443: <a href=\"http:\/\/localhost:5000\/\">http:\/\/localhost:5000\/<\/a>.<\/p>\n<\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/459630\/\"> https:\/\/habr.com\/ru\/post\/459630\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\n<p>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/users\/nomhoi\/posts\/\">Tic Tac Toe, \u0447\u0430\u0441\u0442\u044c 1<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u043d\u0430\u0447\u0430\u043b\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u044d\u0442\u043e\u0439 \u0438\u0433\u0440\u044b \u043d\u0430 <a href=\"https:\/\/svelte.dev\/\">Svelte<\/a>. \u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0434\u043e\u0434\u0435\u043b\u0430\u0435\u043c \u0438\u0433\u0440\u0443 \u0434\u043e \u043a\u043e\u043d\u0446\u0430. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u044b <strong>Undo\/Redo<\/strong>, \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043b\u044e\u0431\u043e\u043c\u0443 \u0448\u0430\u0433\u0443 \u0438\u0433\u0440\u044b, \u043f\u043e\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0445\u043e\u0434\u044b \u0441 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u0438\u043a\u043e\u043c, \u0432\u044b\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0438\u0433\u0440\u044b, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u0431\u0435\u0434\u0438\u0442\u0435\u043b\u044f.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-291952","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/291952","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=291952"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/291952\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=291952"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=291952"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=291952"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}