1
0
mirror of https://github.com/osmarks/website synced 2024-12-24 09:00:30 +00:00
website/experiments/game-of-life/out.js

1 line
103 KiB
JavaScript
Raw Normal View History

2020-03-08 17:13:14 +00:00
!function(O){var n={};function r(t){if(n[t])return n[t].exports;var e=n[t]={i:t,l:!1,exports:{}};return O[t].call(e.exports,e,e.exports,r),e.l=!0,e.exports}r.m=O,r.c=n,r.d=function(O,n,t){r.o(O,n)||Object.defineProperty(O,n,{enumerable:!0,get:t})},r.r=function(O){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(O,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(O,"__esModule",{value:!0})},r.t=function(O,n){if(1&n&&(O=r(O)),8&n)return O;if(4&n&&"object"==typeof O&&O&&O.__esModule)return O;var t=Object.create(null);if(r.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:O}),2&n&&"string"!=typeof O)for(var e in O)r.d(t,e,function(n){return O[n]}.bind(null,e));return t},r.n=function(O){var n=O&&O.__esModule?function(){return O.default}:function(){return O};return r.d(n,"a",n),n},r.o=function(O,n){return Object.prototype.hasOwnProperty.call(O,n)},r.p="",r(r.s=0)}([function(O,n,r){"use strict";r.r(n);var t=r(1),e=r.n(t);document.addEventListener("DOMContentLoaded",function(O){e.a.main(document.getElementById("app"))})},function(O,n,r){"use strict";var t=r(2),e=r(3),i=r(22),u=r(8),a=r(33),o=r(39),c=r(40),f=r(41),_=r(42);function l(O,n){var r=O[1],t=O[0];switch(n){case 0:return[t,r+1|0];case 1:return[t+1|0,r];case 2:return[t,r-1|0];case 3:return[t-1|0,r]}}function s(){return[[t.random_grid(20,20)],o.none]}function m(O,n){if("number"!=typeof n)return n.tag?[[t.Grid[9](1,l(t.Grid[10](O[0]),n[0]),O[0])],o.none]:[[t.Grid[6](t.invert_cell,[n[0],n[1]])(O[0])],o.none];switch(n){case 0:return[[t.step(O[0])],o.none];case 1:return[[f.random(0)],o.none];case 2:return[[t.random_grid(t.Grid[0](O[0]),t.Grid[1](O[0]))],o.none]}}function v(O,n,r){var t=_.onClick(u.__(0,[O,n]));return r?_.td(0,0,[_.class$prime("off"),[t,0]],0):_.td(0,0,[_.class$prime("on"),[t,0]],0)}function d(O){return _.table(0,0,0,e.map(function(O){return _.tr(0,0,0,O)},i.to_list(i.map(i.to_list,t.Grid[4](v)(O)))))}function g(O,n){return _.button(0,0,[_.onClick(O),0],[_.text(n),0])}function h(O){return _.div(0,0,0,[d(O[0]),[g(0,"Step"),[g(1,"Random Pattern"),[g(2,"Random Fill"),[g(u.__(1,[0]),"+W"),[g(u.__(1,[1]),"+H"),[g(u.__(1,[2]),"-W"),[g(u.__(1,[3]),"-H"),0]]]]]]]])}var p=[s,m,h,function(){return c.none}];n.toggleCell=function(O,n){return u.__(0,[O,n])},n.step=0,n.randomPattern=1,n.randomFill=2,n.dimensionChange=function(O){return u.__(1,[O])},n.new_dims=l,n.init=s,n.update=m,n.view_cell=v,n.view_grid=d,n.btn=g,n.view=h,n.main=function(O,n){return a.standardProgram(p,O,n)}},function(O,n,r){"use strict";var t=r(3),e=r(22),i=r(4),u=r(24),a=r(5),o=r(15);function c(O,n){return o.mod_(O+n|0,n)}function f(O,n){return a.caml_array_get(a.caml_array_get(O,c(n[0],O.length)),c(n[1],a.caml_array_get(O,0).length))}function _(O){return function(n){return e.mapi(function(n,r){return e.mapi(function(r,t){return i._3(O,n,r,t)},r)},n)}}function l(O){return function(n){return e.iteri(function(n){return function(r){return e.iteri(function(r,t){return i._3(O,n,r,t)},r)}},n)}}function s(O,n){return[O[0]+n[0]|0,O[1]+n[1]|0]}function m(O,n,r){return _(function(n,r,t){return i._2(O,n,r)})(e.make_matrix(n,r,0))}var v=[function(O){return O.length},function(O){return a.caml_array_get(O,0).length},f,function(O){return function(n){return e.map(function(n){return e.map(O,n)},n)}},_,l,function(O,n){var r=n[1],t=n[0];return _(function(n,e,u){return t===n&&r===e?i._1(O,u):u})},s,m,function(O,n,r){var t=n[1],i=n[0],u=e.make_matrix(i,t,O);return l(function(O,n,r){return O<i&&n<t?a.caml_array_set(a.caml_array_get(u,O),n,r):0})(r),u},function(O){return[O.length,a.caml_array_get(O,0).length]}];var d=[[0,1],[[1,0],[[1,1],[[0,-1],[[-1,0],[[-1,-1],[[1,-1],[[-1,1],0]]]]]]]];function g(O,n){return t.map(function(r){return f(O,s(r,n))},d)}function h(O,n){return t.length(t.filter(function(O){return 0===O})(g(O,n)))}function p(O,n){return O?3===n?0:1:2===n||3===n?0:1}n.wraparound=c,n.Grid=v,n.cell_of_bool=function(O){return O?0:1},n.invert_cell=function(O){return O?0:1},n.random_cell=function(){return u.bool(0)?0:1},n.neighbour_positions=d,n.neighbours=g,n.live_neighbours=h,n.