var btn = document.getElementById("btn"); var canvas = document.getElementById("chessboard"); //var canvas = document.querySelector(".an"); var context = canvas.getContext("2d"); var chessMapArr = [];//记录棋盘落子情况 var chessColor = ["black", "white"];//棋子颜色 var step = 0;//记录当前步数 var flag = false;//判断游戏是否结束 //输赢检查方向模式 var checkMode = [ [1,0],//水平 [0,1],//竖直 [1,1],//左斜线 [1,-1],//右斜线 ];