html
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
<!--
Brython Chess Board UI (by HonFu)
---------------------------------
This is basically a game board which knows the rules and allows only valid moves.
What it does understand:
- basic movements
- castling
- en passant
- pawn transformation
- check
- check mate
- stalemate
- remis (threefold repetition, fifty-move-rule)
What it doesn't understand yet:
- remis (lack of material, dead positions)
I will aim at improving the code further, tidy it up, add comments.
So far, if you should find any bug, please tell me!
I hope you like it. :-)
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* Brython Chess Board UI (by HonFu) */
body {
background-color: #111;
}
#board {
font-size: 27px;
margin: auto;
height: 304px;
width: 304px;
display: grid;
grid-template-columns:
1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
grid-template-rows:
1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
}
Enter to Rename, Shift+Enter to Preview
js
js
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
//</script><script type="text/python">
# Brython Chess Board UI (by HonFu)
from browser import document, html, prompt, alert
class ChessPiece:
def __init__(self, board, i, j, king=None):
self._king = king or self
self._board = board
self._board[i][j] = self
self._i = i
self._j = j
if isinstance(self, King):
self._subjects = []
else:
self._king._subjects.append(self)
def move(self, i, j, serious=True):
if (i, j) not in self.moves():
return 0
b = self._king.tacticalchart()
b[self._i][self._j]._move(i, j)
if b[i][j]._king.incheck():
return 0
if serious:
self._move(i, j)
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run