diff --git a/.idea/Chess.iml b/.idea/Chess.iml
new file mode 100644
index 0000000..c956989
--- /dev/null
+++ b/.idea/Chess.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..10812fd
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..28a804d
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..fac3e91
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..2ab0f21
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,260 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1550641282982
+
+
+ 1550641282982
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 5bbc3f6..ffecbf8 100644
--- a/README.md
+++ b/README.md
@@ -1,26 +1,26 @@
-中国象棋 - in html5
-===========
-
-作者:一叶孤舟
-联系:itlwei@163.com QQ:28701884
-Demo:http://itlwei.github.io/chess/
-
-中国象棋 - in html5是一款使用html5 canvas开发的开源小游戏,不依赖任何类库,不依赖任何后台程序,全部原生Javascript进行AI计算,欢迎广大业内同行多多交流指正,共同完善。
-
-##特点
-
-* 全部使用Javascript完成AI人工智能计算,不依赖任何后台程序
-* 不依赖任何类库,全部原生Javascript,使用html5 canvas.
-* 实现中不涉及任何浏览器特性,所以不存在浏览器兼容性问题.
-* 代码结构极其简洁明了,你可以轻易的阅读,修改成自己版本.
-
-##Change Log
-### v1.0.3
-* 增加历史表,提高AI计算效率
-
-### v1.0.2
-* 修复了AI计算过深的资源耗尽问题
-
-### v1.0.1
-* 修复了一些情况下悔棋出错的问题
-* 修复了长将不死的问题
+中国象棋 - in html5
+===========
+
+作者:一叶孤舟
+联系:itlwei@163.com QQ:28701884
+Demo:http://itlwei.github.io/chess/
+
+中国象棋 - in html5是一款使用html5 canvas开发的开源小游戏,不依赖任何类库,不依赖任何后台程序,全部原生Javascript进行AI计算,欢迎广大业内同行多多交流指正,共同完善。
+
+## 特点
+
+* 全部使用Javascript完成AI人工智能计算,不依赖任何后台程序
+* 不依赖任何类库,全部原生Javascript,使用html5 canvas.
+* 实现中不涉及任何浏览器特性,所以不存在浏览器兼容性问题.
+* 代码结构极其简洁明了,你可以轻易的阅读,修改成自己版本.
+
+## Change Log
+### v1.0.3
+* 增加历史表,提高AI计算效率
+
+### v1.0.2
+* 修复了AI计算过深的资源耗尽问题
+
+### v1.0.1
+* 修复了一些情况下悔棋出错的问题
+* 修复了长将不死的问题
diff --git a/css/chess.css b/css/chess.css
deleted file mode 100644
index d7d8780..0000000
--- a/css/chess.css
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * ChinaChess - in html5
- * http://www.jnzo.com/chess/
- * @ author һҶ
- * @ mail itlwei@163.com
- * @ QQ 28701884
- */
-
-@charset "gb2312";
-body{ font-size: 12px; line-height: 150%; }
-.box { margin:0 auto; width:460px; position: relative; }
-.chess_left {float:left; text-align:center }
-.chess_right { float:left; display:none}
-.move_info { float:left; margin-top:20px}
-
-.bill_box{ height: 320px; width: 80px; overflow:auto;}
-.bill_box li { cursor:pointer; text-align:left}
-.bill_box li:hover { cursor:pointer; background: #C6A577; }
-.bill_box li:active { cursor:pointer; background: #fff; }
-#billList{ margin-top:20px}
-.bn_box{display:none}
-.download{ margin-top:30px}
-
diff --git a/img/stype_1/b_box.png b/img/stype_1/b_box.png
deleted file mode 100644
index e8df3b7..0000000
Binary files a/img/stype_1/b_box.png and /dev/null differ
diff --git a/img/stype_1/b_c.png b/img/stype_1/b_c.png
deleted file mode 100644
index ac09bee..0000000
Binary files a/img/stype_1/b_c.png and /dev/null differ
diff --git a/img/stype_1/b_j.png b/img/stype_1/b_j.png
deleted file mode 100644
index e081279..0000000
Binary files a/img/stype_1/b_j.png and /dev/null differ
diff --git a/img/stype_1/b_m.png b/img/stype_1/b_m.png
deleted file mode 100644
index 5e69b5e..0000000
Binary files a/img/stype_1/b_m.png and /dev/null differ
diff --git a/img/stype_1/b_p.png b/img/stype_1/b_p.png
deleted file mode 100644
index 3b6d594..0000000
Binary files a/img/stype_1/b_p.png and /dev/null differ
diff --git a/img/stype_1/b_s.png b/img/stype_1/b_s.png
deleted file mode 100644
index 0a83c01..0000000
Binary files a/img/stype_1/b_s.png and /dev/null differ
diff --git a/img/stype_1/b_x.png b/img/stype_1/b_x.png
deleted file mode 100644
index b5c6aa2..0000000
Binary files a/img/stype_1/b_x.png and /dev/null differ
diff --git a/img/stype_1/b_z.png b/img/stype_1/b_z.png
deleted file mode 100644
index 39c05dd..0000000
Binary files a/img/stype_1/b_z.png and /dev/null differ
diff --git a/img/stype_1/bg.jpg b/img/stype_1/bg.jpg
deleted file mode 100644
index 27b914b..0000000
Binary files a/img/stype_1/bg.jpg and /dev/null differ
diff --git a/img/stype_1/bg.png b/img/stype_1/bg.png
deleted file mode 100644
index 43652b1..0000000
Binary files a/img/stype_1/bg.png and /dev/null differ
diff --git a/img/stype_1/dot.png b/img/stype_1/dot.png
deleted file mode 100644
index 242b36e..0000000
Binary files a/img/stype_1/dot.png and /dev/null differ
diff --git a/img/stype_1/r_box.png b/img/stype_1/r_box.png
deleted file mode 100644
index 3d5d055..0000000
Binary files a/img/stype_1/r_box.png and /dev/null differ
diff --git a/img/stype_1/r_c.png b/img/stype_1/r_c.png
deleted file mode 100644
index 0697f3d..0000000
Binary files a/img/stype_1/r_c.png and /dev/null differ
diff --git a/img/stype_1/r_j.png b/img/stype_1/r_j.png
deleted file mode 100644
index a4a57a2..0000000
Binary files a/img/stype_1/r_j.png and /dev/null differ
diff --git a/img/stype_1/r_m.png b/img/stype_1/r_m.png
deleted file mode 100644
index 39fe7c5..0000000
Binary files a/img/stype_1/r_m.png and /dev/null differ
diff --git a/img/stype_1/r_p.png b/img/stype_1/r_p.png
deleted file mode 100644
index 5a59d0a..0000000
Binary files a/img/stype_1/r_p.png and /dev/null differ
diff --git a/img/stype_1/r_s.png b/img/stype_1/r_s.png
deleted file mode 100644
index 64aaa11..0000000
Binary files a/img/stype_1/r_s.png and /dev/null differ
diff --git a/img/stype_1/r_x.png b/img/stype_1/r_x.png
deleted file mode 100644
index ffee7c3..0000000
Binary files a/img/stype_1/r_x.png and /dev/null differ
diff --git a/img/stype_1/r_z.png b/img/stype_1/r_z.png
deleted file mode 100644
index cd79e07..0000000
Binary files a/img/stype_1/r_z.png and /dev/null differ
diff --git a/img/stype_2/b_box.png b/img/stype_2/b_box.png
deleted file mode 100644
index e8df3b7..0000000
Binary files a/img/stype_2/b_box.png and /dev/null differ
diff --git a/img/stype_2/b_c.png b/img/stype_2/b_c.png
deleted file mode 100644
index f64c3dc..0000000
Binary files a/img/stype_2/b_c.png and /dev/null differ
diff --git a/img/stype_2/b_j.png b/img/stype_2/b_j.png
deleted file mode 100644
index 90886bd..0000000
Binary files a/img/stype_2/b_j.png and /dev/null differ
diff --git a/img/stype_2/b_m.png b/img/stype_2/b_m.png
deleted file mode 100644
index e71b013..0000000
Binary files a/img/stype_2/b_m.png and /dev/null differ
diff --git a/img/stype_2/b_p.png b/img/stype_2/b_p.png
deleted file mode 100644
index 9457658..0000000
Binary files a/img/stype_2/b_p.png and /dev/null differ
diff --git a/img/stype_2/b_s.png b/img/stype_2/b_s.png
deleted file mode 100644
index 565bed8..0000000
Binary files a/img/stype_2/b_s.png and /dev/null differ
diff --git a/img/stype_2/b_x.png b/img/stype_2/b_x.png
deleted file mode 100644
index bfa7efa..0000000
Binary files a/img/stype_2/b_x.png and /dev/null differ
diff --git a/img/stype_2/b_z.png b/img/stype_2/b_z.png
deleted file mode 100644
index 70d6c91..0000000
Binary files a/img/stype_2/b_z.png and /dev/null differ
diff --git a/img/stype_2/bg.jpg b/img/stype_2/bg.jpg
deleted file mode 100644
index a529b22..0000000
Binary files a/img/stype_2/bg.jpg and /dev/null differ
diff --git a/img/stype_2/bg.png b/img/stype_2/bg.png
deleted file mode 100644
index 4395cec..0000000
Binary files a/img/stype_2/bg.png and /dev/null differ
diff --git a/img/stype_2/dot.png b/img/stype_2/dot.png
deleted file mode 100644
index 1fe0ece..0000000
Binary files a/img/stype_2/dot.png and /dev/null differ
diff --git a/img/stype_2/r_box.png b/img/stype_2/r_box.png
deleted file mode 100644
index 3507bc0..0000000
Binary files a/img/stype_2/r_box.png and /dev/null differ
diff --git a/img/stype_2/r_c.png b/img/stype_2/r_c.png
deleted file mode 100644
index 0deba52..0000000
Binary files a/img/stype_2/r_c.png and /dev/null differ
diff --git a/img/stype_2/r_j.png b/img/stype_2/r_j.png
deleted file mode 100644
index d80eb0b..0000000
Binary files a/img/stype_2/r_j.png and /dev/null differ
diff --git a/img/stype_2/r_m.png b/img/stype_2/r_m.png
deleted file mode 100644
index 44e7893..0000000
Binary files a/img/stype_2/r_m.png and /dev/null differ
diff --git a/img/stype_2/r_p.png b/img/stype_2/r_p.png
deleted file mode 100644
index 922b2ca..0000000
Binary files a/img/stype_2/r_p.png and /dev/null differ
diff --git a/img/stype_2/r_s.png b/img/stype_2/r_s.png
deleted file mode 100644
index 94465ed..0000000
Binary files a/img/stype_2/r_s.png and /dev/null differ
diff --git a/img/stype_2/r_x.png b/img/stype_2/r_x.png
deleted file mode 100644
index 61f6e87..0000000
Binary files a/img/stype_2/r_x.png and /dev/null differ
diff --git a/img/stype_2/r_z.png b/img/stype_2/r_z.png
deleted file mode 100644
index 95d6c05..0000000
Binary files a/img/stype_2/r_z.png and /dev/null differ
diff --git a/index.html b/index.html
deleted file mode 100644
index cc7daba..0000000
--- a/index.html
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-
-
-й in html5
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/js/AI.js b/js/AI.js
deleted file mode 100644
index a5be1ac..0000000
--- a/js/AI.js
+++ /dev/null
@@ -1,265 +0,0 @@
-/**
- * ChinaChess - in html5
- * http://www.jnzo.com/chess/
- * @ author һҶ
- * @ mail itlwei@163.com
- * @ QQ 28701884
- */
-
-var AI = AI||{};
-
-AI.historyTable = {}; //ʷ
-
-
-//˹ܳʼ
-AI.init = function(pace){
- var bill = AI.historyBill || com.gambit; //ֿ
- if (bill.length){
- var len=pace.length;
- var arr=[];
- //
- for (var i=0;i< bill.length;i++){
- if (bill[i].slice(0,len)==pace) {
- arr.push(bill[i]);
- }
- }
- if (arr.length){
- var inx=Math.floor( Math.random() * arr.length );
- AI.historyBill = arr ;
- return arr[inx].slice(len,len+4).split("");
- }else{
- AI.historyBill = [] ;
- }
-
- }
- //ûУ˹ܿʼ
- var initTime = new Date().getTime();
- AI.treeDepth=play.depth;
- //AI.treeDepth=4;
-
- AI.number=0;
- AI.setHistoryTable.lenght = 0
-
- var val=AI.getAlphaBeta(-99999 ,99999, AI.treeDepth, com.arr2Clone(play.map),play.my);
- //var val = AI.iterativeSearch(com.arr2Clone(play.map),play.my)
- if (!val||val.value==-8888) {
- AI.treeDepth=2;
- val=AI.getAlphaBeta(-99999 ,99999, AI.treeDepth, com.arr2Clone(play.map),play.my);
- }
- //var val = AI.iterativeSearch(com.arr2Clone(play.map),play.my);
- if (val&&val.value!=-8888) {
- var man = play.mans[val.key];
- var nowTime= new Date().getTime();
- com.get("moveInfo").innerHTML='AI
ŷ'+
- com.createMove(com.arr2Clone(play.map),man.x,man.y,val.x,val.y)+
- '
ȣ'+AI.treeDepth+'
֧'+
- AI.number+'
ŷ'+
- val.value+''+
- '
ʱ'+
- (nowTime-initTime)+''
- return [man.x,man.y,val.x,val.y]
- }else {
- return false;
- }
-}
-
-//ŷ
-AI.iterativeSearch = function (map, my){
- var timeOut=100;
- var initDepth = 1;
- var maxDepth = 8;
- AI.treeDepth=0;
- var initTime = new Date().getTime();
- var val = {};
- for (var i=initDepth; i<=maxDepth; i++){
- var nowTime= new Date().getTime();
- AI.treeDepth=i;
- AI.aotuDepth=i;
- var val = AI.getAlphaBeta(-99999, 99999, AI.treeDepth , map ,my)
- if (nowTime-initTime > timeOut){
- return val;
- }
- }
- return false;
-}
-
-//ȡ
-AI.getMapAllMan = function (map, my){
- var mans=[];
- for (var i=0; i= AI.treeDepth-depth+1){
- // return history.value*my;
- //}
- if (depth == 0) {
- return {"value":AI.evaluate(map , my)}; //ۺ;
- }
- var moves = AI.getMoves(map , my ); //ȫ߷;
- //ԺЧ
-
- for (var i=0; i < moves.length; i++) {
-
-
- //߷;
- var move= moves[i];
- var key = move[4];
- var oldX= move[0];
- var oldY= move[1];
- var newX= move[2];
- var newY= move[3];
- var clearKey = map[ newY ][ newX ]||"";
-
- map[ newY ][ newX ] = key;
- delete map[ oldY ][ oldX ];
- play.mans[key].x = newX;
- play.mans[key].y = newY;
-
- if (clearKey=="j0"||clearKey=="J0") {//Ͻ,߷;
- play.mans[key] .x = oldX;
- play.mans[key] .y = oldY;
- map[ oldY ][ oldX ] = key;
- delete map[ newY ][ newX ];
- if (clearKey){
- map[ newY ][ newX ] = clearKey;
- // play.mans[ clearKey ].isShow = false;
- }
-
- return {"key":key,"x":newX,"y":newY,"value":8888};
- //return rootKey;
- }else {
- var val = -AI.getAlphaBeta(-B, -A, depth - 1, map , -my).value;
- //val = val || val.value;
-
- //߷;
- play.mans[key] .x = oldX;
- play.mans[key] .y = oldY;
- map[ oldY ][ oldX ] = key;
- delete map[ newY ][ newX ];
- if (clearKey){
- map[ newY ][ newX ] = clearKey;
- //play.mans[ clearKey ].isShow = true;
- }
- if (val >= B) {
- //߷¼ʷ;
- //AI.setHistoryTable(txtMap,AI.treeDepth-depth+1,B,my);
- return {"key":key,"x":newX,"y":newY,"value":B};
- }
- if (val > A) {
- A = val; //߷;
- if (AI.treeDepth == depth) var rootKey={"key":key,"x":newX,"y":newY,"value":A};
- }
- }
- }
- //߷¼ʷ;
- //AI.setHistoryTable(txtMap,AI.treeDepth-depth+1,A,my);
- if (AI.treeDepth == depth) {//Ѿݹظ
- if (!rootKey){
- //AIû߷˵AIˣfalse
- return false;
- }else{
- //߷;
- return rootKey;
- }
- }
-return {"key":key,"x":newX,"y":newY,"value":A};
-}
-
-//ŷ¼ʷ
-AI.setHistoryTable = function (txtMap,depth,value,my){
- AI.setHistoryTable.lenght ++;
- AI.historyTable[txtMap] = {depth:depth,value:value}
-}
-
-// ȡ˫Ӽֵ
-AI.evaluate = function (map,my){
- var val=0;
- for (var i=0; i';
- var x = bl[i+0];
- var y = bl[i+1];
- var newX = bl[i+2];
- var newY = bl[i+3];
- h += com.createMove(map,x,y,newX,newY);
- h +='\n\r';
- }
- com.get("billBox").innerHTML = h;
-
- var doms=com.get("billBox").getElementsByTagName("li");
-
- for (var i=0; i=5) clearInterval(timer);
- },2000);
- })
-
- com.getData("js/gambit.all.js",
- function(data){
- com.gambit=data.split(" ");
- AI.historyBill = com.gambit;
- })
- com.getData("js/store.js",
- function(data){
- com.store=data.split(" ");
- })
-}
-
-//ͼƬ
-com.loadImages = function(stype){
-
- //
- com.bgImg = new Image();
- com.bgImg.src = "img/"+stype+"/bg.png";
-
- //ʾ
- com.dotImg = new Image();
- com.dotImg.src = "img/"+stype+"/dot.png";
-
- //
- for (var i in com.args){
- com[i] = {};
- com[i].img = new Image();
- com[i].img.src = "img/"+stype+"/"+ com.args[i].img +".png";
- }
-
- //
- com.paneImg = new Image();
- com.paneImg.src = "img/"+stype+"/r_box.png";
-
- document.getElementsByTagName("body")[0].style.background= "url(img/"+stype+"/bg.jpg)";
-
-}
-
-//ʾб
-com.show = function (){
- com.ct.clearRect(0, 0, com.width, com.height);
- for (var i=0; i0){
- start=document.cookie.indexOf(name + "=")
- if (start!=-1){
- start=start + name.length+1
- end=document.cookie.indexOf(";",start)
- if (end==-1) end=document.cookie.length
- return unescape(document.cookie.substring(start,end))
- }
- }
- return false;
-}
-//ά¡
-com.arr2Clone = function (arr){
- var newArr=[];
- for (var i=0; i y) {
- h+= "";
- if (man.pater == "m" || man.pater == "s" || man.pater == "x"){
- h+= mumTo[newX];
- }else {
- h+= mumTo[newY - y -1];
- }
- }else if (newY < y) {
- h+= "";
- if (man.pater == "m" || man.pater == "s" || man.pater == "x"){
- h+= mumTo[newX];
- }else {
- h+= mumTo[y - newY -1];
- }
- }else {
- h+= "ƽ";
- h+= mumTo[newX];
- }
- }else{
- var mumTo=["","","","","","","","","","10"];
- h+= mumTo[x];
- if (newY > y) {
- h+= "";
- if (man.pater == "M" || man.pater == "S" || man.pater == "X"){
- h+= mumTo[newX];
- }else {
- h+= mumTo[newY - y-1];
- }
- }else if (newY < y) {
- h+= "";
- if (man.pater == "M" || man.pater == "S" || man.pater == "X"){
- h+= mumTo[newX];
- }else {
- h+= mumTo[y - newY-1];
- }
- }else {
- h+= "ƽ";
- h+= mumTo[newX];
- }
- }
- return h;
-}
-
-com.initMap = [
- ['C0','M0','X0','S0','J0','S1','X1','M1','C1'],
- [ , , , , , , , , ],
- [ ,'P0', , , , , ,'P1', ],
- ['Z0', ,'Z1', ,'Z2', ,'Z3', ,'Z4'],
- [ , , , , , , , , ],
- [ , , , , , , , , ],
- ['z0', ,'z1', ,'z2', ,'z3', ,'z4'],
- [ ,'p0', , , , , ,'p1', ],
- [ , , , , , , , , ],
- ['c0','m0','x0','s0','j0','s1','x1','m1','c1']
-];
-
-
-
-com.initMap1 = [
- [ , , ,, "J0" , , , , ],
- [ , , , , , , , , ],
- [ , , , , ,"c0", , , ],
- [ , , , , , , , , ],
- [ , , , , , , , , ],
- [ , , , , , , , , ],
- [ , , , , , , , , ],
- [ , , , , , , , , ],
- [ , , , ,"s0", , ,"C0", ],
- [ , , ,"s1", ,"j0", , , ]
-];
-
-com.initMap1 = [
- [ , , ,, "J0" , , , , ],
- [ , , , , , , , , ],
- [ , , , , ,"z0", , , ],
- [ , , , , , , , , ],
- [ , , , , , , , , ],
- [ , , , , , , , , ],
- [ , , , , , , , , ],
- [ , , , , , , , , ],
- [ , , , , , , , , ],
- [ , , , "j0" ,, , , ]
-];
-
-com.keys = {
- "c0":"c","c1":"c",
- "m0":"m","m1":"m",
- "x0":"x","x1":"x",
- "s0":"s","s1":"s",
- "j0":"j",
- "p0":"p","p1":"p",
- "z0":"z","z1":"z","z2":"z","z3":"z","z4":"z","z5":"z",
-
- "C0":"c","C1":"C",
- "M0":"M","M1":"M",
- "X0":"X","X1":"X",
- "S0":"S","S1":"S",
- "J0":"J",
- "P0":"P","P1":"P",
- "Z0":"Z","Z1":"Z","Z2":"Z","Z3":"Z","Z4":"Z","Z5":"Z",
-}
-
-//ߵŵ
-com.bylaw ={}
-//
-com.bylaw.c = function (x,y,map,my){
- var d=[];
- //
- for (var i=x-1; i>= 0; i--){
- if (map[y][i]) {
- if (com.mans[map[y][i]].my!=my) d.push([i,y]);
- break
- }else{
- d.push([i,y])
- }
- }
- //Ҳ
- for (var i=x+1; i <= 8; i++){
- if (map[y][i]) {
- if (com.mans[map[y][i]].my!=my) d.push([i,y]);
- break
- }else{
- d.push([i,y])
- }
- }
- //ϼ
- for (var i = y-1 ; i >= 0; i--){
- if (map[i][x]) {
- if (com.mans[map[i][x]].my!=my) d.push([x,i]);
- break
- }else{
- d.push([x,i])
- }
- }
- //¼
- for (var i = y+1 ; i<= 9; i++){
- if (map[i][x]) {
- if (com.mans[map[i][x]].my!=my) d.push([x,i]);
- break
- }else{
- d.push([x,i])
- }
- }
- return d;
-}
-
-//
-com.bylaw.m = function (x,y,map,my){
- var d=[];
- //1
- if ( y-2>= 0 && x+1<= 8 && !play.map[y-1][x] &&(!com.mans[map[y-2][x+1]] || com.mans[map[y-2][x+1]].my!=my)) d.push([x+1,y-2]);
- //2
- if ( y-1>= 0 && x+2<= 8 && !play.map[y][x+1] &&(!com.mans[map[y-1][x+2]] || com.mans[map[y-1][x+2]].my!=my)) d.push([x+2,y-1]);
- //4
- if ( y+1<= 9 && x+2<= 8 && !play.map[y][x+1] &&(!com.mans[map[y+1][x+2]] || com.mans[map[y+1][x+2]].my!=my)) d.push([x+2,y+1]);
- //5
- if ( y+2<= 9 && x+1<= 8 && !play.map[y+1][x] &&(!com.mans[map[y+2][x+1]] || com.mans[map[y+2][x+1]].my!=my)) d.push([x+1,y+2]);
- //7
- if ( y+2<= 9 && x-1>= 0 && !play.map[y+1][x] &&(!com.mans[map[y+2][x-1]] || com.mans[map[y+2][x-1]].my!=my)) d.push([x-1,y+2]);
- //8
- if ( y+1<= 9 && x-2>= 0 && !play.map[y][x-1] &&(!com.mans[map[y+1][x-2]] || com.mans[map[y+1][x-2]].my!=my)) d.push([x-2,y+1]);
- //10
- if ( y-1>= 0 && x-2>= 0 && !play.map[y][x-1] &&(!com.mans[map[y-1][x-2]] || com.mans[map[y-1][x-2]].my!=my)) d.push([x-2,y-1]);
- //11
- if ( y-2>= 0 && x-1>= 0 && !play.map[y-1][x] &&(!com.mans[map[y-2][x-1]] || com.mans[map[y-2][x-1]].my!=my)) d.push([x-1,y-2]);
-
- return d;
-}
-
-//
-com.bylaw.x = function (x,y,map,my){
- var d=[];
- if (my===1){ //췽
- //4
- if ( y+2<= 9 && x+2<= 8 && !play.map[y+1][x+1] && (!com.mans[map[y+2][x+2]] || com.mans[map[y+2][x+2]].my!=my)) d.push([x+2,y+2]);
- //7
- if ( y+2<= 9 && x-2>= 0 && !play.map[y+1][x-1] && (!com.mans[map[y+2][x-2]] || com.mans[map[y+2][x-2]].my!=my)) d.push([x-2,y+2]);
- //1
- if ( y-2>= 5 && x+2<= 8 && !play.map[y-1][x+1] && (!com.mans[map[y-2][x+2]] || com.mans[map[y-2][x+2]].my!=my)) d.push([x+2,y-2]);
- //10
- if ( y-2>= 5 && x-2>= 0 && !play.map[y-1][x-1] && (!com.mans[map[y-2][x-2]] || com.mans[map[y-2][x-2]].my!=my)) d.push([x-2,y-2]);
- }else{
- //4
- if ( y+2<= 4 && x+2<= 8 && !play.map[y+1][x+1] && (!com.mans[map[y+2][x+2]] || com.mans[map[y+2][x+2]].my!=my)) d.push([x+2,y+2]);
- //7
- if ( y+2<= 4 && x-2>= 0 && !play.map[y+1][x-1] && (!com.mans[map[y+2][x-2]] || com.mans[map[y+2][x-2]].my!=my)) d.push([x-2,y+2]);
- //1
- if ( y-2>= 0 && x+2<= 8 && !play.map[y-1][x+1] && (!com.mans[map[y-2][x+2]] || com.mans[map[y-2][x+2]].my!=my)) d.push([x+2,y-2]);
- //10
- if ( y-2>= 0 && x-2>= 0 && !play.map[y-1][x-1] && (!com.mans[map[y-2][x-2]] || com.mans[map[y-2][x-2]].my!=my)) d.push([x-2,y-2]);
- }
- return d;
-}
-
-//ʿ
-com.bylaw.s = function (x,y,map,my){
- var d=[];
- if (my===1){ //췽
- //4
- if ( y+1<= 9 && x+1<= 5 && (!com.mans[map[y+1][x+1]] || com.mans[map[y+1][x+1]].my!=my)) d.push([x+1,y+1]);
- //7
- if ( y+1<= 9 && x-1>= 3 && (!com.mans[map[y+1][x-1]] || com.mans[map[y+1][x-1]].my!=my)) d.push([x-1,y+1]);
- //1
- if ( y-1>= 7 && x+1<= 5 && (!com.mans[map[y-1][x+1]] || com.mans[map[y-1][x+1]].my!=my)) d.push([x+1,y-1]);
- //10
- if ( y-1>= 7 && x-1>= 3 && (!com.mans[map[y-1][x-1]] || com.mans[map[y-1][x-1]].my!=my)) d.push([x-1,y-1]);
- }else{
- //4
- if ( y+1<= 2 && x+1<= 5 && (!com.mans[map[y+1][x+1]] || com.mans[map[y+1][x+1]].my!=my)) d.push([x+1,y+1]);
- //7
- if ( y+1<= 2 && x-1>= 3 && (!com.mans[map[y+1][x-1]] || com.mans[map[y+1][x-1]].my!=my)) d.push([x-1,y+1]);
- //1
- if ( y-1>= 0 && x+1<= 5 && (!com.mans[map[y-1][x+1]] || com.mans[map[y-1][x+1]].my!=my)) d.push([x+1,y-1]);
- //10
- if ( y-1>= 0 && x-1>= 3 && (!com.mans[map[y-1][x-1]] || com.mans[map[y-1][x-1]].my!=my)) d.push([x-1,y-1]);
- }
- return d;
-
-}
-
-//
-com.bylaw.j = function (x,y,map,my){
- var d=[];
- var isNull=(function (y1,y2){
- var y1=com.mans["j0"].y;
- var x1=com.mans["J0"].x;
- var y2=com.mans["J0"].y;
- for (var i=y1-1; i>y2; i--){
- if (map[i][x1]) return false;
- }
- return true;
- })();
-
- if (my===1){ //췽
- //
- if ( y+1<= 9 && (!com.mans[map[y+1][x]] || com.mans[map[y+1][x]].my!=my)) d.push([x,y+1]);
- //
- if ( y-1>= 7 && (!com.mans[map[y-1][x]] || com.mans[map[y-1][x]].my!=my)) d.push([x,y-1]);
- //ϽϽ
- if ( com.mans["j0"].x == com.mans["J0"].x &&isNull) d.push([com.mans["J0"].x,com.mans["J0"].y]);
-
- }else{
- //
- if ( y+1<= 2 && (!com.mans[map[y+1][x]] || com.mans[map[y+1][x]].my!=my)) d.push([x,y+1]);
- //
- if ( y-1>= 0 && (!com.mans[map[y-1][x]] || com.mans[map[y-1][x]].my!=my)) d.push([x,y-1]);
- //ϽϽ
- if ( com.mans["j0"].x == com.mans["J0"].x &&isNull) d.push([com.mans["j0"].x,com.mans["j0"].y]);
- }
- //
- if ( x+1<= 5 && (!com.mans[map[y][x+1]] || com.mans[map[y][x+1]].my!=my)) d.push([x+1,y]);
- //
- if ( x-1>= 3 && (!com.mans[map[y][x-1]] || com.mans[map[y][x-1]].my!=my))d.push([x-1,y]);
- return d;
-}
-
-//
-com.bylaw.p = function (x,y,map,my){
- var d=[];
- //
- var n=0;
- for (var i=x-1; i>= 0; i--){
- if (map[y][i]) {
- if (n==0){
- n++;
- continue;
- }else{
- if (com.mans[map[y][i]].my!=my) d.push([i,y]);
- break
- }
- }else{
- if(n==0) d.push([i,y])
- }
- }
- //Ҳ
- var n=0;
- for (var i=x+1; i <= 8; i++){
- if (map[y][i]) {
- if (n==0){
- n++;
- continue;
- }else{
- if (com.mans[map[y][i]].my!=my) d.push([i,y]);
- break
- }
- }else{
- if(n==0) d.push([i,y])
- }
- }
- //ϼ
- var n=0;
- for (var i = y-1 ; i >= 0; i--){
- if (map[i][x]) {
- if (n==0){
- n++;
- continue;
- }else{
- if (com.mans[map[i][x]].my!=my) d.push([x,i]);
- break
- }
- }else{
- if(n==0) d.push([x,i])
- }
- }
- //¼
- var n=0;
- for (var i = y+1 ; i<= 9; i++){
- if (map[i][x]) {
- if (n==0){
- n++;
- continue;
- }else{
- if (com.mans[map[i][x]].my!=my) d.push([x,i]);
- break
- }
- }else{
- if(n==0) d.push([x,i])
- }
- }
- return d;
-}
-
-//
-com.bylaw.z = function (x,y,map,my){
- var d=[];
- if (my===1){ //췽
- //
- if ( y-1>= 0 && (!com.mans[map[y-1][x]] || com.mans[map[y-1][x]].my!=my)) d.push([x,y-1]);
- //
- if ( x+1<= 8 && y<=4 && (!com.mans[map[y][x+1]] || com.mans[map[y][x+1]].my!=my)) d.push([x+1,y]);
- //
- if ( x-1>= 0 && y<=4 && (!com.mans[map[y][x-1]] || com.mans[map[y][x-1]].my!=my))d.push([x-1,y]);
- }else{
- //
- if ( y+1<= 9 && (!com.mans[map[y+1][x]] || com.mans[map[y+1][x]].my!=my)) d.push([x,y+1]);
- //
- if ( x+1<= 8 && y>=6 && (!com.mans[map[y][x+1]] || com.mans[map[y][x+1]].my!=my)) d.push([x+1,y]);
- //
- if ( x-1>= 0 && y>=6 && (!com.mans[map[y][x-1]] || com.mans[map[y][x-1]].my!=my))d.push([x-1,y]);
- }
-
- return d;
-}
-
-com.value = {
-
- //ֵ
- c:[
- [206, 208, 207, 213, 214, 213, 207, 208, 206],
- [206, 212, 209, 216, 233, 216, 209, 212, 206],
- [206, 208, 207, 214, 216, 214, 207, 208, 206],
- [206, 213, 213, 216, 216, 216, 213, 213, 206],
- [208, 211, 211, 214, 215, 214, 211, 211, 208],
-
- [208, 212, 212, 214, 215, 214, 212, 212, 208],
- [204, 209, 204, 212, 214, 212, 204, 209, 204],
- [198, 208, 204, 212, 212, 212, 204, 208, 198],
- [200, 208, 206, 212, 200, 212, 206, 208, 200],
- [194, 206, 204, 212, 200, 212, 204, 206, 194]
- ],
-
- //ֵ
- m:[
- [90, 90, 90, 96, 90, 96, 90, 90, 90],
- [90, 96,103, 97, 94, 97,103, 96, 90],
- [92, 98, 99,103, 99,103, 99, 98, 92],
- [93,108,100,107,100,107,100,108, 93],
- [90,100, 99,103,104,103, 99,100, 90],
-
- [90, 98,101,102,103,102,101, 98, 90],
- [92, 94, 98, 95, 98, 95, 98, 94, 92],
- [93, 92, 94, 95, 92, 95, 94, 92, 93],
- [85, 90, 92, 93, 78, 93, 92, 90, 85],
- [88, 85, 90, 88, 90, 88, 90, 85, 88]
- ],
-
- //ֵ
- x:[
- [0, 0,20, 0, 0, 0,20, 0, 0],
- [0, 0, 0, 0, 0, 0, 0, 0, 0],
- [0, 0, 0, 0,23, 0, 0, 0, 0],
- [0, 0, 0, 0, 0, 0, 0, 0, 0],
- [0, 0,20, 0, 0, 0,20, 0, 0],
-
- [0, 0,20, 0, 0, 0,20, 0, 0],
- [0, 0, 0, 0, 0, 0, 0, 0, 0],
- [18,0, 0, 0,23, 0, 0, 0,18],
- [0, 0, 0, 0, 0, 0, 0, 0, 0],
- [0, 0,20, 0, 0, 0,20, 0, 0]
- ],
-
- //ʿֵ
- s:[
- [0, 0, 0,20, 0,20, 0, 0, 0],
- [0, 0, 0, 0,23, 0, 0, 0, 0],
- [0, 0, 0,20, 0,20, 0, 0, 0],
- [0, 0, 0, 0, 0, 0, 0, 0, 0],
- [0, 0, 0, 0, 0, 0, 0, 0, 0],
-
- [0, 0, 0, 0, 0, 0, 0, 0, 0],
- [0, 0, 0, 0, 0, 0, 0, 0, 0],
- [0, 0, 0,20, 0,20, 0, 0, 0],
- [0, 0, 0, 0,23, 0, 0, 0, 0],
- [0, 0, 0,20, 0,20, 0, 0, 0]
- ],
-
- //ֵ
- j:[
- [0, 0, 0, 8888, 8888, 8888, 0, 0, 0],
- [0, 0, 0, 8888, 8888, 8888, 0, 0, 0],
- [0, 0, 0, 8888, 8888, 8888, 0, 0, 0],
- [0, 0, 0, 0, 0, 0, 0, 0, 0],
- [0, 0, 0, 0, 0, 0, 0, 0, 0],
-
- [0, 0, 0, 0, 0, 0, 0, 0, 0],
- [0, 0, 0, 0, 0, 0, 0, 0, 0],
- [0, 0, 0, 8888, 8888, 8888, 0, 0, 0],
- [0, 0, 0, 8888, 8888, 8888, 0, 0, 0],
- [0, 0, 0, 8888, 8888, 8888, 0, 0, 0]
- ],
-
- //ڼֵ
- p:[
-
- [100, 100, 96, 91, 90, 91, 96, 100, 100],
- [ 98, 98, 96, 92, 89, 92, 96, 98, 98],
- [ 97, 97, 96, 91, 92, 91, 96, 97, 97],
- [ 96, 99, 99, 98, 100, 98, 99, 99, 96],
- [ 96, 96, 96, 96, 100, 96, 96, 96, 96],
-
- [ 95, 96, 99, 96, 100, 96, 99, 96, 95],
- [ 96, 96, 96, 96, 96, 96, 96, 96, 96],
- [ 97, 96, 100, 99, 101, 99, 100, 96, 97],
- [ 96, 97, 98, 98, 98, 98, 98, 97, 96],
- [ 96, 96, 97, 99, 99, 99, 97, 96, 96]
- ],
-
- //ֵ
- z:[
- [ 9, 9, 9, 11, 13, 11, 9, 9, 9],
- [19, 24, 34, 42, 44, 42, 34, 24, 19],
- [19, 24, 32, 37, 37, 37, 32, 24, 19],
- [19, 23, 27, 29, 30, 29, 27, 23, 19],
- [14, 18, 20, 27, 29, 27, 20, 18, 14],
-
- [ 7, 0, 13, 0, 16, 0, 13, 0, 7],
- [ 7, 0, 7, 0, 15, 0, 7, 0, 7],
- [ 0, 0, 0, 0, 0, 0, 0, 0, 0],
- [ 0, 0, 0, 0, 0, 0, 0, 0, 0],
- [ 0, 0, 0, 0, 0, 0, 0, 0, 0]
- ]
-}
-
-//Ϊֵּλõĵ
-com.value.C = com.arr2Clone(com.value.c).reverse();
-com.value.M = com.arr2Clone(com.value.m).reverse();
-com.value.X = com.value.x;
-com.value.S = com.value.s;
-com.value.J = com.value.j;
-com.value.P = com.arr2Clone(com.value.p).reverse();
-com.value.Z = com.arr2Clone(com.value.z).reverse();
-
-//
-com.args={
- // /ͼƬַ/Ӫ/Ȩ
- 'c':{text:"", img:'r_c', my:1 ,bl:"c", value:com.value.c},
- 'm':{text:"", img:'r_m', my:1 ,bl:"m", value:com.value.m},
- 'x':{text:"", img:'r_x', my:1 ,bl:"x", value:com.value.x},
- 's':{text:"", img:'r_s', my:1 ,bl:"s", value:com.value.s},
- 'j':{text:"", img:'r_j', my:1 ,bl:"j", value:com.value.j},
- 'p':{text:"", img:'r_p', my:1 ,bl:"p", value:com.value.p},
- 'z':{text:"", img:'r_z', my:1 ,bl:"z", value:com.value.z},
-
- //
- 'C':{text:"܇", img:'b_c', my:-1 ,bl:"c", value:com.value.C},
- 'M':{text:"R", img:'b_m', my:-1 ,bl:"m", value:com.value.M},
- 'X':{text:"", img:'b_x', my:-1 ,bl:"x", value:com.value.X},
- 'S':{text:"ʿ", img:'b_s', my:-1 ,bl:"s", value:com.value.S},
- 'J':{text:"˧", img:'b_j', my:-1 ,bl:"j", value:com.value.J},
- 'P':{text:"", img:'b_p', my:-1 ,bl:"p", value:com.value.P},
- 'Z':{text:"", img:'b_z', my:-1 ,bl:"z", value:com.value.Z}
-};
-
-com.class = com.class || {} //
-com.class.Man = function (key, x, y){
- this.pater = key.slice(0,1);
- var o=com.args[this.pater]
- this.x = x||0;
- this.y = y||0;
- this.key = key ;
- this.my = o.my;
- this.text = o.text;
- this.value = o.value;
- this.isShow = true;
- this.alpha = 1;
- this.ps = []; //ŵ
-
- this.show = function (){
- if (this.isShow) {
- com.ct.save();
- com.ct.globalAlpha = this.alpha;
- com.ct.drawImage(com[this.pater].img,com.spaceX * this.x + com.pointStartX , com.spaceY * this.y +com.pointStartY);
- com.ct.restore();
- }
- }
-
- this.bl = function (map){
- var map = map || play.map
- return com.bylaw[o.bl](this.x,this.y,map,this.my)
- }
-}
-
-com.class.Bg = function (img, x, y){
- this.x = x||0;
- this.y = y||0;
- this.isShow = true;
-
- this.show = function (){
- if (this.isShow) com.ct.drawImage(com.bgImg, com.spaceX * this.x,com.spaceY * this.y);
- }
-}
-com.class.Pane = function (img, x, y){
- this.x = x||0;
- this.y = y||0;
- this.newX = x||0;
- this.newY = y||0;
- this.isShow = true;
-
- this.show = function (){
- if (this.isShow) {
- com.ct.drawImage(com.paneImg, com.spaceX * this.x + com.pointStartX , com.spaceY * this.y + com.pointStartY)
- com.ct.drawImage(com.paneImg, com.spaceX * this.newX + com.pointStartX , com.spaceY * this.newY + com.pointStartY)
- }
- }
-}
-
-com.class.Dot = function (img, x, y){
- this.x = x||0;
- this.y = y||0;
- this.isShow = true;
- this.dots=[]
-
- this.show = function (){
- for (var i=0; i11&&p[len-1] == p[len-5] &&p[len-5] == p[len-9]){
- return p[len-4].split("");
- }
- return false;
-}
-
-
-
-play.AIclickMan = function (key,x,y){
- var man = com.mans[key];
- //
- man.isShow = false;
- delete play.map[com.mans[play.nowManKey].y][com.mans[play.nowManKey].x];
- play.map[y][x] = play.nowManKey;
- play.showPane(com.mans[play.nowManKey].x ,com.mans[play.nowManKey].y,x,y)
-
- com.mans[play.nowManKey].x = x;
- com.mans[play.nowManKey].y = y;
- play.nowManKey = false;
-
- com.show()
- if (key == "j0") play.showWin (-1);
- if (key == "J0") play.showWin (1);
-}
-
-play.AIclickPoint = function (x,y){
- var key=play.nowManKey;
- var man=com.mans[key];
- if (play.nowManKey){
- delete play.map[com.mans[play.nowManKey].y][com.mans[play.nowManKey].x];
- play.map[y][x] = key;
-
- com.showPane(man.x,man.y,x,y)
-
-
- man.x = x;
- man.y = y;
- play.nowManKey = false;
-
- }
- com.show();
-}
-
-
-play.indexOfPs = function (ps,xy){
- for (var i=0; i8 || y < 0 || y > 9) return false;
- return (play.map[y][x] && play.map[y][x]!="0") ? play.map[y][x] : false;
-}
-
-play.showWin = function (my){
- play.isPlay = false;
- if (my===1){
- alert("ϲ㣬Ӯˣ");
- }else{
- alert("źˣ");
- }
-}
-