diff --git a/10.bootstrap.js b/10.bootstrap.js index 9f057b2..71e40f0 100644 --- a/10.bootstrap.js +++ b/10.bootstrap.js @@ -1,2 +1,2 @@ -(self.webpackChunkdraught=self.webpackChunkdraught||[]).push([[10],{171:(t,e,r)=>{"use strict";r.a(t,(async n=>{r.d(e,{wc:()=>k,SZ:()=>T,Tt:()=>O,rh:()=>E,lA:()=>I,Ck:()=>q,ug:()=>A,h4:()=>U,h9:()=>W,Dz:()=>M,kF:()=>$,s8:()=>D,WB:()=>J,cP:()=>P,a:()=>R,l_:()=>z,U_:()=>F,EN:()=>N,qu:()=>Y,Wg:()=>K,B3:()=>L,I6:()=>Q,Qb:()=>X,cI:()=>H,QK:()=>Z,Md:()=>G,ox:()=>V,ES:()=>tt,Ae:()=>et,UL:()=>rt,qw:()=>nt,tS:()=>_t,R$:()=>at,md:()=>ct,IF:()=>it,XP:()=>ot,m_:()=>st,fY:()=>ut,Or:()=>pt});var _=r(813);t=r.hmd(t);var a=n([_]);_=(a.then?await a:a)[0];const c=new Array(32).fill(void 0);function i(t){return c[t]}c.push(void 0,null,!0,!1);let o=c.length;let s=new("undefined"==typeof TextDecoder?(0,t.require)("util").TextDecoder:TextDecoder)("utf-8",{ignoreBOM:!0,fatal:!0});s.decode();let u=null;function p(){return null!==u&&u.buffer===_.memory.buffer||(u=new Uint8Array(_.memory.buffer)),u}function l(t,e){return s.decode(p().subarray(t,t+e))}function d(t){o===c.length&&c.push(c.length+1);const e=o;return o=c[e],c[e]=t,e}function b(t){const e=typeof t;if("number"==e||"boolean"==e||null==t)return`${t}`;if("string"==e)return`"${t}"`;if("symbol"==e){const e=t.description;return null==e?"Symbol":`Symbol(${e})`}if("function"==e){const e=t.name;return"string"==typeof e&&e.length>0?`Function(${e})`:"Function"}if(Array.isArray(t)){const e=t.length;let r="[";e>0&&(r+=b(t[0]));for(let n=1;n1))return toString.call(t);if(n=r[1],"Object"==n)try{return"Object("+JSON.stringify(t)+")"}catch(t){return"Object"}return t instanceof Error?`${t.name}: ${t.message}\n${t.stack}`:n}let g=0,w=new("undefined"==typeof TextEncoder?(0,t.require)("util").TextEncoder:TextEncoder)("utf-8");const f="function"==typeof w.encodeInto?function(t,e){return w.encodeInto(t,e)}:function(t,e){const r=w.encode(t);return e.set(r),{read:t.length,written:r.length}};function h(t,e,r){if(void 0===r){const r=w.encode(t),n=e(r.length);return p().subarray(n,n+r.length).set(r),g=r.length,n}let n=t.length,_=e(n);const a=p();let c=0;for(;c127)break;a[_+c]=e}if(c!==n){0!==c&&(t=t.slice(c)),_=r(_,n,n=c+3*t.length);const e=p().subarray(_+c,_+n);c+=f(t,e).written}return g=c,_}let m=null;function v(){return null!==m&&m.buffer===_.memory.buffer||(m=new Int32Array(_.memory.buffer)),m}function y(t){return null==t}function x(t,e){if(!(t instanceof e))throw new Error(`expected instance of ${e.name}`);return t.ptr}function k(){_.init_wasm()}function j(t,e){try{return t.apply(this,e)}catch(t){_.__wbindgen_exn_store(d(t))}}Object.freeze({Move:0,0:"Move",Jump:1,1:"Jump"});const T=Object.freeze({Black:0,0:"Black",White:1,1:"White"}),O=(Object.freeze({Man:0,0:"Man",King:1,1:"King"}),Object.freeze({Empty:0,0:"Empty",Occupied:1,1:"Occupied",Unplayable:2,2:"Unplayable"}),Object.freeze({Allowed:0,0:"Allowed",UnoccupiedSrc:1,1:"UnoccupiedSrc",OccupiedDest:2,2:"OccupiedDest",OutOfBounds:3,3:"OutOfBounds",Unplayable:4,4:"Unplayable",WrongTeamSrc:5,5:"WrongTeamSrc",IllegalTrajectory:6,6:"IllegalTrajectory",NoJumpablePiece:7,7:"NoJumpablePiece",JumpingSameTeam:8,8:"JumpingSameTeam"}));class S{static __wrap(t){const e=Object.create(S.prototype);return e.ptr=t,e}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();_.__wbg_board_free(t)}get width(){return _.__wbg_get_board_width(this.ptr)>>>0}set width(t){_.__wbg_set_board_width(this.ptr,t)}get height(){return _.__wbg_get_board_height(this.ptr)>>>0}set height(t){_.__wbg_set_board_height(this.ptr,t)}get current_turn(){return _.__wbg_get_board_current_turn(this.ptr)>>>0}set current_turn(t){_.__wbg_set_board_current_turn(this.ptr,t)}cell(t){var e=_.board_cell(this.ptr,t);return C.__wrap(e)}set_cell(t,e){x(e,C);var r=e.ptr;e.ptr=0,_.board_set_cell(this.ptr,t,r)}grid_cell(t){x(t,E);var e=t.ptr;t.ptr=0;var r=_.board_grid_cell(this.ptr,e);return C.__wrap(r)}cell_index(t,e){return _.board_cell_index(this.ptr,t,e)>>>0}cell_idx(t){x(t,E);var e=t.ptr;return t.ptr=0,_.board_cell_idx(this.ptr,e)>>>0}board_index(t){var e=_.board_board_index(this.ptr,t);return E.__wrap(e)}can_move(t,e){x(t,E);var r=t.ptr;t.ptr=0,x(e,E);var n=e.ptr;return e.ptr=0,_.board_can_move(this.ptr,r,n)>>>0}validate_man_move(t,e,r){x(t,E);var n=t.ptr;t.ptr=0,x(e,E);var a=e.ptr;e.ptr=0,x(r,B);var c=r.ptr;return r.ptr=0,_.board_validate_man_move(this.ptr,n,a,c)>>>0}validate_king_move(t,e,r){x(t,E);var n=t.ptr;t.ptr=0,x(e,E);var a=e.ptr;e.ptr=0,x(r,B);var c=r.ptr;return r.ptr=0,_.board_validate_king_move(this.ptr,n,a,c)>>>0}jumpee_idx(t,e){x(t,E);var r=t.ptr;t.ptr=0,x(e,E);var n=e.ptr;return e.ptr=0,_.board_jumpee_idx(this.ptr,r,n)>>>0}cells(){return _.board_cells(this.ptr)}num_cells(){return _.board_num_cells(this.ptr)>>>0}num_pieces(){return _.board_num_pieces(this.ptr)>>>0}num_player(t){return _.board_num_player(this.ptr,t)>>>0}score(){return _.board_score(this.ptr)}cell_state(t){return _.board_cell_state(this.ptr,t)>>>0}apply_move(t,e){x(t,E);var r=t.ptr;t.ptr=0,x(e,E);var n=e.ptr;e.ptr=0;var a=_.board_apply_move(this.ptr,r,n);return S.__wrap(a)}apply_jump(t,e){x(t,E);var r=t.ptr;t.ptr=0,x(e,E);var n=e.ptr;e.ptr=0;var a=_.board_apply_jump(this.ptr,r,n);return S.__wrap(a)}static validate_jumpee(t,e){x(t,C);var r=t.ptr;t.ptr=0,x(e,B);var n=e.ptr;return e.ptr=0,_.board_validate_jumpee(r,n)>>>0}static check_jumpee_team(t,e){x(t,B);var r=t.ptr;t.ptr=0,x(e,B);var n=e.ptr;return e.ptr=0,0!==_.board_check_jumpee_team(r,n)}constructor(t,e,r){var n=_.board_new(t,e,r);return S.__wrap(n)}static init_game(t,e){x(t,S);var r=t.ptr;t.ptr=0;var n=_.board_init_game(r,e);return S.__wrap(n)}}class E{static __wrap(t){const e=Object.create(E.prototype);return e.ptr=t,e}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();_.__wbg_brdidx_free(t)}get row(){return _.__wbg_get_brdidx_row(this.ptr)>>>0}set row(t){_.__wbg_set_brdidx_row(this.ptr,t)}get col(){return _.__wbg_get_brdidx_col(this.ptr)>>>0}set col(t){_.__wbg_set_brdidx_col(this.ptr,t)}constructor(t,e){var r=_.brdidx_from(t,e);return E.__wrap(r)}}class I{static __wrap(t){const e=Object.create(I.prototype);return e.ptr=t,e}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();_.__wbg_game_free(t)}current_board_cells(){return _.game_current_board_cells(this.ptr)}current_board_len(){return _.game_current_board_len(this.ptr)>>>0}current_turn(){return _.game_current_turn(this.ptr)>>>0}make_move(t,e){x(t,E);var r=t.ptr;t.ptr=0,x(e,E);var n=e.ptr;return e.ptr=0,_.game_make_move(this.ptr,r,n)>>>0}execute_move(t,e){x(t,E);var r=t.ptr;t.ptr=0,x(e,E);var n=e.ptr;e.ptr=0,_.game_execute_move(this.ptr,r,n)}execute_jump(t,e){x(t,E);var r=t.ptr;t.ptr=0,x(e,E);var n=e.ptr;e.ptr=0,_.game_execute_jump(this.ptr,r,n)}push_new_board(t){x(t,S);var e=t.ptr;t.ptr=0,_.game_push_new_board(this.ptr,e)}set_current(t){x(t,S);var e=t.ptr;t.ptr=0,_.game_set_current(this.ptr,e)}constructor(t,e,r,n){var a=_.game_new(t,e,r,n);return I.__wrap(a)}static new_with_canvas(t,e,r,n,a,c,i){var o=h(a,_.__wbindgen_malloc,_.__wbindgen_realloc),s=g,u=_.game_new_with_canvas(t,e,r,n,o,s,c,i);return I.__wrap(u)}set_painter(t){x(t,q);var e=t.ptr;t.ptr=0,_.game_set_painter(this.ptr,e)}draw(){_.game_draw(this.ptr)}}class q{static __wrap(t){const e=Object.create(q.prototype);return e.ptr=t,e}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();_.__wbg_painter_free(t)}constructor(t,e,r){var n=h(r,_.__wbindgen_malloc,_.__wbindgen_realloc),a=g,c=_.painter_new(t,e,n,a);return q.__wrap(c)}static new_with_canvas(t,e,r){var n=_.painter_new_with_canvas(t,e,d(r));return q.__wrap(n)}set_square_outline(t){_.painter_set_square_outline(this.ptr,d(t))}set_outline_width(t){_.painter_set_outline_width(this.ptr,t)}set_draw_outline(t){_.painter_set_draw_outline(this.ptr,t)}reset_dimensions(){_.painter_reset_dimensions(this.ptr)}validate_board_dim(t){return x(t,S),0!==_.painter_validate_board_dim(this.ptr,t.ptr)}draw(t){x(t,S),_.painter_draw(this.ptr,t.ptr)}}class B{static __wrap(t){const e=Object.create(B.prototype);return e.ptr=t,e}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();_.__wbg_piece_free(t)}get team(){return _.__wbg_get_piece_team(this.ptr)>>>0}set team(t){_.__wbg_set_piece_team(this.ptr,t)}get strength(){return _.__wbg_get_piece_strength(this.ptr)>>>0}set strength(t){_.__wbg_set_piece_strength(this.ptr,t)}constructor(t,e){var r=_.piece_new(t,e);return B.__wrap(r)}}class C{static __wrap(t){const e=Object.create(C.prototype);return e.ptr=t,e}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();_.__wbg_square_free(t)}get occupant(){var t=_.__wbg_get_square_occupant(this.ptr);return 0===t?void 0:B.__wrap(t)}set occupant(t){let e=0;y(t)||(x(t,B),e=t.ptr,t.ptr=0),_.__wbg_set_square_occupant(this.ptr,e)}get state(){return _.__wbg_get_square_state(this.ptr)>>>0}set state(t){_.__wbg_set_square_state(this.ptr,t)}constructor(t,e){let r=0;y(e)||(x(e,B),r=e.ptr,e.ptr=0);var n=_.square_new(t,r);return C.__wrap(n)}static pc(t,e){var r=_.square_pc(t,e);return C.__wrap(r)}static empty(){var t=_.square_empty();return C.__wrap(t)}static unplay(){var t=_.square_unplay();return C.__wrap(t)}}function A(t){!function(t){const e=i(t);(function(t){t<36||(c[t]=o,o=t)})(t)}(t)}function U(t,e){return d(l(t,e))}function W(){return d(new Error)}function M(t,e){var r=h(i(e).stack,_.__wbindgen_malloc,_.__wbindgen_realloc),n=g;v()[t/4+1]=n,v()[t/4+0]=r}function $(t,e){try{console.error(l(t,e))}finally{_.__wbindgen_free(t,e)}}function D(t){return i(t)instanceof Window}function J(t){var e=i(t).document;return y(e)?0:d(e)}function P(t,e,r){var n=i(t).getElementById(l(e,r));return y(n)?0:d(n)}function R(t){console.log(i(t))}function z(t){return i(t)instanceof CanvasRenderingContext2D}function F(t,e){i(t).strokeStyle=i(e)}function N(t,e){i(t).fillStyle=i(e)}function Y(t,e){i(t).lineWidth=e}function K(t){i(t).beginPath()}function L(t){i(t).fill()}function Q(t){i(t).stroke()}function X(){return j((function(t,e,r,n,_,a){i(t).arc(e,r,n,_,a)}),arguments)}function H(t,e,r,n,_){i(t).fillRect(e,r,n,_)}function Z(t,e,r,n,_){i(t).strokeRect(e,r,n,_)}function G(t){return i(t)instanceof HTMLCanvasElement}function V(t,e){i(t).width=e>>>0}function tt(t,e){i(t).height=e>>>0}function et(){return j((function(t,e,r){var n=i(t).getContext(l(e,r));return y(n)?0:d(n)}),arguments)}function rt(t,e){return d(new Function(l(t,e)))}function nt(){return j((function(t,e){return d(i(t).call(i(e)))}),arguments)}function _t(){return j((function(){return d(self.self)}),arguments)}function at(){return j((function(){return d(window.window)}),arguments)}function ct(){return j((function(){return d(globalThis.globalThis)}),arguments)}function it(){return j((function(){return d(r.g.global)}),arguments)}function ot(t){return void 0===i(t)}function st(t){return d(i(t))}function ut(t,e){var r=h(b(i(e)),_.__wbindgen_malloc,_.__wbindgen_realloc),n=g;v()[t/4+1]=n,v()[t/4+0]=r}function pt(t,e){throw new Error(l(t,e))}}))},813:(t,e,r)=>{"use strict";var n=([n])=>r.v(e,t.id,"4ee49dc6adc51094e53f",{"./draught_bg.js":{__wbindgen_object_drop_ref:n.ug,__wbindgen_string_new:n.h4,__wbg_new_59cb74e423758ede:n.h9,__wbg_stack_558ba5917b466edd:n.Dz,__wbg_error_4bb6c2a97407129a:n.kF,__wbg_instanceof_Window_11e25482011fc506:n.s8,__wbg_document_5aff8cd83ef968f5:n.WB,__wbg_getElementById_b180ea4ada06a837:n.cP,__wbg_log_9a99fb1af846153b:n.a,__wbg_instanceof_CanvasRenderingContext2d_779e79c4121aa91b:n.l_,__wbg_setstrokeStyle_2939ee453716e462:n.U_,__wbg_setfillStyle_af790b5baf4d3210:n.EN,__wbg_setlineWidth_3e6b1837ae38d099:n.qu,__wbg_beginPath_2378575e37027ad3:n.Wg,__wbg_fill_558339447ed6ad43:n.B3,__wbg_stroke_c1e0313c58997dcf:n.I6,__wbg_arc_fffd87d9113dce32:n.Qb,__wbg_fillRect_46ffc8d2cef7e298:n.cI,__wbg_strokeRect_7ea34fad8a7f0fe2:n.QK,__wbg_instanceof_HtmlCanvasElement_fd3cbbe3906d7792:n.Md,__wbg_setwidth_f3c88eb520ba8d47:n.ox,__wbg_setheight_5a1abba41e35c42a:n.ES,__wbg_getContext_813df131fcbd6e91:n.Ae,__wbg_newnoargs_9fdd8f3961dd1bee:n.UL,__wbg_call_ba36642bd901572b:n.qw,__wbg_self_bb69a836a72ec6e9:n.tS,__wbg_window_3304fc4b414c9693:n.R$,__wbg_globalThis_e0d21cabc6630763:n.md,__wbg_global_8463719227271676:n.IF,__wbindgen_is_undefined:n.XP,__wbindgen_object_clone_ref:n.m_,__wbindgen_debug_string:n.fY,__wbindgen_throw:n.Or}});r.a(t,(t=>{var e=t([r(171)]);return e.then?e.then(n):n(e)}),1)},10:(t,e,r)=>{"use strict";r.a(t,(async t=>{r.r(e);var n=r(171),_=t([n]);n=(_.then?await _:_)[0];const a="human_turn.thinking",c="human_turn.from_selected";(0,n.wc)();const i=document.getElementById("status-p");let o=a,s=new n.Ck(480,480,"game-canvas"),u=null,p=null,l=new n.lA(8,8,3,n.SZ.Black);l.set_painter(s),l.draw();const d=document.getElementById("game-canvas");d.addEventListener("click",(t=>{var e=function(t,e){var r=t.getBoundingClientRect();return{x:e.clientX-r.left,y:e.clientY-r.top}}(d,t);!function(t){switch(o){case a:console.log("Your turn, first piece picked"),u=t,o=c;break;case c:if(console.log("Your turn, first piece already picked, picking second"),p=t,u.col==p.col&&u.row==p.row)"Move Cancelled",i.hidden=!1,i.innerText="Move Cancelled";else{let t=l.make_move(u,p);if(t==n.Tt.Allowed);else switch(t){case n.Tt.Allowed:case n.Tt.IllegalTrajectory:case n.Tt.JumpingSameTeam:case n.Tt.NoJumpablePiece:case n.Tt.OccupiedDest:case n.Tt.OutOfBounds:case n.Tt.UnoccupiedSrc:case n.Tt.Unplayable:case n.Tt.WrongTeamSrc:}}l.draw(),u=null,p=null,o=a;break;case"ai_turn":console.log("It's the AI's turn!")}}(new n.rh(Math.floor(e.y/480*8),Math.floor(e.x/480*8)))}))}))}}]); +(self.webpackChunkdraught=self.webpackChunkdraught||[]).push([[10],{171:(t,e,r)=>{"use strict";r.a(t,(async n=>{r.d(e,{wc:()=>x,SZ:()=>T,Tt:()=>O,rh:()=>E,lA:()=>q,Ck:()=>I,ug:()=>A,h4:()=>U,h9:()=>W,Dz:()=>$,kF:()=>M,s8:()=>D,WB:()=>J,cP:()=>P,a:()=>R,l_:()=>z,U_:()=>F,EN:()=>N,qu:()=>Y,Wg:()=>K,B3:()=>L,I6:()=>Q,Qb:()=>X,cI:()=>H,QK:()=>Z,Md:()=>G,ox:()=>V,ES:()=>tt,Ae:()=>et,UL:()=>rt,qw:()=>nt,tS:()=>_t,R$:()=>at,md:()=>ct,IF:()=>it,XP:()=>ot,m_:()=>st,fY:()=>ut,Or:()=>pt});var _=r(813);t=r.hmd(t);var a=n([_]);_=(a.then?await a:a)[0];const c=new Array(32).fill(void 0);function i(t){return c[t]}c.push(void 0,null,!0,!1);let o=c.length;let s=new("undefined"==typeof TextDecoder?(0,t.require)("util").TextDecoder:TextDecoder)("utf-8",{ignoreBOM:!0,fatal:!0});s.decode();let u=null;function p(){return null!==u&&u.buffer===_.memory.buffer||(u=new Uint8Array(_.memory.buffer)),u}function l(t,e){return s.decode(p().subarray(t,t+e))}function d(t){o===c.length&&c.push(c.length+1);const e=o;return o=c[e],c[e]=t,e}function b(t){const e=typeof t;if("number"==e||"boolean"==e||null==t)return`${t}`;if("string"==e)return`"${t}"`;if("symbol"==e){const e=t.description;return null==e?"Symbol":`Symbol(${e})`}if("function"==e){const e=t.name;return"string"==typeof e&&e.length>0?`Function(${e})`:"Function"}if(Array.isArray(t)){const e=t.length;let r="[";e>0&&(r+=b(t[0]));for(let n=1;n1))return toString.call(t);if(n=r[1],"Object"==n)try{return"Object("+JSON.stringify(t)+")"}catch(t){return"Object"}return t instanceof Error?`${t.name}: ${t.message}\n${t.stack}`:n}let g=0,f=new("undefined"==typeof TextEncoder?(0,t.require)("util").TextEncoder:TextEncoder)("utf-8");const w="function"==typeof f.encodeInto?function(t,e){return f.encodeInto(t,e)}:function(t,e){const r=f.encode(t);return e.set(r),{read:t.length,written:r.length}};function h(t,e,r){if(void 0===r){const r=f.encode(t),n=e(r.length);return p().subarray(n,n+r.length).set(r),g=r.length,n}let n=t.length,_=e(n);const a=p();let c=0;for(;c127)break;a[_+c]=e}if(c!==n){0!==c&&(t=t.slice(c)),_=r(_,n,n=c+3*t.length);const e=p().subarray(_+c,_+n);c+=w(t,e).written}return g=c,_}let m=null;function v(){return null!==m&&m.buffer===_.memory.buffer||(m=new Int32Array(_.memory.buffer)),m}function y(t){return null==t}function k(t,e){if(!(t instanceof e))throw new Error(`expected instance of ${e.name}`);return t.ptr}function x(){_.init_wasm()}function j(t,e){try{return t.apply(this,e)}catch(t){_.__wbindgen_exn_store(d(t))}}Object.freeze({Move:0,0:"Move",Jump:1,1:"Jump"});const T=Object.freeze({Black:0,0:"Black",White:1,1:"White"}),O=(Object.freeze({Man:0,0:"Man",King:1,1:"King"}),Object.freeze({Empty:0,0:"Empty",Occupied:1,1:"Occupied",Unplayable:2,2:"Unplayable"}),Object.freeze({Allowed:0,0:"Allowed",UnoccupiedSrc:1,1:"UnoccupiedSrc",OccupiedDest:2,2:"OccupiedDest",OutOfBounds:3,3:"OutOfBounds",Unplayable:4,4:"Unplayable",WrongTeamSrc:5,5:"WrongTeamSrc",IllegalTrajectory:6,6:"IllegalTrajectory",NoJumpablePiece:7,7:"NoJumpablePiece",JumpingSameTeam:8,8:"JumpingSameTeam"}));class S{static __wrap(t){const e=Object.create(S.prototype);return e.ptr=t,e}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();_.__wbg_board_free(t)}get width(){return _.__wbg_get_board_width(this.ptr)>>>0}set width(t){_.__wbg_set_board_width(this.ptr,t)}get height(){return _.__wbg_get_board_height(this.ptr)>>>0}set height(t){_.__wbg_set_board_height(this.ptr,t)}get current_turn(){return _.__wbg_get_board_current_turn(this.ptr)>>>0}set current_turn(t){_.__wbg_set_board_current_turn(this.ptr,t)}cell(t){var e=_.board_cell(this.ptr,t);return C.__wrap(e)}set_cell(t,e){k(e,C);var r=e.ptr;e.ptr=0,_.board_set_cell(this.ptr,t,r)}grid_cell(t){k(t,E);var e=t.ptr;t.ptr=0;var r=_.board_grid_cell(this.ptr,e);return C.__wrap(r)}cell_index(t,e){return _.board_cell_index(this.ptr,t,e)>>>0}cell_idx(t){k(t,E);var e=t.ptr;return t.ptr=0,_.board_cell_idx(this.ptr,e)>>>0}board_index(t){var e=_.board_board_index(this.ptr,t);return E.__wrap(e)}can_move(t,e){k(t,E);var r=t.ptr;t.ptr=0,k(e,E);var n=e.ptr;return e.ptr=0,_.board_can_move(this.ptr,r,n)>>>0}validate_man_move(t,e,r){k(t,E);var n=t.ptr;t.ptr=0,k(e,E);var a=e.ptr;e.ptr=0,k(r,B);var c=r.ptr;return r.ptr=0,_.board_validate_man_move(this.ptr,n,a,c)>>>0}validate_king_move(t,e,r){k(t,E);var n=t.ptr;t.ptr=0,k(e,E);var a=e.ptr;e.ptr=0,k(r,B);var c=r.ptr;return r.ptr=0,_.board_validate_king_move(this.ptr,n,a,c)>>>0}jumpee_idx(t,e){k(t,E);var r=t.ptr;t.ptr=0,k(e,E);var n=e.ptr;return e.ptr=0,_.board_jumpee_idx(this.ptr,r,n)>>>0}cells(){return _.board_cells(this.ptr)}num_cells(){return _.board_num_cells(this.ptr)>>>0}num_pieces(){return _.board_num_pieces(this.ptr)>>>0}num_player(t){return _.board_num_player(this.ptr,t)>>>0}score(){return _.board_score(this.ptr)}cell_state(t){return _.board_cell_state(this.ptr,t)>>>0}apply_move(t,e){k(t,E);var r=t.ptr;t.ptr=0,k(e,E);var n=e.ptr;e.ptr=0;var a=_.board_apply_move(this.ptr,r,n);return S.__wrap(a)}apply_jump(t,e){k(t,E);var r=t.ptr;t.ptr=0,k(e,E);var n=e.ptr;e.ptr=0;var a=_.board_apply_jump(this.ptr,r,n);return S.__wrap(a)}static validate_jumpee(t,e){k(t,C);var r=t.ptr;t.ptr=0,k(e,B);var n=e.ptr;return e.ptr=0,_.board_validate_jumpee(r,n)>>>0}static check_jumpee_team(t,e){k(t,B);var r=t.ptr;t.ptr=0,k(e,B);var n=e.ptr;return e.ptr=0,0!==_.board_check_jumpee_team(r,n)}constructor(t,e,r){var n=_.board_new(t,e,r);return S.__wrap(n)}static init_game(t,e){k(t,S);var r=t.ptr;t.ptr=0;var n=_.board_init_game(r,e);return S.__wrap(n)}}class E{static __wrap(t){const e=Object.create(E.prototype);return e.ptr=t,e}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();_.__wbg_brdidx_free(t)}get row(){return _.__wbg_get_brdidx_row(this.ptr)>>>0}set row(t){_.__wbg_set_brdidx_row(this.ptr,t)}get col(){return _.__wbg_get_brdidx_col(this.ptr)>>>0}set col(t){_.__wbg_set_brdidx_col(this.ptr,t)}constructor(t,e){var r=_.brdidx_from(t,e);return E.__wrap(r)}eq(t){return k(t,E),0!==_.brdidx_eq(this.ptr,t.ptr)}}class q{static __wrap(t){const e=Object.create(q.prototype);return e.ptr=t,e}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();_.__wbg_game_free(t)}current_board_cells(){return _.game_current_board_cells(this.ptr)}current_board_len(){return _.game_current_board_len(this.ptr)>>>0}current_turn(){return _.game_current_turn(this.ptr)>>>0}current_cell_state(t){k(t,E);var e=t.ptr;t.ptr=0;var r=_.game_current_cell_state(this.ptr,e);return C.__wrap(r)}make_move(t,e){k(t,E);var r=t.ptr;t.ptr=0,k(e,E);var n=e.ptr;return e.ptr=0,_.game_make_move(this.ptr,r,n)>>>0}execute_move(t,e){k(t,E);var r=t.ptr;t.ptr=0,k(e,E);var n=e.ptr;e.ptr=0,_.game_execute_move(this.ptr,r,n)}execute_jump(t,e){k(t,E);var r=t.ptr;t.ptr=0,k(e,E);var n=e.ptr;e.ptr=0,_.game_execute_jump(this.ptr,r,n)}push_new_board(t){k(t,S);var e=t.ptr;t.ptr=0,_.game_push_new_board(this.ptr,e)}set_current(t){k(t,S);var e=t.ptr;t.ptr=0,_.game_set_current(this.ptr,e)}constructor(t,e,r,n){var a=_.game_new(t,e,r,n);return q.__wrap(a)}static new_with_canvas(t,e,r,n,a,c,i){var o=h(a,_.__wbindgen_malloc,_.__wbindgen_realloc),s=g,u=_.game_new_with_canvas(t,e,r,n,o,s,c,i);return q.__wrap(u)}set_painter(t){k(t,I);var e=t.ptr;t.ptr=0,_.game_set_painter(this.ptr,e)}draw(){_.game_draw(this.ptr)}}class I{static __wrap(t){const e=Object.create(I.prototype);return e.ptr=t,e}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();_.__wbg_painter_free(t)}constructor(t,e,r){var n=h(r,_.__wbindgen_malloc,_.__wbindgen_realloc),a=g,c=_.painter_new(t,e,n,a);return I.__wrap(c)}static new_with_canvas(t,e,r){var n=_.painter_new_with_canvas(t,e,d(r));return I.__wrap(n)}set_square_outline(t){_.painter_set_square_outline(this.ptr,d(t))}set_outline_width(t){_.painter_set_outline_width(this.ptr,t)}set_draw_outline(t){_.painter_set_draw_outline(this.ptr,t)}reset_dimensions(){_.painter_reset_dimensions(this.ptr)}validate_board_dim(t){return k(t,S),0!==_.painter_validate_board_dim(this.ptr,t.ptr)}draw(t){k(t,S),_.painter_draw(this.ptr,t.ptr)}}class B{static __wrap(t){const e=Object.create(B.prototype);return e.ptr=t,e}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();_.__wbg_piece_free(t)}get team(){return _.__wbg_get_piece_team(this.ptr)>>>0}set team(t){_.__wbg_set_piece_team(this.ptr,t)}get strength(){return _.__wbg_get_piece_strength(this.ptr)>>>0}set strength(t){_.__wbg_set_piece_strength(this.ptr,t)}constructor(t,e){var r=_.piece_new(t,e);return B.__wrap(r)}}class C{static __wrap(t){const e=Object.create(C.prototype);return e.ptr=t,e}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();_.__wbg_square_free(t)}get occupant(){var t=_.__wbg_get_square_occupant(this.ptr);return 0===t?void 0:B.__wrap(t)}set occupant(t){let e=0;y(t)||(k(t,B),e=t.ptr,t.ptr=0),_.__wbg_set_square_occupant(this.ptr,e)}get state(){return _.__wbg_get_square_state(this.ptr)>>>0}set state(t){_.__wbg_set_square_state(this.ptr,t)}constructor(t,e){let r=0;y(e)||(k(e,B),r=e.ptr,e.ptr=0);var n=_.square_new(t,r);return C.__wrap(n)}static pc(t,e){var r=_.square_pc(t,e);return C.__wrap(r)}static empty(){var t=_.square_empty();return C.__wrap(t)}static unplay(){var t=_.square_unplay();return C.__wrap(t)}}function A(t){!function(t){const e=i(t);(function(t){t<36||(c[t]=o,o=t)})(t)}(t)}function U(t,e){return d(l(t,e))}function W(){return d(new Error)}function $(t,e){var r=h(i(e).stack,_.__wbindgen_malloc,_.__wbindgen_realloc),n=g;v()[t/4+1]=n,v()[t/4+0]=r}function M(t,e){try{console.error(l(t,e))}finally{_.__wbindgen_free(t,e)}}function D(t){return i(t)instanceof Window}function J(t){var e=i(t).document;return y(e)?0:d(e)}function P(t,e,r){var n=i(t).getElementById(l(e,r));return y(n)?0:d(n)}function R(t){console.log(i(t))}function z(t){return i(t)instanceof CanvasRenderingContext2D}function F(t,e){i(t).strokeStyle=i(e)}function N(t,e){i(t).fillStyle=i(e)}function Y(t,e){i(t).lineWidth=e}function K(t){i(t).beginPath()}function L(t){i(t).fill()}function Q(t){i(t).stroke()}function X(){return j((function(t,e,r,n,_,a){i(t).arc(e,r,n,_,a)}),arguments)}function H(t,e,r,n,_){i(t).fillRect(e,r,n,_)}function Z(t,e,r,n,_){i(t).strokeRect(e,r,n,_)}function G(t){return i(t)instanceof HTMLCanvasElement}function V(t,e){i(t).width=e>>>0}function tt(t,e){i(t).height=e>>>0}function et(){return j((function(t,e,r){var n=i(t).getContext(l(e,r));return y(n)?0:d(n)}),arguments)}function rt(t,e){return d(new Function(l(t,e)))}function nt(){return j((function(t,e){return d(i(t).call(i(e)))}),arguments)}function _t(){return j((function(){return d(self.self)}),arguments)}function at(){return j((function(){return d(window.window)}),arguments)}function ct(){return j((function(){return d(globalThis.globalThis)}),arguments)}function it(){return j((function(){return d(r.g.global)}),arguments)}function ot(t){return void 0===i(t)}function st(t){return d(i(t))}function ut(t,e){var r=h(b(i(e)),_.__wbindgen_malloc,_.__wbindgen_realloc),n=g;v()[t/4+1]=n,v()[t/4+0]=r}function pt(t,e){throw new Error(l(t,e))}}))},813:(t,e,r)=>{"use strict";var n=([n])=>r.v(e,t.id,"29964598fec03e30f3aa",{"./draught_bg.js":{__wbindgen_object_drop_ref:n.ug,__wbindgen_string_new:n.h4,__wbg_new_59cb74e423758ede:n.h9,__wbg_stack_558ba5917b466edd:n.Dz,__wbg_error_4bb6c2a97407129a:n.kF,__wbg_instanceof_Window_11e25482011fc506:n.s8,__wbg_document_5aff8cd83ef968f5:n.WB,__wbg_getElementById_b180ea4ada06a837:n.cP,__wbg_log_9a99fb1af846153b:n.a,__wbg_instanceof_CanvasRenderingContext2d_779e79c4121aa91b:n.l_,__wbg_setstrokeStyle_2939ee453716e462:n.U_,__wbg_setfillStyle_af790b5baf4d3210:n.EN,__wbg_setlineWidth_3e6b1837ae38d099:n.qu,__wbg_beginPath_2378575e37027ad3:n.Wg,__wbg_fill_558339447ed6ad43:n.B3,__wbg_stroke_c1e0313c58997dcf:n.I6,__wbg_arc_fffd87d9113dce32:n.Qb,__wbg_fillRect_46ffc8d2cef7e298:n.cI,__wbg_strokeRect_7ea34fad8a7f0fe2:n.QK,__wbg_instanceof_HtmlCanvasElement_fd3cbbe3906d7792:n.Md,__wbg_setwidth_f3c88eb520ba8d47:n.ox,__wbg_setheight_5a1abba41e35c42a:n.ES,__wbg_getContext_813df131fcbd6e91:n.Ae,__wbg_newnoargs_9fdd8f3961dd1bee:n.UL,__wbg_call_ba36642bd901572b:n.qw,__wbg_self_bb69a836a72ec6e9:n.tS,__wbg_window_3304fc4b414c9693:n.R$,__wbg_globalThis_e0d21cabc6630763:n.md,__wbg_global_8463719227271676:n.IF,__wbindgen_is_undefined:n.XP,__wbindgen_object_clone_ref:n.m_,__wbindgen_debug_string:n.fY,__wbindgen_throw:n.Or}});r.a(t,(t=>{var e=t([r(171)]);return e.then?e.then(n):n(e)}),1)},10:(t,e,r)=>{"use strict";r.a(t,(async t=>{r.r(e);var n=r(171),_=t([n]);n=(_.then?await _:_)[0];const a="human_turn.thinking",c="human_turn.from_selected";(0,n.wc)();const i=document.getElementById("status-p");let o=a,s=new n.Ck(480,480,"game-canvas"),u=[],p=new n.lA(8,8,3,n.SZ.Black);p.set_painter(s),p.draw();const l=document.getElementById("game-canvas");function d(t){i.hidden=!1,i.innerText=t}l.addEventListener("click",(t=>{var e=function(t,e){var r=t.getBoundingClientRect();return{x:e.clientX-r.left,y:e.clientY-r.top}}(l,t);!function(t){switch(o){case a:console.log("Your turn, first piece picked"),u.push(t),o=c;break;case c:if(console.log("Your turn, first piece already picked, picking second"),u.push(t),2!=u.length)return d(`Error: wrong number of clicks to process ${u.length}`),void console.error(`Error: wrong number of clicks to process ${u.length}`);if(u[0].eq(u[1]))d("Move Cancelled");else switch(p.make_move(u[0],u[1])){case n.Tt.Allowed:case n.Tt.IllegalTrajectory:case n.Tt.JumpingSameTeam:case n.Tt.NoJumpablePiece:case n.Tt.OccupiedDest:case n.Tt.OutOfBounds:case n.Tt.UnoccupiedSrc:case n.Tt.Unplayable:case n.Tt.WrongTeamSrc:}p.draw(),u=[],o=a;break;case"ai_turn":console.log("It's the AI's turn!")}}(new n.rh(Math.floor(e.y/480*8),Math.floor(e.x/480*8)))}))}))}}]); //# sourceMappingURL=10.bootstrap.js.map \ No newline at end of file diff --git a/10.bootstrap.js.map b/10.bootstrap.js.map index 85757c6..deba575 100644 --- a/10.bootstrap.js.map +++ b/10.bootstrap.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://draught/../pkg/draught_bg.js","webpack://draught/./index.js"],"names":["heap","Array","fill","undefined","getObject","idx","push","heap_next","length","cachedTextDecoder","TextDecoder","module","require","ignoreBOM","fatal","decode","cachegetUint8Memory0","getUint8Memory0","buffer","Uint8Array","getStringFromWasm0","ptr","len","subarray","addHeapObject","obj","debugString","val","type","description","name","isArray","debug","i","builtInMatches","exec","toString","call","className","JSON","stringify","_","Error","message","stack","WASM_VECTOR_LEN","cachedTextEncoder","TextEncoder","encodeString","encodeInto","arg","view","buf","encode","set","read","written","passStringToWasm0","malloc","realloc","mem","offset","code","charCodeAt","slice","cachegetInt32Memory0","getInt32Memory0","Int32Array","isLikeNone","x","_assertClass","instance","klass","init_wasm","handleError","f","args","apply","this","e","Object","freeze","Move","Jump","Team","Black","White","Moveable","Man","King","Empty","Occupied","Unplayable","Allowed","UnoccupiedSrc","OccupiedDest","OutOfBounds","WrongTeamSrc","IllegalTrajectory","NoJumpablePiece","JumpingSameTeam","Board","create","prototype","__destroy_into_raw","arg0","ret","Square","__wrap","square","ptr0","BrdIdx","row","col","from","to","ptr1","from_square_occupant","Piece","ptr2","team","jumpee","from_occ","width","height","current_turn","board","piece_rows","Game","first_turn","canvas_id","canvas_width","canvas_height","len0","value","Painter","canvas","strength","state","occupant","__wbindgen_object_drop_ref","dropObject","takeObject","__wbindgen_string_new","arg1","__wbg_new_59cb74e423758ede","__wbg_stack_558ba5917b466edd","__wbg_error_4bb6c2a97407129a","console","error","__wbg_instanceof_Window_11e25482011fc506","Window","__wbg_document_5aff8cd83ef968f5","document","__wbg_getElementById_b180ea4ada06a837","arg2","getElementById","__wbg_log_9a99fb1af846153b","log","__wbg_instanceof_CanvasRenderingContext2d_779e79c4121aa91b","CanvasRenderingContext2D","__wbg_setstrokeStyle_2939ee453716e462","strokeStyle","__wbg_setfillStyle_af790b5baf4d3210","fillStyle","__wbg_setlineWidth_3e6b1837ae38d099","lineWidth","__wbg_beginPath_2378575e37027ad3","beginPath","__wbg_fill_558339447ed6ad43","__wbg_stroke_c1e0313c58997dcf","stroke","__wbg_arc_fffd87d9113dce32","arg3","arg4","arg5","arc","arguments","__wbg_fillRect_46ffc8d2cef7e298","fillRect","__wbg_strokeRect_7ea34fad8a7f0fe2","strokeRect","__wbg_instanceof_HtmlCanvasElement_fd3cbbe3906d7792","HTMLCanvasElement","__wbg_setwidth_f3c88eb520ba8d47","__wbg_setheight_5a1abba41e35c42a","__wbg_getContext_813df131fcbd6e91","getContext","__wbg_newnoargs_9fdd8f3961dd1bee","Function","__wbg_call_ba36642bd901572b","__wbg_self_bb69a836a72ec6e9","self","__wbg_window_3304fc4b414c9693","window","__wbg_globalThis_e0d21cabc6630763","globalThis","__wbg_global_8463719227271676","g","global","__wbindgen_is_undefined","__wbindgen_object_clone_ref","__wbindgen_debug_string","__wbindgen_throw","GameState","statusText","current_state","painter","game","set_painter","draw","addEventListener","event","mousepos","evt","rect","getBoundingClientRect","clientX","left","y","clientY","top","getMousePos","cell_coord","hidden","innerText","status","make_move","process_canvas_click","Math","floor"],"mappings":"giBAEA,MAAMA,EAAO,IAAIC,MAAM,IAAIC,UAAKC,GAIhC,SAASC,EAAUC,GAAO,OAAOL,EAAKK,GAFtCL,EAAKM,UAAKH,EAAW,MAAM,GAAM,GAIjC,IAAII,EAAYP,EAAKQ,OAgBrB,IAAIC,EAAoB,IAFoB,oBAAhBC,aAA8B,EAAIC,EAAOC,SAAS,QAAQF,YAAcA,aAE3D,QAAS,CAAEG,WAAW,EAAMC,OAAO,IAE5EL,EAAkBM,SAElB,IAAIC,EAAuB,KAC3B,SAASC,IAIL,OAH6B,OAAzBD,GAAiCA,EAAqBE,SAAW,kBACjEF,EAAuB,IAAIG,WAAW,kBAEnCH,EAGX,SAASI,EAAmBC,EAAKC,GAC7B,OAAOb,EAAkBM,OAAOE,IAAkBM,SAASF,EAAKA,EAAMC,IAG1E,SAASE,EAAcC,GACflB,IAAcP,EAAKQ,QAAQR,EAAKM,KAAKN,EAAKQ,OAAS,GACvD,MAAMH,EAAME,EAIZ,OAHAA,EAAYP,EAAKK,GAEjBL,EAAKK,GAAOoB,EACLpB,EAGX,SAASqB,EAAYC,GAEjB,MAAMC,SAAcD,EACpB,GAAY,UAARC,GAA4B,WAARA,GAA4B,MAAPD,EACzC,MAAQ,GAAGA,IAEf,GAAY,UAARC,EACA,MAAO,IAAID,KAEf,G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G,EACPjB,EAAgBF,EAEhB,MACJ,KAAKA,EAKD,GAJAxD,QAAQU,IAAI,yDAEZ3C,EAAK4G,EAEF7G,EAAKD,KAAOE,EAAGF,KAAOC,EAAKF,KAAOG,EAAGH,IACtB,iBAqD1B6F,EAAWmB,QAAS,EACpBnB,EAAWoB,UAtDe,qBACX,CAEH,IAAIC,EAASlB,EAAKmB,UAAUjH,EAAMC,GAElC,GAAI+G,GAAU,mBAGV,OAAOA,GACH,KAAK,aAEL,KAAK,uBAEL,KAAK,qBAEL,KAAK,qBAEL,KAAK,kBAEL,KAAK,iBAEL,KAAK,mBAEL,KAAK,gBAEL,KAAK,oBAOjBlB,EAAKE,OACLhG,EAAO,KACPC,EAAK,KACL2F,EAAgBF,EAEhB,MACJ,IAzGK,UA0GDxD,QAAQU,IAAI,wBArEpBsE,CALW,IAAI,KACXC,KAAKC,MAAOjB,EAASM,EA7CP,IAGD,GA2CbU,KAAKC,MAAOjB,EAAShJ,EA/CR,IAGD","file":"10.bootstrap.js","sourcesContent":["import * as wasm from './draught_bg.wasm';\n\nconst heap = new Array(32).fill(undefined);\n\nheap.push(undefined, null, true, false);\n\nfunction getObject(idx) { return heap[idx]; }\n\nlet heap_next = heap.length;\n\nfunction dropObject(idx) {\n if (idx < 36) return;\n heap[idx] = heap_next;\n heap_next = idx;\n}\n\nfunction takeObject(idx) {\n const ret = getObject(idx);\n dropObject(idx);\n return ret;\n}\n\nconst lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;\n\nlet cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });\n\ncachedTextDecoder.decode();\n\nlet cachegetUint8Memory0 = null;\nfunction getUint8Memory0() {\n if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {\n cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachegetUint8Memory0;\n}\n\nfunction getStringFromWasm0(ptr, len) {\n return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));\n}\n\nfunction addHeapObject(obj) {\n if (heap_next === heap.length) heap.push(heap.length + 1);\n const idx = heap_next;\n heap_next = heap[idx];\n\n heap[idx] = obj;\n return idx;\n}\n\nfunction debugString(val) {\n // primitive types\n const type = typeof val;\n if (type == 'number' || type == 'boolean' || val == null) {\n return `${val}`;\n }\n if (type == 'string') {\n return `\"${val}\"`;\n }\n if (type == 'symbol') {\n const description = val.description;\n if (description == null) {\n return 'Symbol';\n } else {\n return `Symbol(${description})`;\n }\n }\n if (type == 'function') {\n const name = val.name;\n if (typeof name == 'string' && name.length > 0) {\n return `Function(${name})`;\n } else {\n return 'Function';\n }\n }\n // objects\n if (Array.isArray(val)) {\n const length = val.length;\n let debug = '[';\n if (length > 0) {\n debug += debugString(val[0]);\n }\n for(let i = 1; i < length; i++) {\n debug += ', ' + debugString(val[i]);\n }\n debug += ']';\n return debug;\n }\n // Test for built-in\n const builtInMatches = /\\[object ([^\\]]+)\\]/.exec(toString.call(val));\n let className;\n if (builtInMatches.length > 1) {\n className = builtInMatches[1];\n } else {\n // Failed to match the standard '[object ClassName]'\n return toString.call(val);\n }\n if (className == 'Object') {\n // we're a user defined class or Object\n // JSON.stringify avoids problems with cycles, and is generally much\n // easier than looping through ownProperties of `val`.\n try {\n return 'Object(' + JSON.stringify(val) + ')';\n } catch (_) {\n return 'Object';\n }\n }\n // errors\n if (val instanceof Error) {\n return `${val.name}: ${val.message}\\n${val.stack}`;\n }\n // TODO we could test for more things here, like `Set`s and `Map`s.\n return className;\n}\n\nlet WASM_VECTOR_LEN = 0;\n\nconst lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;\n\nlet cachedTextEncoder = new lTextEncoder('utf-8');\n\nconst encodeString = (typeof cachedTextEncoder.encodeInto === 'function'\n ? function (arg, view) {\n return cachedTextEncoder.encodeInto(arg, view);\n}\n : function (arg, view) {\n const buf = cachedTextEncoder.encode(arg);\n view.set(buf);\n return {\n read: arg.length,\n written: buf.length\n };\n});\n\nfunction passStringToWasm0(arg, malloc, realloc) {\n\n if (realloc === undefined) {\n const buf = cachedTextEncoder.encode(arg);\n const ptr = malloc(buf.length);\n getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);\n WASM_VECTOR_LEN = buf.length;\n return ptr;\n }\n\n let len = arg.length;\n let ptr = malloc(len);\n\n const mem = getUint8Memory0();\n\n let offset = 0;\n\n for (; offset < len; offset++) {\n const code = arg.charCodeAt(offset);\n if (code > 0x7F) break;\n mem[ptr + offset] = code;\n }\n\n if (offset !== len) {\n if (offset !== 0) {\n arg = arg.slice(offset);\n }\n ptr = realloc(ptr, len, len = offset + arg.length * 3);\n const view = getUint8Memory0().subarray(ptr + offset, ptr + len);\n const ret = encodeString(arg, view);\n\n offset += ret.written;\n }\n\n WASM_VECTOR_LEN = offset;\n return ptr;\n}\n\nlet cachegetInt32Memory0 = null;\nfunction getInt32Memory0() {\n if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {\n cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);\n }\n return cachegetInt32Memory0;\n}\n\nfunction isLikeNone(x) {\n return x === undefined || x === null;\n}\n\nfunction _assertClass(instance, klass) {\n if (!(instance instanceof klass)) {\n throw new Error(`expected instance of ${klass.name}`);\n }\n return instance.ptr;\n}\n/**\n*/\nexport function init_wasm() {\n wasm.init_wasm();\n}\n\nfunction handleError(f, args) {\n try {\n return f.apply(this, args);\n } catch (e) {\n wasm.__wbindgen_exn_store(addHeapObject(e));\n }\n}\n/**\n*/\nexport const MoveType = Object.freeze({ Move:0,\"0\":\"Move\",Jump:1,\"1\":\"Jump\", });\n/**\n*/\nexport const Team = Object.freeze({ Black:0,\"0\":\"Black\",White:1,\"1\":\"White\", });\n/**\n*/\nexport const Strength = Object.freeze({ Man:0,\"0\":\"Man\",King:1,\"1\":\"King\", });\n/**\n*/\nexport const SquareState = Object.freeze({ Empty:0,\"0\":\"Empty\",Occupied:1,\"1\":\"Occupied\",Unplayable:2,\"2\":\"Unplayable\", });\n/**\n*/\nexport const Moveable = Object.freeze({ Allowed:0,\"0\":\"Allowed\",UnoccupiedSrc:1,\"1\":\"UnoccupiedSrc\",OccupiedDest:2,\"2\":\"OccupiedDest\",OutOfBounds:3,\"3\":\"OutOfBounds\",Unplayable:4,\"4\":\"Unplayable\",WrongTeamSrc:5,\"5\":\"WrongTeamSrc\",IllegalTrajectory:6,\"6\":\"IllegalTrajectory\",NoJumpablePiece:7,\"7\":\"NoJumpablePiece\",JumpingSameTeam:8,\"8\":\"JumpingSameTeam\", });\n/**\n* Single state of a checkers board\n*/\nexport class Board {\n\n static __wrap(ptr) {\n const obj = Object.create(Board.prototype);\n obj.ptr = ptr;\n\n return obj;\n }\n\n __destroy_into_raw() {\n const ptr = this.ptr;\n this.ptr = 0;\n\n return ptr;\n }\n\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_board_free(ptr);\n }\n /**\n * @returns {number}\n */\n get width() {\n var ret = wasm.__wbg_get_board_width(this.ptr);\n return ret >>> 0;\n }\n /**\n * @param {number} arg0\n */\n set width(arg0) {\n wasm.__wbg_set_board_width(this.ptr, arg0);\n }\n /**\n * @returns {number}\n */\n get height() {\n var ret = wasm.__wbg_get_board_height(this.ptr);\n return ret >>> 0;\n }\n /**\n * @param {number} arg0\n */\n set height(arg0) {\n wasm.__wbg_set_board_height(this.ptr, arg0);\n }\n /**\n * @returns {number}\n */\n get current_turn() {\n var ret = wasm.__wbg_get_board_current_turn(this.ptr);\n return ret >>> 0;\n }\n /**\n * @param {number} arg0\n */\n set current_turn(arg0) {\n wasm.__wbg_set_board_current_turn(this.ptr, arg0);\n }\n /**\n * Get a copy of a board square by 1D array index\n * @param {number} idx\n * @returns {Square}\n */\n cell(idx) {\n var ret = wasm.board_cell(this.ptr, idx);\n return Square.__wrap(ret);\n }\n /**\n * Get a copy of a board square by 1D array index\n * @param {number} idx\n * @param {Square} square\n */\n set_cell(idx, square) {\n _assertClass(square, Square);\n var ptr0 = square.ptr;\n square.ptr = 0;\n wasm.board_set_cell(this.ptr, idx, ptr0);\n }\n /**\n * Get a copy of a board square by 2D [`BrdIdx`] index\n * @param {BrdIdx} idx\n * @returns {Square}\n */\n grid_cell(idx) {\n _assertClass(idx, BrdIdx);\n var ptr0 = idx.ptr;\n idx.ptr = 0;\n var ret = wasm.board_grid_cell(this.ptr, ptr0);\n return Square.__wrap(ret);\n }\n /**\n * Transform a 2D row/column board index into a single 1D index for use with [`Board::cells`]\n * @param {number} row\n * @param {number} col\n * @returns {number}\n */\n cell_index(row, col) {\n var ret = wasm.board_cell_index(this.ptr, row, col);\n return ret >>> 0;\n }\n /**\n * Similar to [`Board::cell_index`] but with a [`BrdIdx`] instead of separate indices. Transform a 2D row/column board index into a single 1D index for use with [`Board::cells`]\n * @param {BrdIdx} idx\n * @returns {number}\n */\n cell_idx(idx) {\n _assertClass(idx, BrdIdx);\n var ptr0 = idx.ptr;\n idx.ptr = 0;\n var ret = wasm.board_cell_idx(this.ptr, ptr0);\n return ret >>> 0;\n }\n /**\n * Transform a 1D array index (for [`Board::cells`]) into a 2D game board index (by row/col)\n * @param {number} idx\n * @returns {BrdIdx}\n */\n board_index(idx) {\n var ret = wasm.board_board_index(this.ptr, idx);\n return BrdIdx.__wrap(ret);\n }\n /**\n * Check whether a move given by source and destination indices is legal\n * @param {BrdIdx} from\n * @param {BrdIdx} to\n * @returns {number}\n */\n can_move(from, to) {\n _assertClass(from, BrdIdx);\n var ptr0 = from.ptr;\n from.ptr = 0;\n _assertClass(to, BrdIdx);\n var ptr1 = to.ptr;\n to.ptr = 0;\n var ret = wasm.board_can_move(this.ptr, ptr0, ptr1);\n return ret >>> 0;\n }\n /**\n * @param {BrdIdx} from\n * @param {BrdIdx} to\n * @param {Piece} from_square_occupant\n * @returns {number}\n */\n validate_man_move(from, to, from_square_occupant) {\n _assertClass(from, BrdIdx);\n var ptr0 = from.ptr;\n from.ptr = 0;\n _assertClass(to, BrdIdx);\n var ptr1 = to.ptr;\n to.ptr = 0;\n _assertClass(from_square_occupant, Piece);\n var ptr2 = from_square_occupant.ptr;\n from_square_occupant.ptr = 0;\n var ret = wasm.board_validate_man_move(this.ptr, ptr0, ptr1, ptr2);\n return ret >>> 0;\n }\n /**\n * @param {BrdIdx} from\n * @param {BrdIdx} to\n * @param {Piece} from_square_occupant\n * @returns {number}\n */\n validate_king_move(from, to, from_square_occupant) {\n _assertClass(from, BrdIdx);\n var ptr0 = from.ptr;\n from.ptr = 0;\n _assertClass(to, BrdIdx);\n var ptr1 = to.ptr;\n to.ptr = 0;\n _assertClass(from_square_occupant, Piece);\n var ptr2 = from_square_occupant.ptr;\n from_square_occupant.ptr = 0;\n var ret = wasm.board_validate_king_move(this.ptr, ptr0, ptr1, ptr2);\n return ret >>> 0;\n }\n /**\n * @param {BrdIdx} from\n * @param {BrdIdx} to\n * @returns {number}\n */\n jumpee_idx(from, to) {\n _assertClass(from, BrdIdx);\n var ptr0 = from.ptr;\n from.ptr = 0;\n _assertClass(to, BrdIdx);\n var ptr1 = to.ptr;\n to.ptr = 0;\n var ret = wasm.board_jumpee_idx(this.ptr, ptr0, ptr1);\n return ret >>> 0;\n }\n /**\n * Get a pointer to the backing array of board squares, [`Board::cells`]\n * @returns {number}\n */\n cells() {\n var ret = wasm.board_cells(this.ptr);\n return ret;\n }\n /**\n * Get the number of board squares\n * @returns {number}\n */\n num_cells() {\n var ret = wasm.board_num_cells(this.ptr);\n return ret >>> 0;\n }\n /**\n * Get the number of remaining pieces\n * @returns {number}\n */\n num_pieces() {\n var ret = wasm.board_num_pieces(this.ptr);\n return ret >>> 0;\n }\n /**\n * Get the number of remaining pieces for a player\n * @param {number} team\n * @returns {number}\n */\n num_player(team) {\n var ret = wasm.board_num_player(this.ptr, team);\n return ret >>> 0;\n }\n /**\n * Get the score value, Black - White pieces\n * @returns {number}\n */\n score() {\n var ret = wasm.board_score(this.ptr);\n return ret;\n }\n /**\n * Get the state of a board square by 1D array index\n * @param {number} idx\n * @returns {number}\n */\n cell_state(idx) {\n var ret = wasm.board_cell_state(this.ptr, idx);\n return ret >>> 0;\n }\n /**\n * @param {BrdIdx} from\n * @param {BrdIdx} to\n * @returns {Board}\n */\n apply_move(from, to) {\n _assertClass(from, BrdIdx);\n var ptr0 = from.ptr;\n from.ptr = 0;\n _assertClass(to, BrdIdx);\n var ptr1 = to.ptr;\n to.ptr = 0;\n var ret = wasm.board_apply_move(this.ptr, ptr0, ptr1);\n return Board.__wrap(ret);\n }\n /**\n * @param {BrdIdx} from\n * @param {BrdIdx} to\n * @returns {Board}\n */\n apply_jump(from, to) {\n _assertClass(from, BrdIdx);\n var ptr0 = from.ptr;\n from.ptr = 0;\n _assertClass(to, BrdIdx);\n var ptr1 = to.ptr;\n to.ptr = 0;\n var ret = wasm.board_apply_jump(this.ptr, ptr0, ptr1);\n return Board.__wrap(ret);\n }\n /**\n * Unwrap the jumpee piece from the square and [`Board::check_jumpee_team`] with [`Moveable`] response\n * @param {Square} jumpee\n * @param {Piece} from_occ\n * @returns {number}\n */\n static validate_jumpee(jumpee, from_occ) {\n _assertClass(jumpee, Square);\n var ptr0 = jumpee.ptr;\n jumpee.ptr = 0;\n _assertClass(from_occ, Piece);\n var ptr1 = from_occ.ptr;\n from_occ.ptr = 0;\n var ret = wasm.board_validate_jumpee(ptr0, ptr1);\n return ret >>> 0;\n }\n /**\n * Check that the source piece and the jumpee are of opposing teams\n * @param {Piece} from\n * @param {Piece} jumpee\n * @returns {boolean}\n */\n static check_jumpee_team(from, jumpee) {\n _assertClass(from, Piece);\n var ptr0 = from.ptr;\n from.ptr = 0;\n _assertClass(jumpee, Piece);\n var ptr1 = jumpee.ptr;\n jumpee.ptr = 0;\n var ret = wasm.board_check_jumpee_team(ptr0, ptr1);\n return ret !== 0;\n }\n /**\n * Initialise a game board without game pieces\n * @param {number} width\n * @param {number} height\n * @param {number} current_turn\n */\n constructor(width, height, current_turn) {\n var ret = wasm.board_new(width, height, current_turn);\n return Board.__wrap(ret);\n }\n /**\n * Reset the given board to a starting layout with 3 rows of opposing pieces\n * @param {Board} board\n * @param {number} piece_rows\n * @returns {Board}\n */\n static init_game(board, piece_rows) {\n _assertClass(board, Board);\n var ptr0 = board.ptr;\n board.ptr = 0;\n var ret = wasm.board_init_game(ptr0, piece_rows);\n return Board.__wrap(ret);\n }\n}\n/**\n* Rank 2 tensor index to identify a board square by row and column\n*/\nexport class BrdIdx {\n\n static __wrap(ptr) {\n const obj = Object.create(BrdIdx.prototype);\n obj.ptr = ptr;\n\n return obj;\n }\n\n __destroy_into_raw() {\n const ptr = this.ptr;\n this.ptr = 0;\n\n return ptr;\n }\n\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_brdidx_free(ptr);\n }\n /**\n * @returns {number}\n */\n get row() {\n var ret = wasm.__wbg_get_brdidx_row(this.ptr);\n return ret >>> 0;\n }\n /**\n * @param {number} arg0\n */\n set row(arg0) {\n wasm.__wbg_set_brdidx_row(this.ptr, arg0);\n }\n /**\n * @returns {number}\n */\n get col() {\n var ret = wasm.__wbg_get_brdidx_col(this.ptr);\n return ret >>> 0;\n }\n /**\n * @param {number} arg0\n */\n set col(arg0) {\n wasm.__wbg_set_brdidx_col(this.ptr, arg0);\n }\n /**\n * @param {number} row\n * @param {number} col\n */\n constructor(row, col) {\n var ret = wasm.brdidx_from(row, col);\n return BrdIdx.__wrap(ret);\n }\n}\n/**\n* Root-level structure for managing the game as a collection of board states\n*/\nexport class Game {\n\n static __wrap(ptr) {\n const obj = Object.create(Game.prototype);\n obj.ptr = ptr;\n\n return obj;\n }\n\n __destroy_into_raw() {\n const ptr = this.ptr;\n this.ptr = 0;\n\n return ptr;\n }\n\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_game_free(ptr);\n }\n /**\n * Get pointer to current board's squares\n * @returns {number}\n */\n current_board_cells() {\n var ret = wasm.game_current_board_cells(this.ptr);\n return ret;\n }\n /**\n * Get pointer to current board's squares\n * @returns {number}\n */\n current_board_len() {\n var ret = wasm.game_current_board_len(this.ptr);\n return ret >>> 0;\n }\n /**\n * Current turn's team\n * @returns {number}\n */\n current_turn() {\n var ret = wasm.game_current_turn(this.ptr);\n return ret >>> 0;\n }\n /**\n * Attempt to make a move given a source and destination index\n * @param {BrdIdx} from\n * @param {BrdIdx} to\n * @returns {number}\n */\n make_move(from, to) {\n _assertClass(from, BrdIdx);\n var ptr0 = from.ptr;\n from.ptr = 0;\n _assertClass(to, BrdIdx);\n var ptr1 = to.ptr;\n to.ptr = 0;\n var ret = wasm.game_make_move(this.ptr, ptr0, ptr1);\n return ret >>> 0;\n }\n /**\n * Update board state with given move and push new board into current state\n * @param {BrdIdx} from\n * @param {BrdIdx} to\n */\n execute_move(from, to) {\n _assertClass(from, BrdIdx);\n var ptr0 = from.ptr;\n from.ptr = 0;\n _assertClass(to, BrdIdx);\n var ptr1 = to.ptr;\n to.ptr = 0;\n wasm.game_execute_move(this.ptr, ptr0, ptr1);\n }\n /**\n * Update board state with given jump move and push new board into current state\n * @param {BrdIdx} from\n * @param {BrdIdx} to\n */\n execute_jump(from, to) {\n _assertClass(from, BrdIdx);\n var ptr0 = from.ptr;\n from.ptr = 0;\n _assertClass(to, BrdIdx);\n var ptr1 = to.ptr;\n to.ptr = 0;\n wasm.game_execute_jump(this.ptr, ptr0, ptr1);\n }\n /**\n * Push current board into the previous turns and set given board to current\n * @param {Board} board\n */\n push_new_board(board) {\n _assertClass(board, Board);\n var ptr0 = board.ptr;\n board.ptr = 0;\n wasm.game_push_new_board(this.ptr, ptr0);\n }\n /**\n * Set current board to given\n * @param {Board} board\n */\n set_current(board) {\n _assertClass(board, Board);\n var ptr0 = board.ptr;\n board.ptr = 0;\n wasm.game_set_current(this.ptr, ptr0);\n }\n /**\n * @param {number} width\n * @param {number} height\n * @param {number} piece_rows\n * @param {number} first_turn\n */\n constructor(width, height, piece_rows, first_turn) {\n var ret = wasm.game_new(width, height, piece_rows, first_turn);\n return Game.__wrap(ret);\n }\n /**\n * @param {number} width\n * @param {number} height\n * @param {number} piece_rows\n * @param {number} first_turn\n * @param {string} canvas_id\n * @param {number} canvas_width\n * @param {number} canvas_height\n * @returns {Game}\n */\n static new_with_canvas(width, height, piece_rows, first_turn, canvas_id, canvas_width, canvas_height) {\n var ptr0 = passStringToWasm0(canvas_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len0 = WASM_VECTOR_LEN;\n var ret = wasm.game_new_with_canvas(width, height, piece_rows, first_turn, ptr0, len0, canvas_width, canvas_height);\n return Game.__wrap(ret);\n }\n /**\n * @param {Painter} value\n */\n set_painter(value) {\n _assertClass(value, Painter);\n var ptr0 = value.ptr;\n value.ptr = 0;\n wasm.game_set_painter(this.ptr, ptr0);\n }\n /**\n */\n draw() {\n wasm.game_draw(this.ptr);\n }\n}\n/**\n* Used to paint boards onto HTML canvases\n*/\nexport class Painter {\n\n static __wrap(ptr) {\n const obj = Object.create(Painter.prototype);\n obj.ptr = ptr;\n\n return obj;\n }\n\n __destroy_into_raw() {\n const ptr = this.ptr;\n this.ptr = 0;\n\n return ptr;\n }\n\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_painter_free(ptr);\n }\n /**\n * Default constructor which queries for canvas by ID\n * @param {number} width\n * @param {number} height\n * @param {string} canvas_id\n */\n constructor(width, height, canvas_id) {\n var ptr0 = passStringToWasm0(canvas_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len0 = WASM_VECTOR_LEN;\n var ret = wasm.painter_new(width, height, ptr0, len0);\n return Painter.__wrap(ret);\n }\n /**\n * Constructor with given canvas element\n * @param {number} width\n * @param {number} height\n * @param {HTMLCanvasElement} canvas\n * @returns {Painter}\n */\n static new_with_canvas(width, height, canvas) {\n var ret = wasm.painter_new_with_canvas(width, height, addHeapObject(canvas));\n return Painter.__wrap(ret);\n }\n /**\n * Set new square outline colour value\n * @param {any} value\n */\n set_square_outline(value) {\n wasm.painter_set_square_outline(this.ptr, addHeapObject(value));\n }\n /**\n * Set new line width for outlining squares\n * @param {number} value\n */\n set_outline_width(value) {\n wasm.painter_set_outline_width(this.ptr, value);\n }\n /**\n * Set whether squares are outlined\n * @param {boolean} value\n */\n set_draw_outline(value) {\n wasm.painter_set_draw_outline(this.ptr, value);\n }\n /**\n * Reset the canvas dimensions to the given width and height\n */\n reset_dimensions() {\n wasm.painter_reset_dimensions(this.ptr);\n }\n /**\n * Check whether given canvas dimensions divide evenly by given board dimenions\n * @param {Board} board\n * @returns {boolean}\n */\n validate_board_dim(board) {\n _assertClass(board, Board);\n var ret = wasm.painter_validate_board_dim(this.ptr, board.ptr);\n return ret !== 0;\n }\n /**\n * Draw a board onto the canvas\n * @param {Board} board\n */\n draw(board) {\n _assertClass(board, Board);\n wasm.painter_draw(this.ptr, board.ptr);\n }\n}\n/**\n* Game piece given by its team and strength (normal or kinged)\n*/\nexport class Piece {\n\n static __wrap(ptr) {\n const obj = Object.create(Piece.prototype);\n obj.ptr = ptr;\n\n return obj;\n }\n\n __destroy_into_raw() {\n const ptr = this.ptr;\n this.ptr = 0;\n\n return ptr;\n }\n\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_piece_free(ptr);\n }\n /**\n * @returns {number}\n */\n get team() {\n var ret = wasm.__wbg_get_piece_team(this.ptr);\n return ret >>> 0;\n }\n /**\n * @param {number} arg0\n */\n set team(arg0) {\n wasm.__wbg_set_piece_team(this.ptr, arg0);\n }\n /**\n * @returns {number}\n */\n get strength() {\n var ret = wasm.__wbg_get_piece_strength(this.ptr);\n return ret >>> 0;\n }\n /**\n * @param {number} arg0\n */\n set strength(arg0) {\n wasm.__wbg_set_piece_strength(this.ptr, arg0);\n }\n /**\n * @param {number} team\n * @param {number} strength\n */\n constructor(team, strength) {\n var ret = wasm.piece_new(team, strength);\n return Piece.__wrap(ret);\n }\n}\n/**\n*/\nexport class Player {\n\n __destroy_into_raw() {\n const ptr = this.ptr;\n this.ptr = 0;\n\n return ptr;\n }\n\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_player_free(ptr);\n }\n}\n/**\n* Board squares given by a state and a possible occupying game piece\n*/\nexport class Square {\n\n static __wrap(ptr) {\n const obj = Object.create(Square.prototype);\n obj.ptr = ptr;\n\n return obj;\n }\n\n __destroy_into_raw() {\n const ptr = this.ptr;\n this.ptr = 0;\n\n return ptr;\n }\n\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_square_free(ptr);\n }\n /**\n * Game piece if square is occupied\n * @returns {Piece | undefined}\n */\n get occupant() {\n var ret = wasm.__wbg_get_square_occupant(this.ptr);\n return ret === 0 ? undefined : Piece.__wrap(ret);\n }\n /**\n * Game piece if square is occupied\n * @param {Piece | undefined} arg0\n */\n set occupant(arg0) {\n let ptr0 = 0;\n if (!isLikeNone(arg0)) {\n _assertClass(arg0, Piece);\n ptr0 = arg0.ptr;\n arg0.ptr = 0;\n }\n wasm.__wbg_set_square_occupant(this.ptr, ptr0);\n }\n /**\n * Description of whether the square is occupied or an unplayable, i.e. off-lattice square\n * @returns {number}\n */\n get state() {\n var ret = wasm.__wbg_get_square_state(this.ptr);\n return ret >>> 0;\n }\n /**\n * Description of whether the square is occupied or an unplayable, i.e. off-lattice square\n * @param {number} arg0\n */\n set state(arg0) {\n wasm.__wbg_set_square_state(this.ptr, arg0);\n }\n /**\n * Standard constructor function to form square from state and occupant\n * @param {number} state\n * @param {Piece | undefined} occupant\n */\n constructor(state, occupant) {\n let ptr0 = 0;\n if (!isLikeNone(occupant)) {\n _assertClass(occupant, Piece);\n ptr0 = occupant.ptr;\n occupant.ptr = 0;\n }\n var ret = wasm.square_new(state, ptr0);\n return Square.__wrap(ret);\n }\n /**\n * Helper function for a well-formed piece square by team and strength\n * @param {number} team\n * @param {number} strength\n * @returns {Square}\n */\n static pc(team, strength) {\n var ret = wasm.square_pc(team, strength);\n return Square.__wrap(ret);\n }\n /**\n * Helper function for a well-formed empty square\n * @returns {Square}\n */\n static empty() {\n var ret = wasm.square_empty();\n return Square.__wrap(ret);\n }\n /**\n * Helper function for a well-formed unplayable square\n * @returns {Square}\n */\n static unplay() {\n var ret = wasm.square_unplay();\n return Square.__wrap(ret);\n }\n}\n\nexport function __wbindgen_object_drop_ref(arg0) {\n takeObject(arg0);\n};\n\nexport function __wbindgen_string_new(arg0, arg1) {\n var ret = getStringFromWasm0(arg0, arg1);\n return addHeapObject(ret);\n};\n\nexport function __wbg_new_59cb74e423758ede() {\n var ret = new Error();\n return addHeapObject(ret);\n};\n\nexport function __wbg_stack_558ba5917b466edd(arg0, arg1) {\n var ret = getObject(arg1).stack;\n var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len0 = WASM_VECTOR_LEN;\n getInt32Memory0()[arg0 / 4 + 1] = len0;\n getInt32Memory0()[arg0 / 4 + 0] = ptr0;\n};\n\nexport function __wbg_error_4bb6c2a97407129a(arg0, arg1) {\n try {\n console.error(getStringFromWasm0(arg0, arg1));\n } finally {\n wasm.__wbindgen_free(arg0, arg1);\n }\n};\n\nexport function __wbg_instanceof_Window_11e25482011fc506(arg0) {\n var ret = getObject(arg0) instanceof Window;\n return ret;\n};\n\nexport function __wbg_document_5aff8cd83ef968f5(arg0) {\n var ret = getObject(arg0).document;\n return isLikeNone(ret) ? 0 : addHeapObject(ret);\n};\n\nexport function __wbg_getElementById_b180ea4ada06a837(arg0, arg1, arg2) {\n var ret = getObject(arg0).getElementById(getStringFromWasm0(arg1, arg2));\n return isLikeNone(ret) ? 0 : addHeapObject(ret);\n};\n\nexport function __wbg_log_9a99fb1af846153b(arg0) {\n console.log(getObject(arg0));\n};\n\nexport function __wbg_instanceof_CanvasRenderingContext2d_779e79c4121aa91b(arg0) {\n var ret = getObject(arg0) instanceof CanvasRenderingContext2D;\n return ret;\n};\n\nexport function __wbg_setstrokeStyle_2939ee453716e462(arg0, arg1) {\n getObject(arg0).strokeStyle = getObject(arg1);\n};\n\nexport function __wbg_setfillStyle_af790b5baf4d3210(arg0, arg1) {\n getObject(arg0).fillStyle = getObject(arg1);\n};\n\nexport function __wbg_setlineWidth_3e6b1837ae38d099(arg0, arg1) {\n getObject(arg0).lineWidth = arg1;\n};\n\nexport function __wbg_beginPath_2378575e37027ad3(arg0) {\n getObject(arg0).beginPath();\n};\n\nexport function __wbg_fill_558339447ed6ad43(arg0) {\n getObject(arg0).fill();\n};\n\nexport function __wbg_stroke_c1e0313c58997dcf(arg0) {\n getObject(arg0).stroke();\n};\n\nexport function __wbg_arc_fffd87d9113dce32() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5) {\n getObject(arg0).arc(arg1, arg2, arg3, arg4, arg5);\n}, arguments) };\n\nexport function __wbg_fillRect_46ffc8d2cef7e298(arg0, arg1, arg2, arg3, arg4) {\n getObject(arg0).fillRect(arg1, arg2, arg3, arg4);\n};\n\nexport function __wbg_strokeRect_7ea34fad8a7f0fe2(arg0, arg1, arg2, arg3, arg4) {\n getObject(arg0).strokeRect(arg1, arg2, arg3, arg4);\n};\n\nexport function __wbg_instanceof_HtmlCanvasElement_fd3cbbe3906d7792(arg0) {\n var ret = getObject(arg0) instanceof HTMLCanvasElement;\n return ret;\n};\n\nexport function __wbg_setwidth_f3c88eb520ba8d47(arg0, arg1) {\n getObject(arg0).width = arg1 >>> 0;\n};\n\nexport function __wbg_setheight_5a1abba41e35c42a(arg0, arg1) {\n getObject(arg0).height = arg1 >>> 0;\n};\n\nexport function __wbg_getContext_813df131fcbd6e91() { return handleError(function (arg0, arg1, arg2) {\n var ret = getObject(arg0).getContext(getStringFromWasm0(arg1, arg2));\n return isLikeNone(ret) ? 0 : addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_newnoargs_9fdd8f3961dd1bee(arg0, arg1) {\n var ret = new Function(getStringFromWasm0(arg0, arg1));\n return addHeapObject(ret);\n};\n\nexport function __wbg_call_ba36642bd901572b() { return handleError(function (arg0, arg1) {\n var ret = getObject(arg0).call(getObject(arg1));\n return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_self_bb69a836a72ec6e9() { return handleError(function () {\n var ret = self.self;\n return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_window_3304fc4b414c9693() { return handleError(function () {\n var ret = window.window;\n return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_globalThis_e0d21cabc6630763() { return handleError(function () {\n var ret = globalThis.globalThis;\n return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_global_8463719227271676() { return handleError(function () {\n var ret = global.global;\n return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbindgen_is_undefined(arg0) {\n var ret = getObject(arg0) === undefined;\n return ret;\n};\n\nexport function __wbindgen_object_clone_ref(arg0) {\n var ret = getObject(arg0);\n return addHeapObject(ret);\n};\n\nexport function __wbindgen_debug_string(arg0, arg1) {\n var ret = debugString(getObject(arg1));\n var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len0 = WASM_VECTOR_LEN;\n getInt32Memory0()[arg0 / 4 + 1] = len0;\n getInt32Memory0()[arg0 / 4 + 0] = ptr0;\n};\n\nexport function __wbindgen_throw(arg0, arg1) {\n throw new Error(getStringFromWasm0(arg0, arg1));\n};\n\n","import { Game, Board, BrdIdx, Painter, Team, init_wasm, Moveable } from \"draught\";\nimport { memory } from \"draught/draught_bg.wasm\";\n\n///////////////////\n// CONSTS\n///////////////////\n\nconst CANVAS_WIDTH = 480;\nconst CANVAS_HEIGHT = 480;\n\nconst BOARD_WIDTH = 8;\nconst BOARD_HEIGHT = 8;\n\nconst PIECE_ROWS = 3;\n\nconst GameState = {\n HUMAN_TURN: {\n THINKING: \"human_turn.thinking\",\n FROM_SELECTED: \"human_turn.from_selected\"\n },\n AI_TURN: \"ai_turn\"\n}\n\n//////////////////\n// GAME STUFF\n//////////////////\n\ninit_wasm();\n\n// let board = new Board(BOARD_WIDTH, BOARD_HEIGHT, Team.Black);\n\nconst statusText = document.getElementById(\"status-p\");\n\nlet current_state = GameState.HUMAN_TURN.THINKING;\nlet painter = new Painter(CANVAS_WIDTH, CANVAS_HEIGHT, \"game-canvas\");\n// painter.draw(board);\n\nlet from = null;\nlet to = null;\n\nlet game = new Game(BOARD_WIDTH, BOARD_HEIGHT, PIECE_ROWS, Team.Black);\ngame.set_painter(painter);\ngame.draw();\n\n/////////////////\n// CANVAS\n/////////////////\n\nconst canvas = document.getElementById(\"game-canvas\");\ncanvas.addEventListener(\"click\", (event) => {\n var mousepos = getMousePos(canvas, event);\n // console.log(mousepos);\n var cell = new BrdIdx(\n Math.floor((mousepos.y / CANVAS_HEIGHT) * BOARD_HEIGHT),\n Math.floor((mousepos.x / CANVAS_WIDTH) * BOARD_WIDTH),\n );\n // console.log(cell);\n process_canvas_click(cell);\n})\n\n////////////////\n// FUNCS\n////////////////\n\nfunction start_game() {\n game = new Game(BOARD_WIDTH, BOARD_HEIGHT, PIECE_ROWS, Team.Black);\n game.set_painter(painter);\n game.draw();\n\n current_state = GameState.HUMAN_TURN.THINKING;\n}\n\nfunction process_canvas_click(cell_coord) {\n switch(current_state) {\n case GameState.HUMAN_TURN.THINKING:\n console.log(\"Your turn, first piece picked\");\n\n from = cell_coord;\n current_state = GameState.HUMAN_TURN.FROM_SELECTED; \n \n break;\n case GameState.HUMAN_TURN.FROM_SELECTED:\n console.log(\"Your turn, first piece already picked, picking second\");\n\n to = cell_coord;\n\n if(from.col == to.col && from.row == to.row){\n setStatusText(\"Move Cancelled\");\n } else {\n\n let status = game.make_move(from, to);\n\n if (status == Moveable.Allowed) {\n // game.draw();\n } else {\n switch(status) {\n case Moveable.Allowed:\n break;\n case Moveable.IllegalTrajectory:\n break;\n case Moveable.JumpingSameTeam:\n break;\n case Moveable.NoJumpablePiece:\n break;\n case Moveable.OccupiedDest:\n break;\n case Moveable.OutOfBounds:\n break;\n case Moveable.UnoccupiedSrc:\n break;\n case Moveable.Unplayable:\n break;\n case Moveable.WrongTeamSrc:\n break;\n }\n }\n \n }\n\n game.draw();\n from = null;\n to = null;\n current_state = GameState.HUMAN_TURN.THINKING;\n \n break;\n case GameState.AI_TURN:\n console.log(\"It's the AI's turn!\");\n break;\n }\n}\n\nfunction getMousePos(canvas, evt) {\n var rect = canvas.getBoundingClientRect();\n return {\n x: evt.clientX - rect.left,\n y: evt.clientY - rect.top\n };\n}\n\nfunction setStatusText(txt) {\n statusText.hidden = false;\n statusText.innerText = txt;\n}\n\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://draught/../pkg/draught_bg.js","webpack://draught/./index.js"],"names":["heap","Array","fill","undefined","getObject","idx","push","heap_next","length","cachedTextDecoder","TextDecoder","module","require","ignoreBOM","fatal","decode","cachegetUint8Memory0","getUint8Memory0","buffer","Uint8Array","getStringFromWasm0","ptr","len","subarray","addHeapObject","obj","debugString","val","type","description","name","isArray","debug","i","builtInMatches","exec","toString","call","className","JSON","stringify","_","Error","message","stack","WASM_VECTOR_LEN","cachedTextEncoder","TextEncoder","encodeString","encodeInto","arg","view","buf","encode","set","read","written","passStringToWasm0","malloc","realloc","mem","offset","code","charCodeAt","slice","cachegetInt32Memory0","getInt32Memory0","Int32Array","isLikeNone","x","_assertClass","instance","klass","init_wasm","handleError","f","args","apply","this","e","Object","freeze","Move","Jump","Team","Black","White","Moveable","Man","King","Empty","Occupied","Unplayable","Allowed","UnoccupiedSrc","OccupiedDest","OutOfBounds","WrongTeamSrc","IllegalTrajectory","NoJumpablePiece","JumpingSameTeam","Board","create","prototype","__destroy_into_raw","arg0","ret","Square","__wrap","square","ptr0","BrdIdx","row","col","from","to","ptr1","from_square_occupant","Piece","ptr2","team","jumpee","from_occ","width","height","current_turn","board","piece_rows","other","Game","first_turn","canvas_id","canvas_width","canvas_height","len0","value","Painter","canvas","strength","state","occupant","__wbindgen_object_drop_ref","dropObject","takeObject","__wbindgen_string_new","arg1","__wbg_new_59cb74e423758ede","__wbg_stack_558ba5917b466edd","__wbg_error_4bb6c2a97407129a","console","error","__wbg_instanceof_Window_11e25482011fc506","Window","__wbg_document_5aff8cd83ef968f5","document","__wbg_getElementById_b180ea4ada06a837","arg2","getElementById","__wbg_log_9a99fb1af846153b","log","__wbg_instanceof_CanvasRenderingContext2d_779e79c4121aa91b","CanvasRenderingContext2D","__wbg_setstrokeStyle_2939ee453716e462","strokeStyle","__wbg_setfillStyle_af790b5baf4d3210","fillStyle","__wbg_setlineWidth_3e6b1837ae38d099","lineWidth","__wbg_beginPath_2378575e37027ad3","beginPath","__wbg_fill_558339447ed6ad43","__wbg_stroke_c1e0313c58997dcf","stroke","__wbg_arc_fffd87d9113dce32","arg3","arg4","arg5","arc","arguments","__wbg_fillRect_46ffc8d2cef7e298","fillRect","__wbg_strokeRect_7ea34fad8a7f0fe2","strokeRect","__wbg_instanceof_HtmlCanvasElement_fd3cbbe3906d7792","HTMLCanvasElement","__wbg_setwidth_f3c88eb520ba8d47","__wbg_setheight_5a1abba41e35c42a","__wbg_getContext_813df131fcbd6e91","getContext","__wbg_newnoargs_9fdd8f3961dd1bee","Function","__wbg_call_ba36642bd901572b","__wbg_self_bb69a836a72ec6e9","self","__wbg_window_3304fc4b414c9693","window","__wbg_globalThis_e0d21cabc6630763","globalThis","__wbg_global_8463719227271676","g","global","__wbindgen_is_undefined","__wbindgen_object_clone_ref","__wbindgen_debug_string","__wbindgen_throw","GameState","statusText","current_state","painter","clicks","game","set_painter","draw","setStatusText","txt","hidden","innerText","addEventListener","event","mousepos","evt","rect","getBoundingClientRect","clientX","left","y","clientY","top","getMousePos","cell_coord","eq","make_move","process_canvas_click","Math","floor"],"mappings":"giBAEA,MAAMA,EAAO,IAAIC,MAAM,IAAIC,UAAKC,GAIhC,SAASC,EAAUC,GAAO,OAAOL,EAAKK,GAFtCL,EAAKM,UAAKH,EAAW,MAAM,GAAM,GAIjC,IAAII,EAAYP,EAAKQ,OAgBrB,IAAIC,EAAoB,IAFoB,oBAAhBC,aAA8B,EAAIC,EAAOC,SAAS,QAAQF,YAAcA,aAE3D,QAAS,CAAEG,WAAW,EAAMC,OAAO,IAE5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K,mBAEL,KAAK,gBAEL,KAAK,mBAMbC,EAAKE,OACLH,EAAS,GAGTF,EAAgBF,EAEhB,MACJ,IA9HK,UA+HDxD,QAAQU,IAAI,wBAxFpByE,CALW,IAAI,KACXC,KAAKC,MAAOf,EAASM,EA/CP,IAGD,GA6CbQ,KAAKC,MAAOf,EAAStJ,EAjDR,IAGD","file":"10.bootstrap.js","sourcesContent":["import * as wasm from './draught_bg.wasm';\n\nconst heap = new Array(32).fill(undefined);\n\nheap.push(undefined, null, true, false);\n\nfunction getObject(idx) { return heap[idx]; }\n\nlet heap_next = heap.length;\n\nfunction dropObject(idx) {\n if (idx < 36) return;\n heap[idx] = heap_next;\n heap_next = idx;\n}\n\nfunction takeObject(idx) {\n const ret = getObject(idx);\n dropObject(idx);\n return ret;\n}\n\nconst lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;\n\nlet cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });\n\ncachedTextDecoder.decode();\n\nlet cachegetUint8Memory0 = null;\nfunction getUint8Memory0() {\n if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {\n cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachegetUint8Memory0;\n}\n\nfunction getStringFromWasm0(ptr, len) {\n return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));\n}\n\nfunction addHeapObject(obj) {\n if (heap_next === heap.length) heap.push(heap.length + 1);\n const idx = heap_next;\n heap_next = heap[idx];\n\n heap[idx] = obj;\n return idx;\n}\n\nfunction debugString(val) {\n // primitive types\n const type = typeof val;\n if (type == 'number' || type == 'boolean' || val == null) {\n return `${val}`;\n }\n if (type == 'string') {\n return `\"${val}\"`;\n }\n if (type == 'symbol') {\n const description = val.description;\n if (description == null) {\n return 'Symbol';\n } else {\n return `Symbol(${description})`;\n }\n }\n if (type == 'function') {\n const name = val.name;\n if (typeof name == 'string' && name.length > 0) {\n return `Function(${name})`;\n } else {\n return 'Function';\n }\n }\n // objects\n if (Array.isArray(val)) {\n const length = val.length;\n let debug = '[';\n if (length > 0) {\n debug += debugString(val[0]);\n }\n for(let i = 1; i < length; i++) {\n debug += ', ' + debugString(val[i]);\n }\n debug += ']';\n return debug;\n }\n // Test for built-in\n const builtInMatches = /\\[object ([^\\]]+)\\]/.exec(toString.call(val));\n let className;\n if (builtInMatches.length > 1) {\n className = builtInMatches[1];\n } else {\n // Failed to match the standard '[object ClassName]'\n return toString.call(val);\n }\n if (className == 'Object') {\n // we're a user defined class or Object\n // JSON.stringify avoids problems with cycles, and is generally much\n // easier than looping through ownProperties of `val`.\n try {\n return 'Object(' + JSON.stringify(val) + ')';\n } catch (_) {\n return 'Object';\n }\n }\n // errors\n if (val instanceof Error) {\n return `${val.name}: ${val.message}\\n${val.stack}`;\n }\n // TODO we could test for more things here, like `Set`s and `Map`s.\n return className;\n}\n\nlet WASM_VECTOR_LEN = 0;\n\nconst lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;\n\nlet cachedTextEncoder = new lTextEncoder('utf-8');\n\nconst encodeString = (typeof cachedTextEncoder.encodeInto === 'function'\n ? function (arg, view) {\n return cachedTextEncoder.encodeInto(arg, view);\n}\n : function (arg, view) {\n const buf = cachedTextEncoder.encode(arg);\n view.set(buf);\n return {\n read: arg.length,\n written: buf.length\n };\n});\n\nfunction passStringToWasm0(arg, malloc, realloc) {\n\n if (realloc === undefined) {\n const buf = cachedTextEncoder.encode(arg);\n const ptr = malloc(buf.length);\n getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);\n WASM_VECTOR_LEN = buf.length;\n return ptr;\n }\n\n let len = arg.length;\n let ptr = malloc(len);\n\n const mem = getUint8Memory0();\n\n let offset = 0;\n\n for (; offset < len; offset++) {\n const code = arg.charCodeAt(offset);\n if (code > 0x7F) break;\n mem[ptr + offset] = code;\n }\n\n if (offset !== len) {\n if (offset !== 0) {\n arg = arg.slice(offset);\n }\n ptr = realloc(ptr, len, len = offset + arg.length * 3);\n const view = getUint8Memory0().subarray(ptr + offset, ptr + len);\n const ret = encodeString(arg, view);\n\n offset += ret.written;\n }\n\n WASM_VECTOR_LEN = offset;\n return ptr;\n}\n\nlet cachegetInt32Memory0 = null;\nfunction getInt32Memory0() {\n if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {\n cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);\n }\n return cachegetInt32Memory0;\n}\n\nfunction isLikeNone(x) {\n return x === undefined || x === null;\n}\n\nfunction _assertClass(instance, klass) {\n if (!(instance instanceof klass)) {\n throw new Error(`expected instance of ${klass.name}`);\n }\n return instance.ptr;\n}\n/**\n*/\nexport function init_wasm() {\n wasm.init_wasm();\n}\n\nfunction handleError(f, args) {\n try {\n return f.apply(this, args);\n } catch (e) {\n wasm.__wbindgen_exn_store(addHeapObject(e));\n }\n}\n/**\n*/\nexport const MoveType = Object.freeze({ Move:0,\"0\":\"Move\",Jump:1,\"1\":\"Jump\", });\n/**\n*/\nexport const Team = Object.freeze({ Black:0,\"0\":\"Black\",White:1,\"1\":\"White\", });\n/**\n*/\nexport const Strength = Object.freeze({ Man:0,\"0\":\"Man\",King:1,\"1\":\"King\", });\n/**\n*/\nexport const SquareState = Object.freeze({ Empty:0,\"0\":\"Empty\",Occupied:1,\"1\":\"Occupied\",Unplayable:2,\"2\":\"Unplayable\", });\n/**\n*/\nexport const Moveable = Object.freeze({ Allowed:0,\"0\":\"Allowed\",UnoccupiedSrc:1,\"1\":\"UnoccupiedSrc\",OccupiedDest:2,\"2\":\"OccupiedDest\",OutOfBounds:3,\"3\":\"OutOfBounds\",Unplayable:4,\"4\":\"Unplayable\",WrongTeamSrc:5,\"5\":\"WrongTeamSrc\",IllegalTrajectory:6,\"6\":\"IllegalTrajectory\",NoJumpablePiece:7,\"7\":\"NoJumpablePiece\",JumpingSameTeam:8,\"8\":\"JumpingSameTeam\", });\n/**\n* Single state of a checkers board\n*/\nexport class Board {\n\n static __wrap(ptr) {\n const obj = Object.create(Board.prototype);\n obj.ptr = ptr;\n\n return obj;\n }\n\n __destroy_into_raw() {\n const ptr = this.ptr;\n this.ptr = 0;\n\n return ptr;\n }\n\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_board_free(ptr);\n }\n /**\n * @returns {number}\n */\n get width() {\n var ret = wasm.__wbg_get_board_width(this.ptr);\n return ret >>> 0;\n }\n /**\n * @param {number} arg0\n */\n set width(arg0) {\n wasm.__wbg_set_board_width(this.ptr, arg0);\n }\n /**\n * @returns {number}\n */\n get height() {\n var ret = wasm.__wbg_get_board_height(this.ptr);\n return ret >>> 0;\n }\n /**\n * @param {number} arg0\n */\n set height(arg0) {\n wasm.__wbg_set_board_height(this.ptr, arg0);\n }\n /**\n * @returns {number}\n */\n get current_turn() {\n var ret = wasm.__wbg_get_board_current_turn(this.ptr);\n return ret >>> 0;\n }\n /**\n * @param {number} arg0\n */\n set current_turn(arg0) {\n wasm.__wbg_set_board_current_turn(this.ptr, arg0);\n }\n /**\n * Get a copy of a board square by 1D array index\n * @param {number} idx\n * @returns {Square}\n */\n cell(idx) {\n var ret = wasm.board_cell(this.ptr, idx);\n return Square.__wrap(ret);\n }\n /**\n * Get a copy of a board square by 1D array index\n * @param {number} idx\n * @param {Square} square\n */\n set_cell(idx, square) {\n _assertClass(square, Square);\n var ptr0 = square.ptr;\n square.ptr = 0;\n wasm.board_set_cell(this.ptr, idx, ptr0);\n }\n /**\n * Get a copy of a board square by 2D [`BrdIdx`] index\n * @param {BrdIdx} idx\n * @returns {Square}\n */\n grid_cell(idx) {\n _assertClass(idx, BrdIdx);\n var ptr0 = idx.ptr;\n idx.ptr = 0;\n var ret = wasm.board_grid_cell(this.ptr, ptr0);\n return Square.__wrap(ret);\n }\n /**\n * Transform a 2D row/column board index into a single 1D index for use with [`Board::cells`]\n * @param {number} row\n * @param {number} col\n * @returns {number}\n */\n cell_index(row, col) {\n var ret = wasm.board_cell_index(this.ptr, row, col);\n return ret >>> 0;\n }\n /**\n * Similar to [`Board::cell_index`] but with a [`BrdIdx`] instead of separate indices. Transform a 2D row/column board index into a single 1D index for use with [`Board::cells`]\n * @param {BrdIdx} idx\n * @returns {number}\n */\n cell_idx(idx) {\n _assertClass(idx, BrdIdx);\n var ptr0 = idx.ptr;\n idx.ptr = 0;\n var ret = wasm.board_cell_idx(this.ptr, ptr0);\n return ret >>> 0;\n }\n /**\n * Transform a 1D array index (for [`Board::cells`]) into a 2D game board index (by row/col)\n * @param {number} idx\n * @returns {BrdIdx}\n */\n board_index(idx) {\n var ret = wasm.board_board_index(this.ptr, idx);\n return BrdIdx.__wrap(ret);\n }\n /**\n * Check whether a move given by source and destination indices is legal\n * @param {BrdIdx} from\n * @param {BrdIdx} to\n * @returns {number}\n */\n can_move(from, to) {\n _assertClass(from, BrdIdx);\n var ptr0 = from.ptr;\n from.ptr = 0;\n _assertClass(to, BrdIdx);\n var ptr1 = to.ptr;\n to.ptr = 0;\n var ret = wasm.board_can_move(this.ptr, ptr0, ptr1);\n return ret >>> 0;\n }\n /**\n * @param {BrdIdx} from\n * @param {BrdIdx} to\n * @param {Piece} from_square_occupant\n * @returns {number}\n */\n validate_man_move(from, to, from_square_occupant) {\n _assertClass(from, BrdIdx);\n var ptr0 = from.ptr;\n from.ptr = 0;\n _assertClass(to, BrdIdx);\n var ptr1 = to.ptr;\n to.ptr = 0;\n _assertClass(from_square_occupant, Piece);\n var ptr2 = from_square_occupant.ptr;\n from_square_occupant.ptr = 0;\n var ret = wasm.board_validate_man_move(this.ptr, ptr0, ptr1, ptr2);\n return ret >>> 0;\n }\n /**\n * @param {BrdIdx} from\n * @param {BrdIdx} to\n * @param {Piece} from_square_occupant\n * @returns {number}\n */\n validate_king_move(from, to, from_square_occupant) {\n _assertClass(from, BrdIdx);\n var ptr0 = from.ptr;\n from.ptr = 0;\n _assertClass(to, BrdIdx);\n var ptr1 = to.ptr;\n to.ptr = 0;\n _assertClass(from_square_occupant, Piece);\n var ptr2 = from_square_occupant.ptr;\n from_square_occupant.ptr = 0;\n var ret = wasm.board_validate_king_move(this.ptr, ptr0, ptr1, ptr2);\n return ret >>> 0;\n }\n /**\n * @param {BrdIdx} from\n * @param {BrdIdx} to\n * @returns {number}\n */\n jumpee_idx(from, to) {\n _assertClass(from, BrdIdx);\n var ptr0 = from.ptr;\n from.ptr = 0;\n _assertClass(to, BrdIdx);\n var ptr1 = to.ptr;\n to.ptr = 0;\n var ret = wasm.board_jumpee_idx(this.ptr, ptr0, ptr1);\n return ret >>> 0;\n }\n /**\n * Get a pointer to the backing array of board squares, [`Board::cells`]\n * @returns {number}\n */\n cells() {\n var ret = wasm.board_cells(this.ptr);\n return ret;\n }\n /**\n * Get the number of board squares\n * @returns {number}\n */\n num_cells() {\n var ret = wasm.board_num_cells(this.ptr);\n return ret >>> 0;\n }\n /**\n * Get the number of remaining pieces\n * @returns {number}\n */\n num_pieces() {\n var ret = wasm.board_num_pieces(this.ptr);\n return ret >>> 0;\n }\n /**\n * Get the number of remaining pieces for a player\n * @param {number} team\n * @returns {number}\n */\n num_player(team) {\n var ret = wasm.board_num_player(this.ptr, team);\n return ret >>> 0;\n }\n /**\n * Get the score value, Black - White pieces\n * @returns {number}\n */\n score() {\n var ret = wasm.board_score(this.ptr);\n return ret;\n }\n /**\n * Get the state of a board square by 1D array index\n * @param {number} idx\n * @returns {number}\n */\n cell_state(idx) {\n var ret = wasm.board_cell_state(this.ptr, idx);\n return ret >>> 0;\n }\n /**\n * @param {BrdIdx} from\n * @param {BrdIdx} to\n * @returns {Board}\n */\n apply_move(from, to) {\n _assertClass(from, BrdIdx);\n var ptr0 = from.ptr;\n from.ptr = 0;\n _assertClass(to, BrdIdx);\n var ptr1 = to.ptr;\n to.ptr = 0;\n var ret = wasm.board_apply_move(this.ptr, ptr0, ptr1);\n return Board.__wrap(ret);\n }\n /**\n * @param {BrdIdx} from\n * @param {BrdIdx} to\n * @returns {Board}\n */\n apply_jump(from, to) {\n _assertClass(from, BrdIdx);\n var ptr0 = from.ptr;\n from.ptr = 0;\n _assertClass(to, BrdIdx);\n var ptr1 = to.ptr;\n to.ptr = 0;\n var ret = wasm.board_apply_jump(this.ptr, ptr0, ptr1);\n return Board.__wrap(ret);\n }\n /**\n * Unwrap the jumpee piece from the square and [`Board::check_jumpee_team`] with [`Moveable`] response\n * @param {Square} jumpee\n * @param {Piece} from_occ\n * @returns {number}\n */\n static validate_jumpee(jumpee, from_occ) {\n _assertClass(jumpee, Square);\n var ptr0 = jumpee.ptr;\n jumpee.ptr = 0;\n _assertClass(from_occ, Piece);\n var ptr1 = from_occ.ptr;\n from_occ.ptr = 0;\n var ret = wasm.board_validate_jumpee(ptr0, ptr1);\n return ret >>> 0;\n }\n /**\n * Check that the source piece and the jumpee are of opposing teams\n * @param {Piece} from\n * @param {Piece} jumpee\n * @returns {boolean}\n */\n static check_jumpee_team(from, jumpee) {\n _assertClass(from, Piece);\n var ptr0 = from.ptr;\n from.ptr = 0;\n _assertClass(jumpee, Piece);\n var ptr1 = jumpee.ptr;\n jumpee.ptr = 0;\n var ret = wasm.board_check_jumpee_team(ptr0, ptr1);\n return ret !== 0;\n }\n /**\n * Initialise a game board without game pieces\n * @param {number} width\n * @param {number} height\n * @param {number} current_turn\n */\n constructor(width, height, current_turn) {\n var ret = wasm.board_new(width, height, current_turn);\n return Board.__wrap(ret);\n }\n /**\n * Reset the given board to a starting layout with 3 rows of opposing pieces\n * @param {Board} board\n * @param {number} piece_rows\n * @returns {Board}\n */\n static init_game(board, piece_rows) {\n _assertClass(board, Board);\n var ptr0 = board.ptr;\n board.ptr = 0;\n var ret = wasm.board_init_game(ptr0, piece_rows);\n return Board.__wrap(ret);\n }\n}\n/**\n* Rank 2 tensor index to identify a board square by row and column\n*/\nexport class BrdIdx {\n\n static __wrap(ptr) {\n const obj = Object.create(BrdIdx.prototype);\n obj.ptr = ptr;\n\n return obj;\n }\n\n __destroy_into_raw() {\n const ptr = this.ptr;\n this.ptr = 0;\n\n return ptr;\n }\n\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_brdidx_free(ptr);\n }\n /**\n * @returns {number}\n */\n get row() {\n var ret = wasm.__wbg_get_brdidx_row(this.ptr);\n return ret >>> 0;\n }\n /**\n * @param {number} arg0\n */\n set row(arg0) {\n wasm.__wbg_set_brdidx_row(this.ptr, arg0);\n }\n /**\n * @returns {number}\n */\n get col() {\n var ret = wasm.__wbg_get_brdidx_col(this.ptr);\n return ret >>> 0;\n }\n /**\n * @param {number} arg0\n */\n set col(arg0) {\n wasm.__wbg_set_brdidx_col(this.ptr, arg0);\n }\n /**\n * @param {number} row\n * @param {number} col\n */\n constructor(row, col) {\n var ret = wasm.brdidx_from(row, col);\n return BrdIdx.__wrap(ret);\n }\n /**\n * @param {BrdIdx} other\n * @returns {boolean}\n */\n eq(other) {\n _assertClass(other, BrdIdx);\n var ret = wasm.brdidx_eq(this.ptr, other.ptr);\n return ret !== 0;\n }\n}\n/**\n* Root-level structure for managing the game as a collection of board states\n*/\nexport class Game {\n\n static __wrap(ptr) {\n const obj = Object.create(Game.prototype);\n obj.ptr = ptr;\n\n return obj;\n }\n\n __destroy_into_raw() {\n const ptr = this.ptr;\n this.ptr = 0;\n\n return ptr;\n }\n\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_game_free(ptr);\n }\n /**\n * Get pointer to current board's squares\n * @returns {number}\n */\n current_board_cells() {\n var ret = wasm.game_current_board_cells(this.ptr);\n return ret;\n }\n /**\n * Get pointer to current board's squares\n * @returns {number}\n */\n current_board_len() {\n var ret = wasm.game_current_board_len(this.ptr);\n return ret >>> 0;\n }\n /**\n * Current turn's team\n * @returns {number}\n */\n current_turn() {\n var ret = wasm.game_current_turn(this.ptr);\n return ret >>> 0;\n }\n /**\n * @param {BrdIdx} idx\n * @returns {Square}\n */\n current_cell_state(idx) {\n _assertClass(idx, BrdIdx);\n var ptr0 = idx.ptr;\n idx.ptr = 0;\n var ret = wasm.game_current_cell_state(this.ptr, ptr0);\n return Square.__wrap(ret);\n }\n /**\n * Attempt to make a move given a source and destination index\n * @param {BrdIdx} from\n * @param {BrdIdx} to\n * @returns {number}\n */\n make_move(from, to) {\n _assertClass(from, BrdIdx);\n var ptr0 = from.ptr;\n from.ptr = 0;\n _assertClass(to, BrdIdx);\n var ptr1 = to.ptr;\n to.ptr = 0;\n var ret = wasm.game_make_move(this.ptr, ptr0, ptr1);\n return ret >>> 0;\n }\n /**\n * Update board state with given move and push new board into current state\n * @param {BrdIdx} from\n * @param {BrdIdx} to\n */\n execute_move(from, to) {\n _assertClass(from, BrdIdx);\n var ptr0 = from.ptr;\n from.ptr = 0;\n _assertClass(to, BrdIdx);\n var ptr1 = to.ptr;\n to.ptr = 0;\n wasm.game_execute_move(this.ptr, ptr0, ptr1);\n }\n /**\n * Update board state with given jump move and push new board into current state\n * @param {BrdIdx} from\n * @param {BrdIdx} to\n */\n execute_jump(from, to) {\n _assertClass(from, BrdIdx);\n var ptr0 = from.ptr;\n from.ptr = 0;\n _assertClass(to, BrdIdx);\n var ptr1 = to.ptr;\n to.ptr = 0;\n wasm.game_execute_jump(this.ptr, ptr0, ptr1);\n }\n /**\n * Push current board into the previous turns and set given board to current\n * @param {Board} board\n */\n push_new_board(board) {\n _assertClass(board, Board);\n var ptr0 = board.ptr;\n board.ptr = 0;\n wasm.game_push_new_board(this.ptr, ptr0);\n }\n /**\n * Set current board to given\n * @param {Board} board\n */\n set_current(board) {\n _assertClass(board, Board);\n var ptr0 = board.ptr;\n board.ptr = 0;\n wasm.game_set_current(this.ptr, ptr0);\n }\n /**\n * @param {number} width\n * @param {number} height\n * @param {number} piece_rows\n * @param {number} first_turn\n */\n constructor(width, height, piece_rows, first_turn) {\n var ret = wasm.game_new(width, height, piece_rows, first_turn);\n return Game.__wrap(ret);\n }\n /**\n * @param {number} width\n * @param {number} height\n * @param {number} piece_rows\n * @param {number} first_turn\n * @param {string} canvas_id\n * @param {number} canvas_width\n * @param {number} canvas_height\n * @returns {Game}\n */\n static new_with_canvas(width, height, piece_rows, first_turn, canvas_id, canvas_width, canvas_height) {\n var ptr0 = passStringToWasm0(canvas_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len0 = WASM_VECTOR_LEN;\n var ret = wasm.game_new_with_canvas(width, height, piece_rows, first_turn, ptr0, len0, canvas_width, canvas_height);\n return Game.__wrap(ret);\n }\n /**\n * @param {Painter} value\n */\n set_painter(value) {\n _assertClass(value, Painter);\n var ptr0 = value.ptr;\n value.ptr = 0;\n wasm.game_set_painter(this.ptr, ptr0);\n }\n /**\n */\n draw() {\n wasm.game_draw(this.ptr);\n }\n}\n/**\n* Used to paint boards onto HTML canvases\n*/\nexport class Painter {\n\n static __wrap(ptr) {\n const obj = Object.create(Painter.prototype);\n obj.ptr = ptr;\n\n return obj;\n }\n\n __destroy_into_raw() {\n const ptr = this.ptr;\n this.ptr = 0;\n\n return ptr;\n }\n\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_painter_free(ptr);\n }\n /**\n * Default constructor which queries for canvas by ID\n * @param {number} width\n * @param {number} height\n * @param {string} canvas_id\n */\n constructor(width, height, canvas_id) {\n var ptr0 = passStringToWasm0(canvas_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len0 = WASM_VECTOR_LEN;\n var ret = wasm.painter_new(width, height, ptr0, len0);\n return Painter.__wrap(ret);\n }\n /**\n * Constructor with given canvas element\n * @param {number} width\n * @param {number} height\n * @param {HTMLCanvasElement} canvas\n * @returns {Painter}\n */\n static new_with_canvas(width, height, canvas) {\n var ret = wasm.painter_new_with_canvas(width, height, addHeapObject(canvas));\n return Painter.__wrap(ret);\n }\n /**\n * Set new square outline colour value\n * @param {any} value\n */\n set_square_outline(value) {\n wasm.painter_set_square_outline(this.ptr, addHeapObject(value));\n }\n /**\n * Set new line width for outlining squares\n * @param {number} value\n */\n set_outline_width(value) {\n wasm.painter_set_outline_width(this.ptr, value);\n }\n /**\n * Set whether squares are outlined\n * @param {boolean} value\n */\n set_draw_outline(value) {\n wasm.painter_set_draw_outline(this.ptr, value);\n }\n /**\n * Reset the canvas dimensions to the given width and height\n */\n reset_dimensions() {\n wasm.painter_reset_dimensions(this.ptr);\n }\n /**\n * Check whether given canvas dimensions divide evenly by given board dimenions\n * @param {Board} board\n * @returns {boolean}\n */\n validate_board_dim(board) {\n _assertClass(board, Board);\n var ret = wasm.painter_validate_board_dim(this.ptr, board.ptr);\n return ret !== 0;\n }\n /**\n * Draw a board onto the canvas\n * @param {Board} board\n */\n draw(board) {\n _assertClass(board, Board);\n wasm.painter_draw(this.ptr, board.ptr);\n }\n}\n/**\n* Game piece given by its team and strength (normal or kinged)\n*/\nexport class Piece {\n\n static __wrap(ptr) {\n const obj = Object.create(Piece.prototype);\n obj.ptr = ptr;\n\n return obj;\n }\n\n __destroy_into_raw() {\n const ptr = this.ptr;\n this.ptr = 0;\n\n return ptr;\n }\n\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_piece_free(ptr);\n }\n /**\n * @returns {number}\n */\n get team() {\n var ret = wasm.__wbg_get_piece_team(this.ptr);\n return ret >>> 0;\n }\n /**\n * @param {number} arg0\n */\n set team(arg0) {\n wasm.__wbg_set_piece_team(this.ptr, arg0);\n }\n /**\n * @returns {number}\n */\n get strength() {\n var ret = wasm.__wbg_get_piece_strength(this.ptr);\n return ret >>> 0;\n }\n /**\n * @param {number} arg0\n */\n set strength(arg0) {\n wasm.__wbg_set_piece_strength(this.ptr, arg0);\n }\n /**\n * @param {number} team\n * @param {number} strength\n */\n constructor(team, strength) {\n var ret = wasm.piece_new(team, strength);\n return Piece.__wrap(ret);\n }\n}\n/**\n*/\nexport class Player {\n\n __destroy_into_raw() {\n const ptr = this.ptr;\n this.ptr = 0;\n\n return ptr;\n }\n\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_player_free(ptr);\n }\n}\n/**\n* Board squares given by a state and a possible occupying game piece\n*/\nexport class Square {\n\n static __wrap(ptr) {\n const obj = Object.create(Square.prototype);\n obj.ptr = ptr;\n\n return obj;\n }\n\n __destroy_into_raw() {\n const ptr = this.ptr;\n this.ptr = 0;\n\n return ptr;\n }\n\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_square_free(ptr);\n }\n /**\n * Game piece if square is occupied\n * @returns {Piece | undefined}\n */\n get occupant() {\n var ret = wasm.__wbg_get_square_occupant(this.ptr);\n return ret === 0 ? undefined : Piece.__wrap(ret);\n }\n /**\n * Game piece if square is occupied\n * @param {Piece | undefined} arg0\n */\n set occupant(arg0) {\n let ptr0 = 0;\n if (!isLikeNone(arg0)) {\n _assertClass(arg0, Piece);\n ptr0 = arg0.ptr;\n arg0.ptr = 0;\n }\n wasm.__wbg_set_square_occupant(this.ptr, ptr0);\n }\n /**\n * Description of whether the square is occupied or an unplayable, i.e. off-lattice square\n * @returns {number}\n */\n get state() {\n var ret = wasm.__wbg_get_square_state(this.ptr);\n return ret >>> 0;\n }\n /**\n * Description of whether the square is occupied or an unplayable, i.e. off-lattice square\n * @param {number} arg0\n */\n set state(arg0) {\n wasm.__wbg_set_square_state(this.ptr, arg0);\n }\n /**\n * Standard constructor function to form square from state and occupant\n * @param {number} state\n * @param {Piece | undefined} occupant\n */\n constructor(state, occupant) {\n let ptr0 = 0;\n if (!isLikeNone(occupant)) {\n _assertClass(occupant, Piece);\n ptr0 = occupant.ptr;\n occupant.ptr = 0;\n }\n var ret = wasm.square_new(state, ptr0);\n return Square.__wrap(ret);\n }\n /**\n * Helper function for a well-formed piece square by team and strength\n * @param {number} team\n * @param {number} strength\n * @returns {Square}\n */\n static pc(team, strength) {\n var ret = wasm.square_pc(team, strength);\n return Square.__wrap(ret);\n }\n /**\n * Helper function for a well-formed empty square\n * @returns {Square}\n */\n static empty() {\n var ret = wasm.square_empty();\n return Square.__wrap(ret);\n }\n /**\n * Helper function for a well-formed unplayable square\n * @returns {Square}\n */\n static unplay() {\n var ret = wasm.square_unplay();\n return Square.__wrap(ret);\n }\n}\n\nexport function __wbindgen_object_drop_ref(arg0) {\n takeObject(arg0);\n};\n\nexport function __wbindgen_string_new(arg0, arg1) {\n var ret = getStringFromWasm0(arg0, arg1);\n return addHeapObject(ret);\n};\n\nexport function __wbg_new_59cb74e423758ede() {\n var ret = new Error();\n return addHeapObject(ret);\n};\n\nexport function __wbg_stack_558ba5917b466edd(arg0, arg1) {\n var ret = getObject(arg1).stack;\n var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len0 = WASM_VECTOR_LEN;\n getInt32Memory0()[arg0 / 4 + 1] = len0;\n getInt32Memory0()[arg0 / 4 + 0] = ptr0;\n};\n\nexport function __wbg_error_4bb6c2a97407129a(arg0, arg1) {\n try {\n console.error(getStringFromWasm0(arg0, arg1));\n } finally {\n wasm.__wbindgen_free(arg0, arg1);\n }\n};\n\nexport function __wbg_instanceof_Window_11e25482011fc506(arg0) {\n var ret = getObject(arg0) instanceof Window;\n return ret;\n};\n\nexport function __wbg_document_5aff8cd83ef968f5(arg0) {\n var ret = getObject(arg0).document;\n return isLikeNone(ret) ? 0 : addHeapObject(ret);\n};\n\nexport function __wbg_getElementById_b180ea4ada06a837(arg0, arg1, arg2) {\n var ret = getObject(arg0).getElementById(getStringFromWasm0(arg1, arg2));\n return isLikeNone(ret) ? 0 : addHeapObject(ret);\n};\n\nexport function __wbg_log_9a99fb1af846153b(arg0) {\n console.log(getObject(arg0));\n};\n\nexport function __wbg_instanceof_CanvasRenderingContext2d_779e79c4121aa91b(arg0) {\n var ret = getObject(arg0) instanceof CanvasRenderingContext2D;\n return ret;\n};\n\nexport function __wbg_setstrokeStyle_2939ee453716e462(arg0, arg1) {\n getObject(arg0).strokeStyle = getObject(arg1);\n};\n\nexport function __wbg_setfillStyle_af790b5baf4d3210(arg0, arg1) {\n getObject(arg0).fillStyle = getObject(arg1);\n};\n\nexport function __wbg_setlineWidth_3e6b1837ae38d099(arg0, arg1) {\n getObject(arg0).lineWidth = arg1;\n};\n\nexport function __wbg_beginPath_2378575e37027ad3(arg0) {\n getObject(arg0).beginPath();\n};\n\nexport function __wbg_fill_558339447ed6ad43(arg0) {\n getObject(arg0).fill();\n};\n\nexport function __wbg_stroke_c1e0313c58997dcf(arg0) {\n getObject(arg0).stroke();\n};\n\nexport function __wbg_arc_fffd87d9113dce32() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5) {\n getObject(arg0).arc(arg1, arg2, arg3, arg4, arg5);\n}, arguments) };\n\nexport function __wbg_fillRect_46ffc8d2cef7e298(arg0, arg1, arg2, arg3, arg4) {\n getObject(arg0).fillRect(arg1, arg2, arg3, arg4);\n};\n\nexport function __wbg_strokeRect_7ea34fad8a7f0fe2(arg0, arg1, arg2, arg3, arg4) {\n getObject(arg0).strokeRect(arg1, arg2, arg3, arg4);\n};\n\nexport function __wbg_instanceof_HtmlCanvasElement_fd3cbbe3906d7792(arg0) {\n var ret = getObject(arg0) instanceof HTMLCanvasElement;\n return ret;\n};\n\nexport function __wbg_setwidth_f3c88eb520ba8d47(arg0, arg1) {\n getObject(arg0).width = arg1 >>> 0;\n};\n\nexport function __wbg_setheight_5a1abba41e35c42a(arg0, arg1) {\n getObject(arg0).height = arg1 >>> 0;\n};\n\nexport function __wbg_getContext_813df131fcbd6e91() { return handleError(function (arg0, arg1, arg2) {\n var ret = getObject(arg0).getContext(getStringFromWasm0(arg1, arg2));\n return isLikeNone(ret) ? 0 : addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_newnoargs_9fdd8f3961dd1bee(arg0, arg1) {\n var ret = new Function(getStringFromWasm0(arg0, arg1));\n return addHeapObject(ret);\n};\n\nexport function __wbg_call_ba36642bd901572b() { return handleError(function (arg0, arg1) {\n var ret = getObject(arg0).call(getObject(arg1));\n return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_self_bb69a836a72ec6e9() { return handleError(function () {\n var ret = self.self;\n return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_window_3304fc4b414c9693() { return handleError(function () {\n var ret = window.window;\n return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_globalThis_e0d21cabc6630763() { return handleError(function () {\n var ret = globalThis.globalThis;\n return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_global_8463719227271676() { return handleError(function () {\n var ret = global.global;\n return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbindgen_is_undefined(arg0) {\n var ret = getObject(arg0) === undefined;\n return ret;\n};\n\nexport function __wbindgen_object_clone_ref(arg0) {\n var ret = getObject(arg0);\n return addHeapObject(ret);\n};\n\nexport function __wbindgen_debug_string(arg0, arg1) {\n var ret = debugString(getObject(arg1));\n var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len0 = WASM_VECTOR_LEN;\n getInt32Memory0()[arg0 / 4 + 1] = len0;\n getInt32Memory0()[arg0 / 4 + 0] = ptr0;\n};\n\nexport function __wbindgen_throw(arg0, arg1) {\n throw new Error(getStringFromWasm0(arg0, arg1));\n};\n\n","import { Game, Board, BrdIdx, Painter, Team, init_wasm, Moveable, SquareState } from \"draught\";\nimport { memory } from \"draught/draught_bg.wasm\";\n\n///////////////////\n// CONSTS\n///////////////////\n\nconst CANVAS_WIDTH = 480;\nconst CANVAS_HEIGHT = 480;\n\nconst BOARD_WIDTH = 8;\nconst BOARD_HEIGHT = 8;\n\nconst PIECE_ROWS = 3;\n\nconst GameState = {\n HUMAN_TURN: {\n THINKING: \"human_turn.thinking\",\n FROM_SELECTED: \"human_turn.from_selected\"\n },\n AI_TURN: \"ai_turn\"\n}\n\n//////////////////\n// GAME STUFF\n//////////////////\n\ninit_wasm();\n\n// let board = new Board(BOARD_WIDTH, BOARD_HEIGHT, Team.Black);\n\nconst statusText = document.getElementById(\"status-p\");\n\nlet current_state = GameState.HUMAN_TURN.THINKING;\nlet painter = new Painter(CANVAS_WIDTH, CANVAS_HEIGHT, \"game-canvas\");\n// painter.draw(board);\n\nlet clicks = [];\n\nlet from = null;\nlet to = null;\n\nlet game = new Game(BOARD_WIDTH, BOARD_HEIGHT, PIECE_ROWS, Team.Black);\ngame.set_painter(painter);\ngame.draw();\n\n/////////////////\n// CANVAS\n/////////////////\n\nconst canvas = document.getElementById(\"game-canvas\");\ncanvas.addEventListener(\"click\", (event) => {\n var mousepos = getMousePos(canvas, event);\n // console.log(mousepos);\n var cell = new BrdIdx(\n Math.floor((mousepos.y / CANVAS_HEIGHT) * BOARD_HEIGHT),\n Math.floor((mousepos.x / CANVAS_WIDTH) * BOARD_WIDTH),\n );\n // console.log(cell);\n process_canvas_click(cell);\n})\n\n////////////////\n// FUNCS\n////////////////\n\nfunction start_game() {\n game = new Game(BOARD_WIDTH, BOARD_HEIGHT, PIECE_ROWS, Team.Black);\n game.set_painter(painter);\n game.draw();\n\n current_state = GameState.HUMAN_TURN.THINKING;\n}\n\nfunction process_canvas_click(cell_coord) {\n\n // if (game.current_cell_state(cell_coord).state == SquareState.Unplayable ) {\n // from = null;\n // to = null;\n // current_state = GameState.HUMAN_TURN.THINKING;\n // setStatusText(\"Unplayable Square!\");\n // return;\n // }\n\n switch(current_state) {\n case GameState.HUMAN_TURN.THINKING:\n console.log(\"Your turn, first piece picked\");\n\n clicks.push(cell_coord);\n\n // from = cell_coord;\n current_state = GameState.HUMAN_TURN.FROM_SELECTED; \n \n break;\n case GameState.HUMAN_TURN.FROM_SELECTED:\n console.log(\"Your turn, first piece already picked, picking second\");\n\n clicks.push(cell_coord);\n\n // to = cell_coord;\n\n if (clicks.length != 2) {\n setStatusText(`Error: wrong number of clicks to process ${clicks.length}`);\n console.error(`Error: wrong number of clicks to process ${clicks.length}`);\n\n return;\n }\n\n // console.log(clicks[0].eq(clicks[1]));\n\n if (clicks[0].eq(clicks[1])) {\n setStatusText(\"Move Cancelled\");\n } else {\n\n let status = game.make_move(clicks[0], clicks[1]);\n\n switch(status) {\n case Moveable.Allowed:\n break;\n case Moveable.IllegalTrajectory:\n break;\n case Moveable.JumpingSameTeam:\n break;\n case Moveable.NoJumpablePiece:\n break;\n case Moveable.OccupiedDest:\n break;\n case Moveable.OutOfBounds:\n break;\n case Moveable.UnoccupiedSrc:\n break;\n case Moveable.Unplayable:\n break;\n case Moveable.WrongTeamSrc:\n break;\n }\n \n }\n\n game.draw();\n clicks = [];\n // from = null;\n // to = null;\n current_state = GameState.HUMAN_TURN.THINKING;\n \n break;\n case GameState.AI_TURN:\n console.log(\"It's the AI's turn!\");\n break;\n }\n}\n\nfunction getMousePos(canvas, evt) {\n var rect = canvas.getBoundingClientRect();\n return {\n x: evt.clientX - rect.left,\n y: evt.clientY - rect.top\n };\n}\n\nfunction setStatusText(txt) {\n statusText.hidden = false;\n statusText.innerText = txt;\n}\n\n"],"sourceRoot":""} \ No newline at end of file diff --git a/4ee49dc6adc51094e53f.module.wasm b/29964598fec03e30f3aa.module.wasm similarity index 50% rename from 4ee49dc6adc51094e53f.module.wasm rename to 29964598fec03e30f3aa.module.wasm index 5182263..d618abe 100644 Binary files a/4ee49dc6adc51094e53f.module.wasm and b/29964598fec03e30f3aa.module.wasm differ diff --git a/doc/draught/board/index.html b/doc/draught/board/index.html index cb80850..9e7d056 100644 --- a/doc/draught/board/index.html +++ b/doc/draught/board/index.html @@ -1,7 +1,7 @@ draught::board - Rust

