1- Core
2- ====
1+ Core API
2+ ========
33
4- Colors
4+ Boards
55------
66
7- Constants for the side to move or the color of a piece.
8-
9- .. py :data :: draughts.Color.WHITE
10- :type: draughts.Color
11- :value: -1
12-
13- Constant representing the white side.
14-
15- .. py :data :: draughts.Color.BLACK
16- :type: draughts.Color
17- :value: 1
18-
19- Constant representing the black side.
20-
21- Example usage::
7+ All board classes inherit from :class: `~draughts.BaseBoard `.
8+ Use ``Board `` (alias for ``StandardBoard ``) for the most common variant.
229
23- from draughts import StandardBoard, Color
24-
25- board = StandardBoard()
26- print(board.turn) # Color.WHITE
27-
28- # Toggle turn
29- if board.turn == Color.WHITE:
30- print("White to move")
31-
32- Figures (Piece Types)
33- ---------------------
34-
35- Constants representing piece types in draughts.
36-
37- .. py :data :: draughts.Figure.BLACK_KING
38- :type: draughts.Figure
39- :value: 2
10+ .. autoclass :: draughts.StandardBoard
11+ :members:
12+ :inherited-members:
13+ :show-inheritance:
4014
41- A black king piece.
15+ .. autoclass :: draughts.AmericanBoard
16+ :members:
17+ :show-inheritance:
18+ :noindex:
4219
43- .. py :data :: draughts.Figure.BLACK_MAN
44- :type: draughts.Figure
45- :value: 1
20+ .. autoclass :: draughts.FrisianBoard
21+ :members:
22+ :show-inheritance:
23+ :noindex:
4624
47- A black man (regular piece).
25+ .. autoclass :: draughts.RussianBoard
26+ :members:
27+ :show-inheritance:
28+ :noindex:
4829
49- .. py :data :: draughts.Figure.WHITE_KING
50- :type: draughts.Figure
51- :value: -2
30+ BaseBoard
31+ ~~~~~~~~~
5232
53- A white king piece.
33+ .. autoclass :: draughts.BaseBoard
34+ :members:
35+ :noindex:
5436
55- .. py :data :: draughts.Figure.WHITE_MAN
56- :type: draughts.Figure
57- :value: -1
37+ Moves
38+ -----
5839
59- A white man (regular piece).
40+ .. autoclass :: draughts.Move
41+ :members:
6042
61- .. py :data :: draughts.Figure.EMPTY
62- :type: draughts.Figure
63- :value: 0
43+ Types
44+ -----
6445
65- An empty square.
46+ .. autoclass :: draughts.Color
47+ :members:
48+ :undoc-members:
6649
67- Squares
68- -------
50+ .. autoclass :: draughts.Figure
51+ :members:
52+ :undoc-members:
6953
70- In py-draughts, squares are numbered from 1 to 50 for standard (10×10) boards
71- and 1 to 32 for American (8×8) boards. Only dark squares are numbered and used
72- in the game.
54+ Square Numbering
55+ ----------------
7356
74- Standard Board (10×10)
75- ~~~~~~~~~~~~~~~~~~~~~~
57+ Only dark squares are playable and numbered.
7658
77- Squares are numbered 1-50:
59+ ** Standard Board (10×10) ** - Squares 1-50:
7860
7961.. code-block :: text
8062
@@ -89,10 +71,7 @@ Squares are numbered 1-50:
8971 41 42 43 44 45
9072 46 47 48 49 50
9173
92- American/Russian Board (8×8)
93- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
94-
95- Both American and Russian draughts use an 8×8 board with squares numbered 1-32:
74+ **American/Russian Board (8×8) ** - Squares 1-32:
9675
9776.. code-block :: text
9877
@@ -105,155 +84,32 @@ Both American and Russian draughts use an 8×8 board with squares numbered 1-32:
10584 25 26 27 28
10685 29 30 31 32
10786
108- Board Factory
109- -------------
110-
111- .. autofunction :: draughts.get_board
112-
113- Example::
114-
115- from draughts import get_board
116-
117- # Create a standard board
118- board = get_board('standard')
119-
120- # Create an American board
121- board = get_board('american')
122-
123- # Create a Frisian board (with orthogonal captures)
124- board = get_board('frisian')
125-
126- # Create a Russian board (flying kings, free capture choice)
127- board = get_board('russian')
128-
129- # Create a board from FEN
130- board = get_board('standard', fen='W:W31,32,33:B18,19,20')
131-
132- Boards
133- ------
134-
135- All board classes inherit from the base :class: `draughts.boards.base.BaseBoard ` class.
136-
137- StandardBoard
138- ~~~~~~~~~~~~~
139-
140- .. autoclass :: draughts.boards.standard.Board
141- :members:
142- :inherited-members:
143- :show-inheritance:
87+ Notation
88+ --------
14489
145- AmericanBoard
146- ~~~~~~~~~~~~~
90+ **FEN ** (Forsyth-Edwards Notation) represents board positions::
14791
148- .. autoclass :: draughts.boards.american.Board
149- :members:
150- :inherited-members:
151- :show-inheritance:
92+ W:W31,32,33:B18,19,20 # W = White to move, pieces listed
93+ W:WK10,K20:BK35,K45 # K prefix = King
15294
153- FrisianBoard
154- ~~~~~~~~~~~~
95+ **PDN ** (Portable Draughts Notation) records games::
15596
156- .. autoclass :: draughts.boards.frisian.Board
157- :members:
158- :inherited-members:
159- :show-inheritance:
160-
161- RussianBoard
162- ~~~~~~~~~~~~
163-
164- Russian draughts uses an 8×8 board like American checkers, but with key differences:
165-
166- - **Flying kings ** that move any distance diagonally (like International)
167- - **Men capture backward ** (unlike American where men only capture forward)
168- - **Free capture choice ** - not required to take maximum captures (unlike International)
169- - **Mid-capture promotion ** - if a man reaches the promotion rank during a capture, it becomes a king and continues capturing as a king
170-
171- .. autoclass :: draughts.boards.russian.Board
172- :members:
173- :inherited-members:
174- :show-inheritance:
175-
176- BaseBoard
177- ~~~~~~~~~
178-
179- .. autoclass :: draughts.boards.base.BaseBoard
180- :members:
181-
182- Moves
183- -----
184-
185- .. autoclass :: draughts.move.Move
186- :members:
187-
188- Example::
189-
190- from draughts import StandardBoard
191-
192- board = StandardBoard()
193-
194- # Make a move using UCI notation
195- move = board.push_uci("31-27")
196- print(move) # Move: 31->27
197-
198- # Iterate through legal moves
199- for move in board.legal_moves:
200- print(move)
201-
202- # Undo the last move
203- board.pop()
204-
205- FEN Notation
206- ------------
207-
208- py-draughts uses FEN (Forsyth-Edwards Notation) adapted for draughts to represent board positions.
209-
210- Format::
211-
212- [Side to move]:[White pieces]:[Black pieces]
213-
214- Example::
215-
216- W:W31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50:B1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
217-
218- Kings are prefixed with 'K'::
219-
220- W:WK10,K20:BK35,K45
97+ [GameType "20"]
98+ [Variant "Standard"]
99+ 1. 31-27 18-22 2. 27x18 12x23
221100
222101Usage::
223102
224- from draughts import StandardBoard
225-
226- # From FEN
227- fen = "W:WK10,K20:BK35,K45"
228- board = StandardBoard.from_fen(fen)
229-
230- # To FEN
231- fen_string = board.to_fen()
232-
233- PDN Notation
234- ------------
235-
236- PDN (Portable Draughts Notation) is used for recording games, similar to PGN in chess.
237-
238- Format::
103+ from draughts import Board
239104
240- [GameType "20"]
241- [Variant "Standard (international) checkers"]
242- [Result "-"]
243- 1. 31-27 32-28 2. 27-23 28-24
105+ # From FEN
106+ board = Board.from_fen("W:WK10,K20:BK35,K45")
244107
245- Usage::
108+ # To FEN
109+ print(board.fen)
246110
247- from draughts import StandardBoard
248-
249- # Generate PDN
250- board = StandardBoard()
251- board.push_uci("31-27")
252- board.push_uci("19-23")
253- pdn = board.pdn
254- print(pdn)
255-
256111 # From PDN
257- pdn_string = '''[GameType "20"]
258- 1. 32-28 19-23 2. 28x19 14x23'''
259- board = StandardBoard.from_pdn(pdn_string)
112+ board = Board.from_pdn('[GameType "20"]\n1. 32-28 19-23')
113+
114+ # To PDN
115+ print(board.pdn)
0 commit comments