sachin-chess-utils 0.1.2__py3-none-any.whl → 0.1.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1,3 @@
1
1
  from .main import hello
2
+ from .move import describe_move
3
+
@@ -0,0 +1,65 @@
1
+ import chess
2
+
3
+ pice_mapping = {
4
+ key: value
5
+ for key, value in zip(chess.PIECE_SYMBOLS, chess.PIECE_NAMES)
6
+ }
7
+
8
+ def describe_move(move, extra=None):
9
+ """
10
+ >>> describe_move('Nxe4#')
11
+ 'Knight captures e4 check and mate.'
12
+ """
13
+
14
+ move = move.lower()
15
+
16
+ is_check = move[-1] == '+'
17
+ is_mate = move[-1] == '#'
18
+ if is_check or is_mate:
19
+ move = move[:-1]
20
+
21
+ is_ep = extra == 'e.p.'
22
+
23
+ is_pawn_move = len(move) == 2
24
+
25
+ if move == 'o-o':
26
+ return 'castle king size'
27
+ if move == 'o-o-o':
28
+ return 'castle queen size'
29
+
30
+ square = move[-2:]
31
+
32
+ p = move[0].upper()
33
+ is_pice = False
34
+ if p in [pi.upper() for pi in list(pice_mapping.keys())[1:]]:
35
+ pice = pice_mapping[p.lower()]
36
+ is_pice = True
37
+ else:
38
+ pice = p
39
+
40
+ is_capture = False
41
+ if 'x' in move:
42
+ is_capture = True
43
+ move = move.replace('x', '')
44
+
45
+ is_doubled_pice = False
46
+ if is_pice and len(move) == 4:
47
+ is_doubled_pice = True
48
+
49
+ output = ''
50
+ if is_pawn_move:
51
+ output = move
52
+ else:
53
+ output = pice + ' ' + (move[1] if is_doubled_pice else '') + (
54
+ ' captures ' if is_capture else ' to ') + square
55
+
56
+ if is_check:
57
+ output += ' check'
58
+
59
+ if is_mate:
60
+ output += ' check and mate'
61
+
62
+ if is_ep:
63
+ output += ' en passant'
64
+
65
+ return output
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sachin-chess-utils
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: UNKNOWN
5
5
  Home-page: UNKNOWN
6
6
  Author: Sachin Chauhan Infocusp
7
7
  License: UNKNOWN
8
8
  Platform: UNKNOWN
9
9
  Description-Content-Type: text/markdown
10
- Requires-Dist: numpy (>=1.11.0)
10
+ Requires-Dist: chess (==1.11.2)
11
11
 
12
12
  # sachin-chess-utils
13
13
 
@@ -0,0 +1,8 @@
1
+ sachin_chess_utils/__init__.py,sha256=MeOM322WTU8yCmRUToqwaPquyvlnI8WxBFuM-HUpE3c,57
2
+ sachin_chess_utils/main.py,sha256=Hg4BBo12oTsUeANHQ4t77WcK-lvUaMFrtkc0azI0qkI,97
3
+ sachin_chess_utils/move.py,sha256=WgBYQe7_VmpLPPsIAkPc52JUQSP2hGa-jjdHpgTLlEk,1352
4
+ sachin_chess_utils-0.1.3.dist-info/METADATA,sha256=B7TOygec1QHa0YXfcOoF1tO4IuWSvmlde-Cc_SSMN7U,533
5
+ sachin_chess_utils-0.1.3.dist-info/WHEEL,sha256=00yskusixUoUt5ob_CiUp6LsnN5lqzTJpoqOFg_FVIc,92
6
+ sachin_chess_utils-0.1.3.dist-info/entry_points.txt,sha256=hGJ3J_tepCGzSrdCfH8OplmaMPvCVDKvDKMrWfVYgac,59
7
+ sachin_chess_utils-0.1.3.dist-info/top_level.txt,sha256=7rW6areR0D7SZ19i5nqaKF9L_NeM_7jeqvOXnqx1iBc,19
8
+ sachin_chess_utils-0.1.3.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- sachin_chess_utils/__init__.py,sha256=317xV69t_woOlT69eParPy7mRhbHqlcEWNHX_01HEsg,24
2
- sachin_chess_utils/main.py,sha256=Hg4BBo12oTsUeANHQ4t77WcK-lvUaMFrtkc0azI0qkI,97
3
- sachin_chess_utils-0.1.2.dist-info/METADATA,sha256=otAp4J8CFxhwCezB3pOPNW-Edwe_kq8PptGXQE341II,533
4
- sachin_chess_utils-0.1.2.dist-info/WHEEL,sha256=00yskusixUoUt5ob_CiUp6LsnN5lqzTJpoqOFg_FVIc,92
5
- sachin_chess_utils-0.1.2.dist-info/entry_points.txt,sha256=hGJ3J_tepCGzSrdCfH8OplmaMPvCVDKvDKMrWfVYgac,59
6
- sachin_chess_utils-0.1.2.dist-info/top_level.txt,sha256=7rW6areR0D7SZ19i5nqaKF9L_NeM_7jeqvOXnqx1iBc,19
7
- sachin_chess_utils-0.1.2.dist-info/RECORD,,