text: Dagaz.Controller.persistense = "none";
  Dagaz.Model.WIDTH = 10;
  
  ZRF = {
      JUMP:          0,
      IF:            1,
      FORK:          2,
      FUNCTION:      3,
      IN_ZONE:       4,
      FLAG:          5,
      SET_FLAG:      6,
      POS_FLAG:      7,
      SET_POS_FLAG:  8,
      ATTR:          9,
      SET_ATTR:      10,
      PROMOTE:       11,
      MODE:          12,
      ON_BOARD_DIR:  13,
      ON_BOARD_POS:  14,
      PARAM:         15,
      LITERAL:       16,
      VERIFY:        20
  };
  
  if (!_.isUndefined(Dagaz.Controller.addSound)) {
      Dagaz.Controller.addSound(0, "sounds/wind.wav", true);
      Dagaz.Controller.addSound(2,  "sounds/tadam.wav", true);
      Dagaz.Controller.addSound(3, "sounds/loss.wav", true);
  }
  
  Dagaz.Model.BuildDesign = function(design) {
      design.checkVersion("z2j", "2");
      design.checkVersion("animate-captures", "false");
      design.checkVersion("smart-moves", "false");
      design.checkVersion("show-hints", "false");
      design.checkVersion("show-blink", "true");
      design.checkVersion("maximal-captures", "true");
      design.checkVersion("deferred-captures", "true");
      design.checkVersion("advisor-wait", "15");
      design.checkVersion("international-extension", "true");
  
      design.addDirection("se");
      design.addDirection("sw");
      design.addDirection("ne");
      design.addDirection("nw");
  
      design.addPlayer("White", [3, 2, 1, 0]);
      design.addPlayer("Black", [3, 2, 1, 0]);
  
      design.addPosition("a10", [11, 0, 0, 0]);
      design.addPosition("b10", [11, 9, 0, 0]);
      design.addPosition("c10", [11, 9, 0, 0]);
      design.addPosition("d10", [11, 9, 0, 0]);
      design.addPosition("e10", [11, 9, 0, 0]);
      design.addPosition("f10", [11, 9, 0, 0]);
      design.addPosition("g10", [11, 9, 0, 0]);
      design.addPosition("h10", [11, 9, 0, 0]);
      design.addPosition("i10", [11, 9, 0, 0]);
      design.addPosition("j10", [0, 9, 0, 0]);
      design.addPosition("a9", [11, 0, -9, 0]);
      design.addPosition("b9", [11, 9, -9, -11]);
      design.addPosition("c9", [11, 9, -9, -11]);
      design.addPosition("d9", [11, 9, -9, -11]);
      design.addPosition("e9", [11, 9, -9, -11]);
      design.addPosition("f9", [11, 9, -9, -11]);
      design.addPosition("g9", [11, 9, -9, -11]);
      design.addPosition("h9", [11, 9, -9, -11]);
      design.addPosition("i9", [11, 9, -9, -11]);
      design.addPosition("j9", [0, 9, 0, -11]);
      design.addPosition("a8", [11, 0, -9, 0]);
      design.addPosition("b8", [11, 9, -9, -11]);
      design.addPosition("c8", [11, 9, -9, -11]);
      design.addPosition("d8", [11, 9, -9, -11]);
      design.addPosition("e8", [11, 9, -9, -11]);
      design.addPosition("f8", [11, 9, -9, -11]);
      design.addPosition("g8", [11, 9, -9, -11]);
      design.addPosition("h8", [11, 9, -9, -11]);
      design.addPosition("i8", [11, 9, -9, -11]);
      design.addPosition("j8", [0, 9, 0, -11]);
      design.addPosition("a7", [11, 0, -9, 0]);
      design.addPosition("b7", [11, 9, -9, -11]);
      design.addPosition("c7", [11, 9, -9, -11]);
      design.addPosition("d7", [11, 9, -9, -11]);
      design.addPosition("e7", [11, 9, -9, -11]);
      design.addPosition("f7", [11, 9, -9, -11]);
      design.addPosition("g7", [11, 9, -9, -11]);
      design.addPosition("h7", [11, 9, -9, -11]);
      design.addPosition("i7", [11, 9, -9, -11]);
      design.addPosition("j7", [0, 9, 0, -11]);
      design.addPosition("a6", [11, 0, -9, 0]);
      design.addPosition("b6", [11, 9, -9, -11]);
      design.addPosition("c6", [11, 9, -9, -11]);
      design.addPosition("d6", [11, 9, -9, -11]);
      design.addPosition("e6", [11, 9, -9, -11]);
      design.addPosition("f6", [11, 9, -9, -11]);
      design.addPosition("g6", [11, 9, -9, -11]);
      design.addPosition("h6", [11, 9, -9, -11]);
      design.addPosition("i6", [11, 9, -9, -11]);
      design.addPosition("j6", [0, 9, 0, -11]);
      design.addPosition("a5", [11, 0, -9, 0]);
      design.addPosition("b5", [11, 9, -9, -11]);
      design.addPosition("c5", [11, 9, -9, -11]);
      design.addPosition("d5", [11, 9, -9, -11]);
      design.addPosition("e5", [11, 9, -9, -11]);
      design.addPosition("f5", [11, 9, -9, -11]);
      design.addPosition("g5", [11, 9, -9, -11]);
      design.addPosition("h5", [11, 9, -9, -11]);
      design.addPosition("i5", [11, 9, -9, -11]);
      design.addPosition("j5", [0, 9, 0, -11]);
      design.addPosition("a4", [11, 0, -9, 0]);
      design.addPosition("b4", [11, 9, -9, -11]);
      design.addPosition("c4", [11, 9, -9, -11]);
      design.addPosition("d4", [11, 9, -9, -11]);
      design.addPosition("e4", [11, 9, -9, -11]);
      design.addPosition("f4", [11, 9, -9, -11]);
      design.addPosition("g4", [11, 9, -9, -11]);
      design.addPosition("h4", [11, 9, -9, -11]);
      design.addPosition("i4", [11, 9, -9, -11]);
      design.addPosition("j4", [0, 9, 0, -11]);
      design.addPosition("a3", [11, 0, -9, 0]);
      design.addPosition("b3", [11, 9, -9, -11]);
      design.addPosition("c3", [11, 9, -9, -11]);
      design.addPosition("d3", [11, 9, -9, -11]);
      design.addPosition("e3", [11, 9, -9, -11]);
      design.addPosition("f3", [11, 9, -9, -11]);
      design.addPosition("g3", [11, 9, -9, -11]);
      design.addPosition("h3", [11, 9, -9, -11]);
      design.addPosition("i3", [11, 9, -9, -11]);
      design.addPosition("j3", [0, 9, 0, -11]);
      design.addPosition("a2", [11, 0, -9, 0]);
      design.addPosition("b2", [11, 9, -9, -11]);
      design.addPosition("c2", [11, 9, -9, -11]);
      design.addPosition("d2", [11, 9, -9, -11]);
      design.addPosition("e2", [11, 9, -9, -11]);
      design.addPosition("f2", [11, 9, -9, -11]);
      design.addPosition("g2", [11, 9, -9, -11]);
      design.addPosition("h2", [11, 9, -9, -11]);
      design.addPosition("i2", [11, 9, -9, -11]);
      design.addPosition("j2", [0, 9, 0, -11]);
      design.addPosition("a1", [0, 0, -9, 0]);
      design.addPosition("b1", [0, 0, -9, -11]);
      design.addPosition("c1", [0, 0, -9, -11]);
      design.addPosition("d1", [0, 0, -9, -11]);
      design.addPosition("e1", [0, 0, -9, -11]);
      design.addPosition("f1", [0, 0, -9, -11]);
      design.addPosition("g1", [0, 0, -9, -11]);
      design.addPosition("h1", [0, 0, -9, -11]);
      design.addPosition("i1", [0, 0, -9, -11]);
      design.addPosition("j1", [0, 0, 0, -11]);
  
      design.addZone("promotion", 1, [1, 3, 5, 7, 9]);
      design.addZone("promotion", 2, [90, 92, 94, 96, 98]);
  
      design.addCommand(0, ZRF.FUNCTION,	24);	// from
      design.addCommand(0, ZRF.PARAM,	0);	// $1
      design.addCommand(0, ZRF.FUNCTION,	22);	// navigate
      design.addCommand(0, ZRF.FUNCTION,	2);	// enemy?
      design.addCommand(0, ZRF.FUNCTION,	20);	// verify
      design.addCommand(0, ZRF.FUNCTION,	26);	// capture
      design.addCommand(0, ZRF.PARAM,	1);	// $2
      design.addCommand(0, ZRF.FUNCTION,	22);	// navigate
      design.addCommand(0, ZRF.FUNCTION,	1);	// empty?
      design.addCommand(0, ZRF.FUNCTION,	20);	// verify
      design.addCommand(0, ZRF.MODE,	0);	// jump-type
      design.addCommand(0, ZRF.FUNCTION,	25);	// to
      design.addCommand(0, ZRF.FUNCTION,	28);	// end
  
      design.addCommand(1, ZRF.FUNCTION,	24);	// from
      design.addCommand(1, ZRF.PARAM,	0);	// $1
      design.addCommand(1, ZRF.FUNCTION,	22);	// navigate
      design.addCommand(1, ZRF.FUNCTION,	1);	// empty?
      design.addCommand(1, ZRF.FUNCTION,	20);	// verify
      design.addCommand(1, ZRF.FUNCTION,	25);	// to
      design.addCommand(1, ZRF.FUNCTION,	28);	// end
  
      design.addCommand(2, ZRF.FUNCTION,	24);	// from
      design.addCommand(2, ZRF.PARAM,	0);	// $1
      design.addCommand(2, ZRF.FUNCTION,	22);	// navigate
      design.addCommand(2, ZRF.FUNCTION,	1);	// empty?
      design.addCommand(2, ZRF.FUNCTION,	0);	// not
      design.addCommand(2, ZRF.IF,	4);
      design.addCommand(2, ZRF.PARAM,	1);	// $2
      design.addCommand(2, ZRF.FUNCTION,	22);	// navigate
      design.addCommand(2, ZRF.JUMP,	-5);
      design.addCommand(2, ZRF.FUNCTION,	2);	// enemy?
      design.addCommand(2, ZRF.FUNCTION,	20);	// verify
      design.addCommand(2, ZRF.PARAM,	2);	// $3
      design.addCommand(2, ZRF.FUNCTION,	22);	// navigate
      design.addCommand(2, ZRF.FUNCTION,	1);	// empty?
      design.addCommand(2, ZRF.FUNCTION,	0);	// not
      design.addCommand(2, ZRF.IF,	18);
      design.addCommand(2, ZRF.FUNCTION,	6);	// mark
      design.addCommand(2, ZRF.FUNCTION,	1);	// empty?
      design.addCommand(2, ZRF.FUNCTION,	0);	// not
      design.addCommand(2, ZRF.IF,	5);
      design.addCommand(2, ZRF.PARAM,	3);	// $4
      design.addCommand(2, ZRF.FUNCTION,	23);	// opposite
      design.addCommand(2, ZRF.FUNCTION,	22);	// navigate
      design.addCommand(2, ZRF.JUMP,	-6);
      design.addCommand(2, ZRF.FUNCTION,	26);	// capture
      design.addCommand(2, ZRF.FUNCTION,	7);	// back
      design.addCommand(2, ZRF.FORK,	4);
      design.addCommand(2, ZRF.MODE,	2);	// cont-type
      design.addCommand(2, ZRF.FUNCTION,	25);	// to
      design.addCommand(2, ZRF.FUNCTION,	28);	// end
      design.addCommand(2, ZRF.PARAM,	4);	// $5
      design.addCommand(2, ZRF.FUNCTION,	22);	// navigate
      design.addCommand(2, ZRF.JUMP,	-19);
      design.addCommand(2, ZRF.FUNCTION,	28);	// end
  
      design.addCommand(3, ZRF.FUNCTION,	24);	// from
      design.addCommand(3, ZRF.PARAM,	0);	// $1
      design.addCommand(3, ZRF.FUNCTION,	22);	// navigate
      design.addCommand(3, ZRF.FUNCTION,	1);	// empty?
      design.addCommand(3, ZRF.FUNCTION,	0);	// not
      design.addCommand(3, ZRF.IF,	7);
      design.addCommand(3, ZRF.PARAM,	1);	// $2
      design.addCommand(3, ZRF.FUNCTION,	22);	// navigate
      design.addCommand(3, ZRF.FUNCTION,	4);	// last-from?
      design.addCommand(3, ZRF.FUNCTION,	0);	// not
      design.addCommand(3, ZRF.FUNCTION,	20);	// verify
      design.addCommand(3, ZRF.JUMP,	-8);
      design.addCommand(3, ZRF.FUNCTION,	2);	// enemy?
      design.addCommand(3, ZRF.FUNCTION,	20);	// verify
      design.addCommand(3, ZRF.PARAM,	2);	// $3
      design.addCommand(3, ZRF.FUNCTION,	22);	// navigate
      design.addCommand(3, ZRF.FUNCTION,	1);	// empty?
      design.addCommand(3, ZRF.FUNCTION,	0);	// not
      design.addCommand(3, ZRF.IF,	18);
      design.addCommand(3, ZRF.FUNCTION,	6);	// mark
      design.addCommand(3, ZRF.FUNCTION,	1);	// empty?
      design.addCommand(3, ZRF.FUNCTION,	0);	// not
      design.addCommand(3, ZRF.IF,	5);
      design.addCommand(3, ZRF.PARAM,	3);	// $4
      design.addCommand(3, ZRF.FUNCTION,	23);	// opposite
      design.addCommand(3, ZRF.FUNCTION,	22);	// navigate
      design.addCommand(3, ZRF.JUMP,	-6);
      design.addCommand(3, ZRF.FUNCTION,	26);	// capture
      design.addCommand(3, ZRF.FUNCTION,	7);	// back
      design.addCommand(3, ZRF.FORK,	4);
      design.addCommand(3, ZRF.MODE,	2);	// cont-type
      design.addCommand(3, ZRF.FUNCTION,	25);	// to
      design.addCommand(3, ZRF.FUNCTION,	28);	// end
      design.addCommand(3, ZRF.PARAM,	4);	// $5
      design.addCommand(3, ZRF.FUNCTION,	22);	// navigate
      design.addCommand(3, ZRF.JUMP,	-19);
      design.addCommand(3, ZRF.FUNCTION,	28);	// end
  
      design.addCommand(4, ZRF.FUNCTION,	24);	// from
      design.addCommand(4, ZRF.PARAM,	0);	// $1
      design.addCommand(4, ZRF.FUNCTION,	22);	// navigate
      design.addCommand(4, ZRF.FUNCTION,	1);	// empty?
      design.addCommand(4, ZRF.FUNCTION,	0);	// not
      design.addCommand(4, ZRF.IF,	7);
      design.addCommand(4, ZRF.FORK,	3);
      design.addCommand(4, ZRF.FUNCTION,	25);	// to
      design.addCommand(4, ZRF.FUNCTION,	28);	// end
      design.addCommand(4, ZRF.PARAM,	1);	// $2
      design.addCommand(4, ZRF.FUNCTION,	22);	// navigate
      design.addCommand(4, ZRF.JUMP,	-8);
      design.addCommand(4, ZRF.FUNCTION,	28);	// end
  
      design.addPriority(0);			// jump-type
      design.addPriority(1);			// normal-type
  
      design.addPiece("Man", 0, 20);
      design.addMove(0, 0, [3, 3], 0);
      design.addMove(0, 0, [2, 2], 0);
      design.addMove(0, 0, [1, 1], 0);
      design.addMove(0, 0, [0, 0], 0);
      design.addMove(0, 1, [3], 1);
      design.addMove(0, 1, [2], 1);
  
      design.addPiece("King", 1, 100);
      design.addMove(1, 2, [3, 3, 3, 3, 3], 0);
      design.addMove(1, 2, [2, 2, 2, 2, 2], 0);
      design.addMove(1, 2, [1, 1, 1, 1, 1], 0);
      design.addMove(1, 2, [0, 0, 0, 0, 0], 0);
      design.addMove(1, 3, [3, 3, 3, 3, 3], 2);
      design.addMove(1, 3, [2, 2, 2, 2, 2], 2);
      design.addMove(1, 3, [1, 1, 1, 1, 1], 2);
      design.addMove(1, 3, [0, 0, 0, 0, 0], 2);
      design.addMove(1, 4, [3, 3], 1);
      design.addMove(1, 4, [2, 2], 1);
      design.addMove(1, 4, [1, 1], 1);
      design.addMove(1, 4, [0, 0], 1);
  
      design.setup("White", "Man", 90);
      design.setup("White", "Man", 92);
      design.setup("White", "Man", 94);
      design.setup("White", "Man", 96);
      design.setup("White", "Man", 98);
      design.setup("White", "Man", 81);
      design.setup("White", "Man", 83);
      design.setup("White", "Man", 85);
      design.setup("White", "Man", 87);
      design.setup("White", "Man", 89);
      design.setup("White", "Man", 70);
      design.setup("White", "Man", 72);
      design.setup("White", "Man", 74);
      design.setup("White", "Man", 76);
      design.setup("White", "Man", 78);
      design.setup("White", "Man", 61);
      design.setup("White", "Man", 63);
      design.setup("White", "Man", 65);
      design.setup("White", "Man", 67);
      design.setup("White", "Man", 69);
      design.setup("Black", "Man", 1);
      design.setup("Black", "Man", 3);
      design.setup("Black", "Man", 5);
      design.setup("Black", "Man", 7);
      design.setup("Black", "Man", 9);
      design.setup("Black", "Man", 10);
      design.setup("Black", "Man", 12);
      design.setup("Black", "Man", 14);
      design.setup("Black", "Man", 16);
      design.setup("Black", "Man", 18);
      design.setup("Black", "Man", 21);
      design.setup("Black", "Man", 23);
      design.setup("Black", "Man", 25);
      design.setup("Black", "Man", 27);
      design.setup("Black", "Man", 29);
      design.setup("Black", "Man", 30);
      design.setup("Black", "Man", 32);
      design.setup("Black", "Man", 34);
      design.setup("Black", "Man", 36);
      design.setup("Black", "Man", 38);
  }
  
  Dagaz.View.configure = function(view) {
      view.defBoard("Board");
      view.defPiece("WhiteMan", "White Man");
      view.defPiece("BlackMan", "Black Man");
      view.defPiece("WhiteKing", "White King");
      view.defPiece("BlackKing", "Black King");
   
      view.defPosition("a10", 452, 452, 50, 50);
      view.defPosition("b10", 402, 452, 50, 50);
      view.defPosition("c10", 352, 452, 50, 50);
      view.defPosition("d10", 302, 452, 50, 50);
      view.defPosition("e10", 252, 452, 50, 50);
      view.defPosition("f10", 202, 452, 50, 50);
      view.defPosition("g10", 152, 452, 50, 50);
      view.defPosition("h10", 102, 452, 50, 50);
      view.defPosition("i10", 52, 452, 50, 50);
      view.defPosition("j10", 2, 452, 50, 50);
      view.defPosition("a9", 452, 402, 50, 50);
      view.defPosition("b9", 402, 402, 50, 50);
      view.defPosition("c9", 352, 402, 50, 50);
      view.defPosition("d9", 302, 402, 50, 50);
      view.defPosition("e9", 252, 402, 50, 50);
      view.defPosition("f9", 202, 402, 50, 50);
      view.defPosition("g9", 152, 402, 50, 50);
      view.defPosition("h9", 102, 402, 50, 50);
      view.defPosition("i9", 52, 402, 50, 50);
      view.defPosition("j9", 2, 402, 50, 50);
      view.defPosition("a8", 452, 352, 50, 50);
      view.defPosition("b8", 402, 352, 50, 50);
      view.defPosition("c8", 352, 352, 50, 50);
      view.defPosition("d8", 302, 352, 50, 50);
      view.defPosition("e8", 252, 352, 50, 50);
      view.defPosition("f8", 202, 352, 50, 50);
      view.defPosition("g8", 152, 352, 50, 50);
      view.defPosition("h8", 102, 352, 50, 50);
      view.defPosition("i8", 52, 352, 50, 50);
      view.defPosition("j8", 2, 352, 50, 50);
      view.defPosition("a7", 452, 302, 50, 50);
      view.defPosition("b7", 402, 302, 50, 50);
      view.defPosition("c7", 352, 302, 50, 50);
      view.defPosition("d7", 302, 302, 50, 50);
      view.defPosition("e7", 252, 302, 50, 50);
      view.defPosition("f7", 202, 302, 50, 50);
      view.defPosition("g7", 152, 302, 50, 50);
      view.defPosition("h7", 102, 302, 50, 50);
      view.defPosition("i7", 52, 302, 50, 50);
      view.defPosition("j7", 2, 302, 50, 50);
      view.defPosition("a6", 452, 252, 50, 50);
      view.defPosition("b6", 402, 252, 50, 50);
      view.defPosition("c6", 352, 252, 50, 50);
      view.defPosition("d6", 302, 252, 50, 50);
      view.defPosition("e6", 252, 252, 50, 50);
      view.defPosition("f6", 202, 252, 50, 50);
      view.defPosition("g6", 152, 252, 50, 50);
      view.defPosition("h6", 102, 252, 50, 50);
      view.defPosition("i6", 52, 252, 50, 50);
      view.defPosition("j6", 2, 252, 50, 50);
      view.defPosition("a5", 452, 202, 50, 50);
      view.defPosition("b5", 402, 202, 50, 50);
      view.defPosition("c5", 352, 202, 50, 50);
      view.defPosition("d5", 302, 202, 50, 50);
      view.defPosition("e5", 252, 202, 50, 50);
      view.defPosition("f5", 202, 202, 50, 50);
      view.defPosition("g5", 152, 202, 50, 50);
      view.defPosition("h5", 102, 202, 50, 50);
      view.defPosition("i5", 52, 202, 50, 50);
      view.defPosition("j5", 2, 202, 50, 50);
      view.defPosition("a4", 452, 152, 50, 50);
      view.defPosition("b4", 402, 152, 50, 50);
      view.defPosition("c4", 352, 152, 50, 50);
      view.defPosition("d4", 302, 152, 50, 50);
      view.defPosition("e4", 252, 152, 50, 50);
      view.defPosition("f4", 202, 152, 50, 50);
      view.defPosition("g4", 152, 152, 50, 50);
      view.defPosition("h4", 102, 152, 50, 50);
      view.defPosition("i4", 52, 152, 50, 50);
      view.defPosition("j4", 2, 152, 50, 50);
      view.defPosition("a3", 452, 102, 50, 50);
      view.defPosition("b3", 402, 102, 50, 50);
      view.defPosition("c3", 352, 102, 50, 50);
      view.defPosition("d3", 302, 102, 50, 50);
      view.defPosition("e3", 252, 102, 50, 50);
      view.defPosition("f3", 202, 102, 50, 50);
      view.defPosition("g3", 152, 102, 50, 50);
      view.defPosition("h3", 102, 102, 50, 50);
      view.defPosition("i3", 52, 102, 50, 50);
      view.defPosition("j3", 2, 102, 50, 50);
      view.defPosition("a2", 452, 52, 50, 50);
      view.defPosition("b2", 402, 52, 50, 50);
      view.defPosition("c2", 352, 52, 50, 50);
      view.defPosition("d2", 302, 52, 50, 50);
      view.defPosition("e2", 252, 52, 50, 50);
      view.defPosition("f2", 202, 52, 50, 50);
      view.defPosition("g2", 152, 52, 50, 50);
      view.defPosition("h2", 102, 52, 50, 50);
      view.defPosition("i2", 52, 52, 50, 50);
      view.defPosition("j2", 2, 52, 50, 50);
      view.defPosition("a1", 452, 2, 50, 50);
      view.defPosition("b1", 402, 2, 50, 50);
      view.defPosition("c1", 352, 2, 50, 50);
      view.defPosition("d1", 302, 2, 50, 50);
      view.defPosition("e1", 252, 2, 50, 50);
      view.defPosition("f1", 202, 2, 50, 50);
      view.defPosition("g1", 152, 2, 50, 50);
      view.defPosition("h1", 102, 2, 50, 50);
      view.defPosition("i1", 52, 2, 50, 50);
      view.defPosition("j1", 2, 2, 50, 50);
  }
  