Javascript版五子棋,无禁手。欢迎提出算法的改进意见。
2. [代码]HTML
3. [代码]gomoku.js部分代码
/**
* Javascript 版五子棋(无禁手)
* Author: lovebing
* Depends: jquery.js
* Created: 2013-06
* Last updated: 2013-12-18
* Copyright 2013 lovebing.org
*/
function Gomoku() {
this.chessboardSize = 15;// 棋盘大小
this.chessState = [];// 保存落子情况,二维数组,i表示行,j表示列
this.gameover = false;
this.round = 0;
this.chessCount = 0;
this.gameResult = '';
this.operationLog = [];
this.chess = ['', 'black', 'white'];
this.role = {
human: 1, // 'black'
AI: 2 //'white'
};
this.turn = this.role.human;
this.chessClass = {
white: 'white-chess',
black: 'black-chess',
last: 'last-chess'
};
this.locale = {};
}
4. [代码]locale.js
var locale = [];
locale['en'] = {
gomoku: 'Gomoku Powered by Lovebing',
restart: 'Restart',
regret: 'Regret',
staleBrowser: 'Your browser\'s version is stale! Please use the browser supported HTML5 like Google chrome.',
youLose: 'You lose!',
youWin: 'You win!',
whiteChess: 'White',
blackChess: 'Black'
};
locale['zh-cn'] = {
gomoku: '五子棋 Powered by Lovebing',
restart: '重新开始',
regret: '悔棋',
staleBrowser: '你的浏览器版本过旧,请使用支持HTML5的浏览器,如Google Chrome。',
youLose: '你输了!',
youWin: '你赢了!',
whiteChess: '白棋',
blackChess: '黑棋'
};
阅读(712) | 评论(0) | 转发(0) |