{"id":25261,"date":"2016-09-17T02:13:36","date_gmt":"2016-09-17T07:13:36","guid":{"rendered":"http:\/\/www.dannyadam.com\/blog\/?p=25261"},"modified":"2020-04-18T13:51:20","modified_gmt":"2020-04-18T17:51:20","slug":"conways-game-of-life","status":"publish","type":"post","link":"https:\/\/www.dannyadam.com\/blog\/2016\/09\/conways-game-of-life\/","title":{"rendered":"Conway&#8217;s Game of Life"},"content":{"rendered":"\n<p>Here&#8217;s a <em>quick-and-dirty<\/em> implementation of <a href=\"https:\/\/en.wikipedia.org\/wiki\/Conway%27s_Game_of_Life\">Conway&#8217;s Game of Life<\/a>.<\/p>\n\n\n\n<p>Cells can be selected\/deselected by clicking and dragging your mouse. The interface and display were designed for use with a desktop\/laptop computer, not a touchscreen mobile device. That is, cells can&#8217;t be selected by swiping (but tapping works).<\/p>\n\n\n\n<p>The default selected cells spell my first name, <em>daniel<\/em>. After selecting cells, click <em>Start<\/em> to begin the <em>game of life<\/em>.<\/p>\n\n\n\n<iframe id=\"conway\" src=\"https:\/\/www.dannyadam.com\/blog\/wp-content\/uploads\/2016\/09\/conway.html\" scrolling=\"no\" width=\"100%\" frameborder=\"0\"><\/iframe>\n<script type=\"text\/javascript\">\n  var resize = function() {\n    var conway = document.getElementById(\"conway\");\n    if (conway\n       && conway.getBoundingClientRect()\n       && conway.contentDocument\n       && conway.contentDocument.body\n       && conway.contentDocument.body.style\n       && conway.contentDocument.body.getBoundingClientRect()) {\n        if (!conway.contentDocument.body.hasAttribute('data-scale'))\n          conway.contentDocument.body.setAttribute('data-scale', 1)\n        conway.contentDocument.body.style.transformOrigin = 'top left';\n        var width1 = conway.getBoundingClientRect().width;\n        var width2 = conway.contentDocument.body.getBoundingClientRect().width;\n        var scale = width1 \/ width2;\n        scale *= conway.contentDocument.body.getAttribute('data-scale');\n        conway.contentDocument.body.setAttribute('data-scale', scale)\n        conway.contentDocument.body.style.transform = 'scale(' + scale + ')';\n        var height = conway.contentDocument.body.getBoundingClientRect().height;\n        conway.height = Math.ceil(height) + \"px\";\n    }\n  }\n  var t=setInterval(function() {\n      resize();\n  }, 200);\n<\/script>\n\n\n\n<p>The source code is available <a href=\"https:\/\/www.dannyadam.com\/blog\/wp-content\/uploads\/2016\/09\/conway.html\">here<\/a> (use your browser&#8217;s <em>view source<\/em>).<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s a quick-and-dirty implementation of Conway&#8217;s Game of Life. Cells can be selected\/deselected by clicking and dragging your mouse. The interface and display were designed for use with a desktop\/laptop computer, not a touchscreen mobile device. That is, cells can&#8217;t be selected by swiping (but tapping works). The default selected cells spell my first name, [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[47],"class_list":["post-25261","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-conways-game-of-life"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1sCC6-6zr","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.dannyadam.com\/blog\/wp-json\/wp\/v2\/posts\/25261","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dannyadam.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dannyadam.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dannyadam.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dannyadam.com\/blog\/wp-json\/wp\/v2\/comments?post=25261"}],"version-history":[{"count":189,"href":"https:\/\/www.dannyadam.com\/blog\/wp-json\/wp\/v2\/posts\/25261\/revisions"}],"predecessor-version":[{"id":26536,"href":"https:\/\/www.dannyadam.com\/blog\/wp-json\/wp\/v2\/posts\/25261\/revisions\/26536"}],"wp:attachment":[{"href":"https:\/\/www.dannyadam.com\/blog\/wp-json\/wp\/v2\/media?parent=25261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dannyadam.com\/blog\/wp-json\/wp\/v2\/categories?post=25261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dannyadam.com\/blog\/wp-json\/wp\/v2\/tags?post=25261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}