-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
178 lines (159 loc) · 7.63 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>chess</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="form.css">
</head>
<body>
<form>
<div class="players">
<fieldset>
<legend>player 1</legend>
<p>
<label for="p1h">human</label>
<input type="radio" id="p1h" name="p1" value="Human" checked>
</p>
<p>
<label for="p1s2">sfBot(1)</label>
<input type="radio" id="p1s2" name="p1" value="SfBot(1)">
</p>
<p>
<label for="p1s8">sfBot(8)</label>
<input type="radio" id="p1s8" name="p1" value="SfBot(8)">
</p>
<p>
<label for="p1s16">sfBot(16)</label>
<input type="radio" id="p1s16" name="p1" value="SfBot(16)">
</p>
<p>
<label for="p1r">randomBot</label>
<input type="radio" id="p1r" name="p1" value="RandomBot">
</p>
<p>
<label for="p1z">zpBot</label>
<input type="radio" id="p1z" name="p1" value="ZpBot">
</p>
</fieldset>
<fieldset>
<legend>player 2</legend>
<p>
<label for="p2h">human</label>
<input type="radio" id="p2h" name="p2" value="Human">
</p>
<p>
<label for="p2s2">sfBot(1)</label>
<input type="radio" id="p2s2" name="p2" value="SfBot(1)">
</p>
<p>
<label for="p2s8">sfBot(8)</label>
<input type="radio" id="p2s8" name="p2" value="SfBot(8)">
</p>
<p>
<label for="p2s16">sfBot(16)</label>
<input type="radio" id="p2s16" name="p2" value="SfBot(16)">
</p>
<p>
<label for="p2r">randomBot</label>
<input type="radio" id="p2r" name="p2" value="RandomBot">
</p>
<p>
<label for="p2z">zpBot</label>
<input type="radio" id="p2z" name="p2" value="ZpBot" checked>
</p>
</fieldset>
</div>
<p>
<label for="play-time-ms">bot play time</label>
<input type="range" id="play-time-ms" value="1200" min="550" max="5000" step="50">
<span id="play-time-ms-val">1200</span>
ms
</p>
<p>
<label for="eval">board evaluations</label>
<input type="checkbox" id="eval" value="1" checked>
</p>
<p>
<label for="dest">valid destinations</label>
<input type="checkbox" id="dest" value="1" checked>
</p>
<p>
<label for="hints">visual annotations</label>
<input type="checkbox" id="hints" value="1">
</p>
<p>
<label for="from-blacks">see board from blacks</label>
<input type="checkbox" id="from-blacks" value="1">
</p>
<p>
<label for="sfx">sound effects</label>
<input type="checkbox" id="sfx" value="1" checked>
</p>
<p>
<label for="tts">text to speech (hear the moves)</label>
<input type="checkbox" id="tts" value="1" checked>
</p>
<p>
<label for="fen">game FEN</label>
<textarea id="fen" cols="80" placeholder="keep empty for default board" spellcheck="false" autocorrect="off"></textarea>
</p>
<p>
<label for="puzzle-pieces">puzzle pieces</label>
<textarea id="puzzle-pieces" cols="80" placeholder="fill with piece characters to get a random board with them" spellcheck="false" autocorrect="off"></textarea>
</p>
<button>play</button>
</form>
<script type="module">
import { puzzle } from './src/puzzle.mjs';
const playBtnEl = document.querySelector('button');
const sfxInputEl = document.getElementById('sfx');
const ttsInputEl = document.getElementById('tts');
const fromBlacksInputEl = document.getElementById('from-blacks');
const playTimeMsInputEl = document.getElementById('play-time-ms');
const sfEvalInputEl = document.getElementById('eval');
const destInputEl = document.getElementById('dest');
const hintsInputEl = document.getElementById('hints');
const fenInputEl = document.getElementById('fen');
const puzzlePiecesInputEl = document.getElementById('puzzle-pieces');
const playTimeMsSpanEl = document.getElementById('play-time-ms-val');
playTimeMsInputEl.addEventListener('change', (ev) => {
playTimeMsSpanEl.textContent = ev.target.value;
});
const DEFAULT_PLAY_TIME_MS = 1200;
playBtnEl.addEventListener('click', async (ev) => {
ev.preventDefault();
ev.stopPropagation();
const p1 = document.querySelector('input[name=p1]:checked').value;
const p2 = document.querySelector('input[name=p2]:checked').value;
const sfx = sfxInputEl.checked;
const tts = ttsInputEl.checked;
const fromBlacks = fromBlacksInputEl.checked;
const playTimeMs = playTimeMsInputEl.value;
const sfEval = sfEvalInputEl.checked;
const dest = destInputEl.checked;
const hints = hintsInputEl.checked;
let fen = fenInputEl.value;
const puzzlePieces = puzzlePiecesInputEl.value;
// console.log({ p1, p2, fromBlacks, playTimeMs, sfEval, hints, fen, puzzlePieces });
const u = new URLSearchParams();
u.set('p1', p1);
u.set('p2', p2);
sfx && u.set('sfx', '1');
tts && u.set('tts', '1');
fromBlacks && u.set('from-blacks', '1');
(playTimeMs != DEFAULT_PLAY_TIME_MS) && u.set('play-time-ms', playTimeMs);
sfEval && u.set('eval', '1');
dest && u.set('dest', '1');
hints && u.set('hints', '1');
if (puzzlePieces) {
const board = await puzzle(puzzlePieces);
fen = board.getFen();
}
window.location.href = `./play.html?${u.toString()}${fen ? `#${fen}` : ''}`;
});
</script>
</body>
</html>