Before you can start testing or playing checkers, you need just one more function. You’ve written functions to maintain the game board state, to move player pieces, and even to notify the host when important events occur. What’s missing is the initial set up—placing all of the players’ pieces on the board.
$initBoard is a simple, brute-force function that just calls $setPiece over and over to place the white and black pieces, finally setting the current turn to black:
|||;; Manually place each piece on the board to initialize the game|
|||;; Place the white pieces at the top of the board|
|||(call $setPiece (i32.const 1) (i32.const 0) (i32.const 2))|
|||(call $setPiece (i32.const 3) (i32.const 0) (i32.const ...|