Module draught::board[][src]

Board module for components related to the checkers board and game structure

+ Change settings

Module draught::board[][src]

Board module for components related to the checkers board and game structure

Modules

enums
iter

Structs

Board

Single state of a checkers board

diff --git a/doc/draught/board/struct.Board.html b/doc/draught/board/struct.Board.html index b702c4b..2b1b0b5 100644 --- a/doc/draught/board/struct.Board.html +++ b/doc/draught/board/struct.Board.html @@ -1,7 +1,7 @@ Board in draught::board - Rust

Struct draught::board::Board[][src]

pub struct Board {
+                Change settings

Struct draught::board::Board[][src]

pub struct Board {
     cells: Vec<Square>,
     pub width: usize,
     pub height: usize,
@@ -9,76 +9,76 @@
 }

Single state of a checkers board

Fields

cells: Vec<Square>

1D backing array of board squares for the 2D game board

-
width: usizeheight: usizecurrent_turn: Team

Implementations

impl Board[src]

pub fn cell_mut(&mut self, idx: usize) -> &mut Square[src]

Get a mutable reference to a board square by 1D array index

-

pub fn adjacent_indices(&self, idx: BrdIdx) -> Option<Vec<usize>>[src]

Get the 1D array indices for the diagonally adjacent squares of a given board square

+
width: usizeheight: usizecurrent_turn: Team

Implementations

impl Board[src]

pub fn cell_mut(&mut self, idx: usize) -> &mut Square[src]

Get a mutable reference to a board square by 1D array index

+

pub fn adjacent_indices(&self, idx: BrdIdx) -> Option<Vec<usize>>[src]

Get the 1D array indices for the diagonally adjacent squares of a given board square

Returns

None: If the given square is unplayable

Some(Vec): A variable length vector of 1D indices for diagonally adjacent squares. Vector may be between 1 and 4 items long depending on the location of the given square

-

pub fn adjacent_dir(&self, idx: BrdIdx) -> Option<Direction<Square>>[src]

Get a Direction structure for the diagonally adjacent squares of a given board square

+

pub fn adjacent_dir(&self, idx: BrdIdx) -> Option<Direction<Square>>[src]

Get a Direction structure for the diagonally adjacent squares of a given board square

Similar to the Board::adjacent_indices function with differently formatted results

Returns

None: If the given square is unplayable

Some(Direction): A Direction structure for the diagonally adjacent squares.

-

pub fn filter_indices(
    &self,
    idx: BrdIdx,
    player: Team,
    indices: Vec<usize>
) -> Vec<usize>
[src]

Filter an array of diagonal indices (Like those from Board::adjacent_indices, Board::jumpable_indices) for those that are legal for a team’s man, i.e. solely up or down the board

-

pub fn player_adjacent_indices(
    &self,
    idx: BrdIdx,
    player: Team
) -> Option<Vec<usize>>
[src]

pub fn jumpable_indices(&self, idx: BrdIdx) -> Option<Vec<usize>>[src]

Get the 1D array indices for the diagonally jumpable squares of a given board square

+

pub fn filter_indices(
    &self,
    idx: BrdIdx,
    player: Team,
    indices: Vec<usize>
) -> Vec<usize>
[src]

Filter an array of diagonal indices (Like those from Board::adjacent_indices, Board::jumpable_indices) for those that are legal for a team’s man, i.e. solely up or down the board

+

pub fn player_adjacent_indices(
    &self,
    idx: BrdIdx,
    player: Team
) -> Option<Vec<usize>>
[src]

pub fn jumpable_indices(&self, idx: BrdIdx) -> Option<Vec<usize>>[src]

Get the 1D array indices for the diagonally jumpable squares of a given board square

Returns

None: If the given square is unplayable

Some(Vec): A variable length vector of 1D indices for diagonally jumpable squares. Vector may be between 1 and 4 items long depending on the location of the given square

-

pub fn jumpable_dir(&self, idx: BrdIdx) -> Option<Direction<Square>>[src]

Get a Direction structure for the diagonally jumpable squares of a given board square

+

pub fn jumpable_dir(&self, idx: BrdIdx) -> Option<Direction<Square>>[src]

Get a Direction structure for the diagonally jumpable squares of a given board square

Similar to the Board::jumpable_indices function with differently formatted results

Returns

None: If the given square is unplayable

Some(Direction): A Direction structure for the diagonally jumpable squares.

-

pub fn player_jumpable_indices(
    &self,
    idx: BrdIdx,
    player: Team
) -> Option<Vec<usize>>
[src]

pub fn idx_diffs(from: BrdIdx, to: BrdIdx) -> (isize, isize)[src]

Get the difference between two BrdIdx objects

-

impl Board[src]

pub fn cell(&self, idx: usize) -> Square[src]

Get a copy of a board square by 1D array index

-

pub fn set_cell(&mut self, idx: usize, square: Square)[src]

Get a copy of a board square by 1D array index

-

pub fn grid_cell(&self, idx: BrdIdx) -> Square[src]

Get a copy of a board square by 2D BrdIdx index

-

pub fn cell_index(&self, row: usize, col: usize) -> usize[src]

Transform a 2D row/column board index into a single 1D index for use with Board::cells

-

pub fn cell_idx(&self, idx: BrdIdx) -> usize[src]

Similar to Board::cell_index but with a BrdIdx instead of separate indices. Transform a 2D row/column board index into a single 1D index for use with Board::cells

-

pub fn board_index(&self, idx: usize) -> BrdIdx[src]

Transform a 1D array index (for Board::cells) into a 2D game board index (by row/col)

-

pub fn can_move(&self, from: BrdIdx, to: BrdIdx) -> Moveable[src]

Check whether a move given by source and destination indices is legal

-

pub fn validate_man_move(
    &self,
    from: BrdIdx,
    to: BrdIdx,
    from_square_occupant: Piece
) -> Moveable
[src]

pub fn validate_king_move(
    &self,
    from: BrdIdx,
    to: BrdIdx,
    from_square_occupant: Piece
) -> Moveable
[src]

pub fn jumpee_idx(&self, from: BrdIdx, to: BrdIdx) -> usize[src]

pub fn cells(&self) -> *const Square[src]

Get a pointer to the backing array of board squares, Board::cells

-

pub fn num_cells(&self) -> usize[src]

Get the number of board squares

-

pub fn num_pieces(&self) -> usize[src]

Get the number of remaining pieces

-

pub fn num_player(&self, team: Team) -> usize[src]

Get the number of remaining pieces for a player

-

pub fn score(&self) -> isize[src]

Get the score value, Black - White pieces

-

pub fn cell_state(&self, idx: usize) -> SquareState[src]

Get the state of a board square by 1D array index

-

pub fn apply_move(&self, from: BrdIdx, to: BrdIdx) -> Board[src]

pub fn apply_jump(&self, from: BrdIdx, to: BrdIdx) -> Board[src]

impl Board[src]

pub fn validate_jumpee(jumpee: Square, from_occ: Piece) -> Moveable[src]

Unwrap the jumpee piece from the square and Board::check_jumpee_team with Moveable response

-

pub fn check_jumpee_team(from: Piece, jumpee: Piece) -> bool[src]

Check that the source piece and the jumpee are of opposing teams

-

pub fn new(width: usize, height: usize, current_turn: Team) -> Board[src]

Initialise a game board without game pieces

-

pub fn init_game(board: Board, piece_rows: usize) -> Board[src]

Reset the given board to a starting layout with 3 rows of opposing pieces

-

Trait Implementations

impl Clone for Board[src]

pub fn player_jumpable_indices(
    &self,
    idx: BrdIdx,
    player: Team
) -> Option<Vec<usize>>
[src]

pub fn idx_diffs(from: BrdIdx, to: BrdIdx) -> (isize, isize)[src]

Get the difference between two BrdIdx objects

+

impl Board[src]

pub fn cell(&self, idx: usize) -> Square[src]

Get a copy of a board square by 1D array index

+

pub fn set_cell(&mut self, idx: usize, square: Square)[src]

Get a copy of a board square by 1D array index

+

pub fn grid_cell(&self, idx: BrdIdx) -> Square[src]

Get a copy of a board square by 2D BrdIdx index

+

pub fn cell_index(&self, row: usize, col: usize) -> usize[src]

Transform a 2D row/column board index into a single 1D index for use with Board::cells

+

pub fn cell_idx(&self, idx: BrdIdx) -> usize[src]

Similar to Board::cell_index but with a BrdIdx instead of separate indices. Transform a 2D row/column board index into a single 1D index for use with Board::cells

+

pub fn board_index(&self, idx: usize) -> BrdIdx[src]

Transform a 1D array index (for Board::cells) into a 2D game board index (by row/col)

+

pub fn can_move(&self, from: BrdIdx, to: BrdIdx) -> Moveable[src]

Check whether a move given by source and destination indices is legal

+

pub fn validate_man_move(
    &self,
    from: BrdIdx,
    to: BrdIdx,
    from_square_occupant: Piece
) -> Moveable
[src]

pub fn validate_king_move(
    &self,
    from: BrdIdx,
    to: BrdIdx,
    from_square_occupant: Piece
) -> Moveable
[src]

pub fn jumpee_idx(&self, from: BrdIdx, to: BrdIdx) -> usize[src]

pub fn cells(&self) -> *const Square[src]

Get a pointer to the backing array of board squares, Board::cells

+

pub fn num_cells(&self) -> usize[src]

Get the number of board squares

+

pub fn num_pieces(&self) -> usize[src]

Get the number of remaining pieces

+

pub fn num_player(&self, team: Team) -> usize[src]

Get the number of remaining pieces for a player

+

pub fn score(&self) -> isize[src]

Get the score value, Black - White pieces

+

pub fn cell_state(&self, idx: usize) -> SquareState[src]

Get the state of a board square by 1D array index

+

pub fn apply_move(&self, from: BrdIdx, to: BrdIdx) -> Board[src]

pub fn apply_jump(&self, from: BrdIdx, to: BrdIdx) -> Board[src]

impl Board[src]

pub fn validate_jumpee(jumpee: Square, from_occ: Piece) -> Moveable[src]

Unwrap the jumpee piece from the square and Board::check_jumpee_team with Moveable response

+

pub fn check_jumpee_team(from: Piece, jumpee: Piece) -> bool[src]

Check that the source piece and the jumpee are of opposing teams

+

pub fn new(width: usize, height: usize, current_turn: Team) -> Board[src]

Initialise a game board without game pieces

+

pub fn init_game(board: Board, piece_rows: usize) -> Board[src]

Reset the given board to a starting layout with 3 rows of opposing pieces

+

Trait Implementations

impl Clone for Board[src]

impl Debug for Board[src]

impl Display for Board[src]

impl From<Board> for JsValue[src]

impl FromWasmAbi for Board[src]

type Abi = u32

The wasm ABI type that this converts from when coming back out from the +

impl Debug for Board[src]

impl Display for Board[src]

impl From<Board> for JsValue[src]

impl FromWasmAbi for Board[src]

type Abi = u32

The wasm ABI type that this converts from when coming back out from the ABI boundary. Read more

-

impl IntoWasmAbi for Board[src]

type Abi = u32

The wasm ABI type that this converts into when crossing the ABI +

impl IntoWasmAbi for Board[src]

type Abi = u32

The wasm ABI type that this converts into when crossing the ABI boundary. Read more

-

impl OptionFromWasmAbi for Board[src]

impl OptionFromWasmAbi for Board[src]

impl OptionIntoWasmAbi for Board[src]

impl OptionIntoWasmAbi for Board[src]

impl PartialEq<Board> for Board[src]

impl PartialEq<Board> for Board[src]

impl RefFromWasmAbi for Board[src]

type Abi = u32

The wasm ABI type references to Self are recovered from.

+

impl RefFromWasmAbi for Board[src]

type Abi = u32

The wasm ABI type references to Self are recovered from.

type Anchor = Ref<'static, Board>

The type that holds the reference to Self for the duration of the invocation of the function that has an &Self parameter. This is required to ensure that the lifetimes don’t persist beyond one function call, and so that they remain anonymous. Read more

-

impl RefMutFromWasmAbi for Board[src]

type Abi = u32

Same as RefFromWasmAbi::Abi

+

impl RefMutFromWasmAbi for Board[src]

type Abi = u32

Same as RefFromWasmAbi::Abi

type Anchor = RefMut<'static, Board>

Same as RefFromWasmAbi::Anchor

-

impl WasmDescribe for Board[src]

impl Eq for Board[src]

impl StructuralEq for Board[src]

impl StructuralPartialEq for Board[src]

Auto Trait Implementations

impl RefUnwindSafe for Board

impl Send for Board

impl Sync for Board

impl Unpin for Board

impl UnwindSafe for Board

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl WasmDescribe for Board[src]

impl Eq for Board[src]

impl StructuralEq for Board[src]

impl StructuralPartialEq for Board[src]

Auto Trait Implementations

impl RefUnwindSafe for Board

impl Send for Board

impl Sync for Board

impl Unpin for Board

impl UnwindSafe for Board

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]