Chinaunix首页 | 论坛 | 博客
  • 博客访问: 366567
  • 博文数量: 284
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1707
  • 用 户 组: 普通用户
  • 注册时间: 2014-05-14 16:38
文章分类

全部博文(284)

文章存档

2015年(6)

2014年(278)

我的朋友

分类: JavaScript

2014-07-04 13:55:48

Javascript版五子棋,无禁手。欢迎提出算法的改进意见。

2. [代码]HTML     


   
       
       
         
       
       
       
       
       
   
   
       

           

               
                    简体中文
                    English
               

               
                  ©lovebing
               

           

            You: Black, AI: White, Round: 0
           
           
       

       

       

   

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: '黑棋'
    
};
阅读(657) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~