{"id":260750,"date":"2015-07-06T09:09:02","date_gmt":"2015-07-06T05:09:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=260750"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=260750","title":{"rendered":"\u0417\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u043e \u0441 Nim: \u043f\u0438\u0448\u0435\u043c \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u0443\u044e 2048"},"content":{"rendered":"<p>     \t<img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/657\/f1c\/9fd\/657f1c9fd89b46f485d3be8fe0e9ad24.jpg\" align=\"right\"\/><br \/>  \u0425\u043e\u0447\u0435\u0442\u0441\u044f \u0447\u0435\u0433\u043e-\u0442\u043e \u043d\u043e\u0432\u043e\u0433\u043e, \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e, \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0433\u043e \u043d\u0430 \u043e\u0449\u0443\u043f? \u0414\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434 \u043a\u0430\u0442, \u0433\u0434\u0435 \u043c\u044b \u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Nim \u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0433\u043e \u043a\u043b\u043e\u043d\u0430 \u0438\u0433\u0440\u044b 2048. \u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043e\u0432, \u0442\u043e\u043b\u044c\u043a\u043e \u0445\u0430\u0440\u0434\u043a\u043e\u0440, \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430!<\/p>\n<p>  \u0412 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435:  <\/p>\n<ul>\n<li><a href=\"#who-is-nim\">Who is the Nim?<\/a><\/li>\n<li><a href=\"#oop-in-nim\">\u041a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u041e\u041e\u041f \u0432 Nim<\/a><\/li>\n<li><a href=\"#underhood\">\u041d\u0435\u043c\u043d\u043e\u0433\u043e C \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c<\/a><\/li>\n<li><a href=\"#instances\">\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432<\/a><\/li>\n<li><a href=\"#2048\">\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438\u0433\u0440\u0430 2048<\/a> (<a href=\"https:\/\/github.com\/Ostrovski\/nim-2048\">github<\/a>)<\/li>\n<li><a href=\"#conclusions\">\u0421\u0443\u0431\u044a\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0432\u044b\u0432\u043e\u0434\u044b<\/a><\/li>\n<\/ul>\n<p>  <a name=\"habracut\"><\/a>  <\/p>\n<h1><a name=\"who-is-nim\"><\/a>Who is the Nim?<\/h1>\n<p>  <\/p>\n<h4>\u041e\u0431\u044a\u0435\u043a\u0442\u0438\u0432\u043d\u043e:<\/h4>\n<p>  Nim \u2014 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439, \u0438\u043c\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439, \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u0439. \u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u042f\u041f, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u044f\u043c\u043e\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0430\u0434\u0440\u0435\u0441\u0430\u043c \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0430 \u043c\u0443\u0441\u043e\u0440\u0430. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u2014 <a href=\"http:\/\/nim-lang.org\/\">\u0442\u0443\u0442<\/a>.<\/p>\n<h4>\u0421\u0443\u0431\u044a\u0435\u043a\u0442\u0438\u0432\u043d\u043e<\/h4>\n<p>  \u041c\u043d\u043e\u0433\u0438\u0435 \u0438\u0437 \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0449\u0438\u0445\u0441\u044f \u0441\u0435\u0439\u0447\u0430\u0441 \u044f\u0437\u044b\u043a\u043e\u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u0440\u0435\u043c\u044f\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043e\u0434\u043d\u0443 (\u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e) killer-feature, \u043f\u044b\u0442\u0430\u044f\u0441\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0438\u0445 \u0440\u0435\u0448\u0438\u0442\u044c \u0448\u0438\u0440\u043e\u043a\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 \u0437\u0430\u0434\u0430\u0447 (go routines \u0432 Go, <s>\u0430\u0434\u0441\u043a\u043e\u0435<\/s> \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u0432 Rust \u0438 \u043f\u0440). Nim \u043d\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438. \u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043f\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u043a\u0443 \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044e\u0449\u0438\u0439 Python. \u0417\u0430\u0442\u043e Nim \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043b\u0435\u0433\u043a\u043e. \u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u0430\u043a\u0436\u0435 \u043b\u0435\u0433\u043a\u043e, \u043a\u0430\u043a \u043d\u0430 \u0441\u0442\u043e\u043b\u044c \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u043e\u043c Python. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0441\u0440\u0430\u0432\u043d\u0438\u043c\u044b \u0441 \u0430\u043d\u0430\u043b\u043e\u0433\u0430\u043c\u0438 \u043d\u0430 C, \u0442\u0430\u043a \u043a\u0430\u043a \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0435 \u0434\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u044b, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u043e \u043c\u0430\u0448\u0438\u043d\u043d\u044b\u0445 \u043a\u043e\u0434\u043e\u0432. <\/p>\n<h1><a name=\"oop-in-nim\"><\/a>\u041a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u041e\u041e\u041f \u0432 Nim<\/h1>\n<p>  \u041a\u043e\u0434 \u043f\u0438\u0448\u0435\u0442\u0441\u044f \u0432 \u043c\u043e\u0434\u0443\u043b\u044f\u0445 (\u0442.\u0435. \u0432 \u0444\u0430\u0439\u043b\u0430\u0445, Python-style). \u041c\u043e\u0434\u0443\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u043e\u0434\u0443\u043b\u044f\u0445. \u0415\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (<b>proc<\/b>), \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043d\u0435\u0442. \u0417\u0430\u0442\u043e \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0442\u0438\u043f\u044b \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Uniform Function Call Syntax (<a href=\"https:\/\/en.wikipedia.org\/wiki\/Uniform_Function_Call_Syntax\">UFCS<\/a>) \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0438\u0445 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 2 \u0441\u0442\u0440\u043e\u043a\u0438 \u043a\u043e\u0434\u0430 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b:<\/p>\n<pre><code class=\"python\">foo(bar, baz) bar.foo(baz) <\/code><\/pre>\n<p>  \u0410 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u041e\u041e\u041f \u0431\u0435\u0437 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e\u043c \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430:<\/p>\n<pre><code class=\"python\">type     Game = object         foo: int         bar: string     Car = object         baz: int  # * \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u043f\u0440\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0435  # (\u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u044f) proc start*(self: Game) =      echo &quot;Starting game...&quot;  proc start*(self: Car) =      echo &quot;Starting car...&quot;  var game: Game var car: Car  game.start() car.start() <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b (<b>method<\/b>). \u0424\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u043e \u0436\u0435, \u0447\u0442\u043e \u0438 <b>proc<\/b>, \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043b\u0438\u0448\u044c \u0432 \u043c\u043e\u043c\u0435\u043d\u0442\u0435 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f. \u0412\u044b\u0437\u043e\u0432 <b>proc<\/b> \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0432\u044f\u0437\u0430\u043d, \u0442.\u0435. \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0442\u0438\u043f\u0435 \u0432 runtime \u0443\u0436\u0435 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043e\u0441\u043e\u0431\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <b>method<\/b> \u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u044c\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u0418 \u0434\u0430, Nim \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445, \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u043e\u0433\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f, \u0445\u043e\u0442\u044f \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0435\u043d\u0438\u0435 \u043e\u0442\u0434\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0438. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 <a href=\"http:\/\/nim-by-example.github.io\/oop\/\">\u0442\u0443\u0442<\/a> \u0438 <a href=\"http:\/\/goran.krampe.se\/2014\/10\/29\/nim-and-oo\/\">\u0442\u0443\u0442<\/a>.<\/p>\n<p>  \u0415\u0441\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u2014 \u0442\u0430\u043a\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u041e\u041e\u041f \u043d\u0435 \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0443 \u0432\u0441\u0435\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043a\u0430\u043a\u0438\u043c-\u043b\u0438\u0431\u043e \u0442\u0438\u043f\u043e\u043c \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u043e\u0434\u0443\u043b\u0435. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u043e\u043c\u0435\u0442\u0447\u0438\u0432\u043e \u0440\u0430\u0437\u0431\u0440\u043e\u0441\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043e\u0434\u043d\u0438\u043c \u0442\u0438\u043f\u043e\u043c \u043f\u043e \u0432\u0441\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435, \u0447\u0442\u043e, \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u043e \u0441\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0435 \u043a\u043e\u0434\u0430.<\/p>\n<h1><a name=\"underhood\"><\/a>\u041d\u0435\u043c\u043d\u043e\u0433\u043e C \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c<\/h1>\n<p>  \u0425\u043e\u0442\u044f Nim \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0434\u043e \u043f\u0440\u0435\u0434\u0435\u043b\u0430, \u043e\u043d \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u0443\u044e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e \u0432 C. \u0418 \u044d\u0442\u043e \u043a\u0440\u0443\u0442\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0431\u044d\u043a\u0433\u0440\u0430\u0443\u043d\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0447\u0442\u043e \u0436\u0435 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043a\u043e\u0434\u0435 \u043d\u0430 Nim. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440.<\/p>\n<p>  \u041e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 Nim \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 (\u0442.\u0435. \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0441\u0442\u0435\u043a\u0435) \u0438 \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438 (\u0442.\u0435. \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u0443\u0447\u0435). \u0421\u0441\u044b\u043b\u043a\u0438 \u0431\u044b\u0432\u0430\u044e\u0442 \u0434\u0432\u0443\u0445 \u0442\u0438\u043f\u043e\u0432 \u2014 <b>ref<\/b> \u0438 <b>ptr<\/b>. \u0421\u0441\u044b\u043b\u043a\u0438 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u043e\u043c \u043c\u0443\u0441\u043e\u0440\u0430 \u0438 \u043f\u0440\u0438 \u043d\u0443\u043b\u0435\u0432\u043e\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 ref count, \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0443\u0434\u0430\u043b\u044f\u044e\u0442\u0441\u044f \u0438\u0437 \u043a\u0443\u0447\u0438. \u0421\u0441\u044b\u043b\u043a\u0438 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u043c\u0438 \u0438 \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0432\u0441\u044f\u043a\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0448\u0442\u0443\u043a. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0441\u044b\u043b\u043a\u0438 \u0442\u0438\u043f\u0430 <b>ref<\/b>.<\/p>\n<p>  \u0422\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u0434\u043b\u044f Nim \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">type     Foo = ref FooObj     FooObj = object         bar: int         baz: string <\/code><\/pre>\n<p>  \u0422.\u0435. \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0442\u0438\u043f FooObj \u0438 \u0442\u0438\u043f \u00ab\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 FooObj\u00bb. \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430:<\/p>\n<pre><code class=\"python\">type     Foo = ref FooObj     FooObj = object         bar: int         baz: string  var foo = FooObj(bar: 1, baz: &quot;str_val1&quot;) var fooRef = Foo(bar: 2, baz: &quot;str_val2&quot;) <\/code><\/pre>\n<p>  \u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c:<\/p>\n<pre><code class=\"bash\">nim c -d:release test.nim cat .\/nimcache\/test.c <\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u043f\u0430\u043f\u043a\u0435 nimcache (test.c):<\/p>\n<pre><code>\/\/ ... typedef struct Fooobj89006 Fooobj89006; \/\/ ... struct  Fooobj89006  {  \/\/ \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 FooObj.      NI bar;     NimStringDesc* baz; }; \/\/ ... STRING_LITERAL(TMP5, &quot;str_val1&quot;, 8); STRING_LITERAL(TMP8, &quot;str_val2&quot;, 8); Fooobj89006 foo_89012; \/\/... N_CDECL(void, NimMainInner)(void) {     testInit(); }  N_CDECL(void, NimMain)(void) {     void (*volatile inner)();     PreMain();     inner = NimMainInner;     initStackBottomWith((void *)&inner);     (*inner)(); }  \/\/ \u041e\u0442\u0441\u044e\u0434\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442 \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 int main(int argc, char** args, char** env) {     cmdLine = args;     cmdCount = argc;     gEnv = env;     NimMain();  \/\/ \u044d\u0442\u043e &quot;\u0433\u043b\u0430\u0432\u043d\u0430\u044f&quot; \u0444\u0443\u043d\u043a\u0446\u0438\u044f Nim, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u044b\u0437\u043e\u0432 NimMainInner -&gt; testInit     return nim_program_result; }  NIM_EXTERNC N_NOINLINE(void, testInit)(void) {     Fooobj89006 LOC1;                                     \/\/ \u044d\u0442\u043e \u0431\u0443\u0434\u0443\u0449\u0430\u044f foo \u0438 \u043e\u043d\u0430 \u043d\u0430 \u0441\u0442\u0435\u043a\u0435     Fooobj89006* LOC2;                                    \/\/ \u044d\u0442\u043e fooRef \u0438 \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432 \u043a\u0443\u0447\u0435     NimStringDesc* LOC3;     memset((void*)(&LOC1), 0, sizeof(LOC1));     memset((void*)(&LOC1), 0, sizeof(LOC1));     LOC1.bar = ((NI) 1);     LOC1.baz = copyString(((NimStringDesc*) &TMP5));     foo_89012.bar = LOC1.bar;                              \/\/ \u044d\u0442\u043e foo     asgnRefNoCycle((void**) (&foo_89012.baz), LOC1.baz);     LOC2 = 0;     LOC2 = (Fooobj89006*) newObj((&NTI89004), sizeof(Fooobj89006));  \/\/ \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 \u043a\u0443\u0447\u0435 \u043f\u043e\u0434 fooRef     (*LOC2).bar = ((NI) 2);     LOC3 = 0;     LOC3 = (*LOC2).baz; (*LOC2).baz = copyStringRC1(((NimStringDesc*) &TMP8));     if (LOC3) nimGCunrefNoCycle(LOC3);     asgnRefNoCycle((void**) (&fooref_89017), LOC2); } <\/code><\/pre>\n<p>  \u0412\u044b\u0432\u043e\u0434\u044b \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043a\u043e\u0434 \u043f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u0438 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0436\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c. \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u0434\u043b\u044f \u0434\u0432\u0443\u0445 \u0442\u0438\u043f\u043e\u0432 <i>FooObj<\/i> \u0438 <i>Foo<\/i> \u0431\u044b\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0430 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0432 C. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 <i>foo<\/i> \u0438 <i>fooRef<\/i> \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u043c \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c \u043d\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u041a\u0430\u043a \u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, foo \u2014 \u0441\u0442\u0435\u043a\u043e\u0432\u0430\u044f \u043f\u0435\u0440\u043c\u0435\u043d\u043d\u0430\u044f, \u0430 fooRef \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043a\u0443\u0447\u0435.<\/p>\n<h1><a name=\"instances\"><\/a>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432<\/h1>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u0432 Nim \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0434\u0432\u0443\u043c\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043d\u0430 \u0441\u0442\u0435\u043a\u0435, \u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <i>initObjName<\/i>. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0432 \u043a\u0443\u0447\u0435 \u2014 <i>newObjName<\/i>.<\/p>\n<pre><code class=\"python\">type     Game* = ref GameObj     GameObj = object         score*: int  \/\/ result - \u044d\u0442\u043e \u043d\u0435\u044f\u0432\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u0441\u043b\u0443\u0436\u0430\u0449\u0430\u044f \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 proc newGame*(): Game =     result = Game(score: 0)  \/\/ \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0432\u044b\u0437\u043e\u0432\u0443 new(result)     result.doSomething()  proc initGame*(): GameObj =     GameObj(score: 0) <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0438\u0445 \u0442\u0438\u043f\u043e\u0432 (\u0432 \u043e\u0431\u0445\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0439-\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432) \u043d\u0435 \u043f\u0440\u0438\u043d\u044f\u0442\u043e.<\/p>\n<h1><a name=\"2048\"><\/a>2048<\/h1>\n<p>  \u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u0438\u0433\u0440\u044b \u0443\u043c\u0435\u0441\u0442\u0438\u043b\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432 300 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 \u043a\u043e\u0434\u0430. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0431\u0435\u0437 \u044f\u0432\u043d\u043e\u0439 \u0446\u0435\u043b\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043a\u043e\u0440\u043e\u0447\u0435. \u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u044d\u0442\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u044b\u0441\u043e\u043a\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u044f\u0437\u044b\u043a\u0430.<\/p>\n<p>  \u0421 \u0432\u044b\u0441\u043e\u0442\u044b \u043f\u0442\u0438\u0447\u044c\u0435\u0433\u043e \u043f\u043e\u043b\u0435\u0442\u0430 \u0438\u0433\u0440\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\"  src=\"https:\/\/habrastorage.org\/files\/a0a\/d55\/d69\/a0ad55d6947648569a12d465550e5be8.jpg\"\/><\/div>\n<p>  \u041a\u043e\u0434 \u00abmain\u00bb:<\/p>\n<pre><code class=\"python\">import os, strutils, net import field, render, game, input  const DefaultPort = 12321 let port = if paramCount() &gt; 0: parseInt(paramStr(1))           else: DefaultPort  var inputProcessor = initInputProcessor(port = Port(port)) var g = newGame()  while true:     render(g)     var command = inputProcessor.read()         case command:     of cmdRestart:         g.restart()     of cmdLeft:         g.left()     of cmdRight:         g.right()     of cmdUp:         g.up()     of cmdDown:         g.down()     of cmdExit:        echo &quot;Good buy!&quot;        break        <\/code><\/pre>\n<p>  \u041e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430 \u043f\u043e\u043b\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0439 \u0433\u0440\u0430\u0444\u0438\u043a\u0438 \u0438 \u0446\u0432\u0435\u0442\u043e\u0432\u044b\u0445 \u043a\u043e\u0434\u043e\u0432. \u0418\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e \u0438\u0433\u0440\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434 Linux \u0438 Mac OS. \u0412\u0432\u043e\u0434 \u043a\u043e\u043c\u0430\u043d\u0434 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 <i>getch()<\/i> \u0438\u0437-\u0437\u0430 \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 Nim. <a href=\"https:\/\/ru.wikipedia.org\/wiki\/Curses\">Curses<\/a> \u0434\u043b\u044f Nim \u0441\u0435\u0439\u0447\u0430\u0441 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 (\u0445\u043e\u0442\u044f \u043f\u0430\u043a\u0435\u0442 \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c \u0432\u0432\u043e\u0434\u0430\/\u0432\u044b\u0432\u043e\u0434\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u0447\u0442\u0435\u043d\u0438\u044f \u0438\u0437 \u0441\u043e\u043a\u0435\u0442\u0430 \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e python-\u043a\u043b\u0438\u0435\u043d\u0442\u0430.<\/p>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a \u044d\u0442\u043e\u0433\u043e \u0447\u0443\u0434\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"python\"># \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 1 git clone https:\/\/github.com\/Ostrovski\/nim-2048.git cd nim-2048 nim c -r nim2048  # \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 2 cd nim-2048 python client.py <\/code><\/pre>\n<p>  \u0427\u0442\u043e \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u0438\u0437 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u041a\u043e\u0434 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0438\u0448\u0435\u0442\u0441\u044f \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f! \u0422\u0430\u043a\u043e\u0433\u043e \u043e\u043f\u044b\u0442\u0430 \u0432 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445, \u043d\u0435 \u0441\u0447\u0438\u0442\u0430\u044f Java, \u044f \u043d\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b \u0434\u043e \u044d\u0442\u043e\u0433\u043e. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u00ab\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u043c\u00bb, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 <b>ptr<\/b>. \u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0438 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043e\u0447\u0435\u043d\u044c \u0441\u0438\u043b\u044c\u043d\u043e \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044e\u0442 Python, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0432\u044b\u043a\u0430\u043d\u0438\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f. \u0423 \u043c\u0435\u043d\u044f \u0443\u0436\u0435 \u0431\u044b\u043b\u0430 \u0433\u043e\u0442\u043e\u0432\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f 2048 \u043d\u0430 Python, \u0438 \u044f \u0431\u044b\u043b \u043f\u0440\u0438\u044f\u0442\u043d\u043e \u0443\u0434\u0438\u0432\u043b\u0435\u043d, \u043a\u043e\u0433\u0434\u0430 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u043a\u043e\u0434 \u0438\u0437 \u043d\u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u043a\u043e\u0434 \u043d\u0430 Nim \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438, \u0438 \u043e\u043d \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c! \u0415\u0449\u0435 \u043e\u0434\u0438\u043d \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u2014 Nim \u0438\u0434\u0435\u0442 \u0441 \u0431\u0430\u0442\u0430\u0440\u0435\u0439\u043a\u0430\u043c\u0438 \u0432 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0442\u0435. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u043e\u043c\u0443 \u043c\u043e\u0434\u0443\u043b\u044e <i>net<\/i> \u043a\u043e\u0434 <i>socket<\/i>-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 10 \u0441\u0442\u0440\u043e\u043a.<\/p>\n<p>  <u>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u0438\u0433\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 <a href=\"https:\/\/github.com\/Ostrovski\/nim-2048\">github<\/a>.<\/u><\/p>\n<h1><a name=\"conclusions\"><\/a>\u0412\u043c\u0435\u0441\u0442\u043e \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f<\/h1>\n<p>  Nim \u043a\u0440\u0430\u0441\u0430\u0432\u0447\u0438\u043a! \u041f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434 \u043d\u0430 \u043d\u0435\u043c \u043f\u0440\u0438\u044f\u0442\u043d\u043e, \u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u043e. \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f Nim \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b, \u043d\u043e \u0438 \u0432 JavaScript. \u041e\u0431 \u044d\u0442\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/github.com\/def-\/nimes\">\u0437\u0434\u0435\u0441\u044c<\/a>, \u0430 \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c \u0432 \u044d\u043c\u0443\u043b\u044f\u0442\u043e\u0440 NES, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 Nim \u0438 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0432 JavaScript \u2014 <a href=\"http:\/\/hookrace.net\/nimes\/\">\u0437\u0434\u0435\u0441\u044c<\/a>. <\/p>\n<p>  \u0425\u043e\u0447\u0435\u0442\u0441\u044f \u043d\u0430\u0434\u0435\u044f\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f Nim \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0431\u044b\u0441\u0442\u0440\u044b\u0445 \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0441\u0442\u0430\u043d\u0435\u0442 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0436\u0435 \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c, \u043a\u0430\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 Python, \u0438 \u044d\u0442\u043e \u0431\u043b\u0430\u0433\u043e\u043f\u0440\u0438\u044f\u0442\u043d\u043e \u043e\u0442\u0440\u0430\u0437\u0438\u0442\u0441\u044f \u043d\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0447\u0430\u0441\u043e\u0432, \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043c\u044b\u0445 \u043d\u0430\u043c\u0438 \u043f\u0435\u0440\u0435\u0434 \u0440\u0430\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441-\u0431\u0430\u0440\u0430\u043c\u0438 \u0437\u0430 \u043d\u0430\u0448\u0438\u043c\u0438 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430\u043c\u0438.     \t<\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/261801\/\"> http:\/\/habrahabr.ru\/post\/261801\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>     \t<img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/657\/f1c\/9fd\/657f1c9fd89b46f485d3be8fe0e9ad24.jpg\" align=\"right\"\/><br \/>  \u0425\u043e\u0447\u0435\u0442\u0441\u044f \u0447\u0435\u0433\u043e-\u0442\u043e \u043d\u043e\u0432\u043e\u0433\u043e, \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e, \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0433\u043e \u043d\u0430 \u043e\u0449\u0443\u043f? \u0414\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434 \u043a\u0430\u0442, \u0433\u0434\u0435 \u043c\u044b \u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Nim \u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0433\u043e \u043a\u043b\u043e\u043d\u0430 \u0438\u0433\u0440\u044b 2048. \u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043e\u0432, \u0442\u043e\u043b\u044c\u043a\u043e \u0445\u0430\u0440\u0434\u043a\u043e\u0440, \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430!<\/p>\n<p>  \u0412 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435:  <\/p>\n<ul>\n<li><a href=\"#who-is-nim\">Who is the Nim?<\/a><\/li>\n<li><a href=\"#oop-in-nim\">\u041a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u041e\u041e\u041f \u0432 Nim<\/a><\/li>\n<li><a href=\"#underhood\">\u041d\u0435\u043c\u043d\u043e\u0433\u043e C \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c<\/a><\/li>\n<li><a href=\"#instances\">\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432<\/a><\/li>\n<li><a href=\"#2048\">\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438\u0433\u0440\u0430 2048<\/a> (<a href=\"https:\/\/github.com\/Ostrovski\/nim-2048\">github<\/a>)<\/li>\n<li><a href=\"#conclusions\">\u0421\u0443\u0431\u044a\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0432\u044b\u0432\u043e\u0434\u044b<\/a><\/li>\n<\/ul>\n<p>  <\/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-260750","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/260750","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=260750"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/260750\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=260750"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=260750"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=260750"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}