-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.html
161 lines (157 loc) · 4.78 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>简易围棋</title>
<script src="core.js"></script>
<script src="index.js"></script>
<script src="sgf.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="ai/convnet-min.js"></script>
<script src="ai/net.js"></script>
<script src="ai/ai.js"></script>
<style>
body {
margin: 0 auto;
width:600px;
}
#weiqi {
border: 0px solid blue;
position: absolute;
top:50px;
}
#path {
position: absolute;
top:50px;
z-index: 200;
}
.btn{
background-color: #e65a39;
color: white;
padding: 0 4px;
margin: 0 2px;
}
.deleteBlue{
-moz-user-select: none; /*mozilar*/
-webkit-user-select: none; /*webkit*/
-ms-user-select: none; /*IE*/
user-select: none;
}
</style>
</head>
<body class="deleteBlue">
<canvas id="weiqi" width="600" height="600"></canvas>
<canvas id="path" width="600" height="600"></canvas>
<br>
<span class="btn deleteBlue" id="start"><<</span>
<span class="btn deleteBlue" id="back"> < </span>
<span class="btn deleteBlue" id="next"> > </span>
<span class="btn deleteBlue" id="end">>></span>
<span class="btn deleteBlue" id="new">显示手数</span>
<span class="btn deleteBlue" id="auto">自动</span>
<span class="btn deleteBlue" >黑:<span id="blackUp">0</span></span>
<span class="btn deleteBlue" >白:<span id="whiteUp">0</span></span>
<span class="btn deleteBlue" id="ai">神之一手</span>
<span class="btn deleteBlue" id="lock">锁定</span>
</body>
<script>
$(function () {
draw();
$(document).on("click","#back",function () {
backStep();
draw();
});
$(document).on("click","#next",function () {
nextStep();
draw();
});
$(document).on("click","#start",function () {
startStep();
draw();
});
$(document).on("click","#end",function () {
endStep();
draw();
});
$(document).on("click","#new",function () {
if(move_show_flag){
$(this).text("显示手数")
}else{
$(this).text("隐藏手数")
}
move_show_flag=!move_show_flag;
draw();
});
$(document).on("click","#ai",function () {
convMove();
});
let autoFlag;
$(document).on("click","#auto",function () {
autoNext=!autoNext;
let that=$(this);
if(autoNext){
autoFlag=setInterval(function () {
if(jumpPointer+1>record.length-1){
autoNext=false;
that.text("自动")
clearInterval(autoFlag);
return;
}
nextStep();
draw();
if(jumpPointer+1>record.length-1){
autoNext=false;
that.text("自动")
clearInterval(autoFlag);
return;
}
},1000)
that.text("停止")
}else{
clearInterval(autoFlag);
that.text("自动")
}
})
$("body").bind("contextmenu", function () {
backStep();
draw();
return false;
});
let click=0;
$(document).on("click","#lock",function () {
console.log(click)
switch (click) {
case 0:
$(this).text("锁定黑色")
lockQiRole=qiType.black;
click++;
break;
case 1:
$(this).text("锁定白色")
lockQiRole=qiType.white;
click++;
break;
case 2:
$(this).text("白黑")
whoIsPlay=qiType.white
lockQiRole=undefined;
click++;
break;
case 3:
$(this).text("黑白")
whoIsPlay=qiType.black
lockQiRole=undefined;
click=0;
break;
}
});
})
function importSGF(sgf) {
let record=parser(sgf);
for (let i=0;i<record.length;i++){
play(record[i][0],record[i][1],record[i][2])
}
draw();
}
</script>
</html>