American checkers
- class draughts.boards.american.Board(starting_position: ndarray = None, turn: Color = None)[source]
- Board for American checkers.
Game rules:
Board size: 8x8
Short moves only
Only the king can capture backwards
Capture - choose any
- GAME_TYPE = 23
PDN game type. See PDN specification.
- STARTING_COLOR = -1
Starting color.
Color.WHITE
orColor.BLACK
.
- ROW_IDX = {0: 0, 1: 0, 2: 0, 3: 0, 4: 1, 5: 1, 6: 1, 7: 1, 8: 2, 9: 2, 10: 2, 11: 2, 12: 3, 13: 3, 14: 3, 15: 3, 16: 4, 17: 4, 18: 4, 19: 4, 20: 5, 21: 5, 22: 5, 23: 5, 24: 6, 25: 6, 26: 6, 27: 6, 28: 7, 29: 7, 30: 7, 31: 7}
Dictionary of row indexes for every square. Generated only on module import. Used to calculate legal moves.
- COL_IDX = {0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 0, 9: 1, 10: 2, 11: 3, 12: 4, 13: 5, 14: 6, 15: 7, 16: 0, 17: 1, 18: 2, 19: 3, 20: 4, 21: 5, 22: 6, 23: 7, 24: 0, 25: 1, 26: 2, 27: 3, 28: 4, 29: 5, 30: 6, 31: 7}
Same as
ROW_IDX
but for columns.
- DIAGONAL_LONG_MOVES = {0: [[], [], [5, 9], [4]], 1: [[], [], [6, 10], [5, 8]], 2: [[], [], [7, 11], [6, 9]], 3: [[], [], [], [7, 10]], 4: [[0], [], [8, 13], []], 5: [[1], [0], [9, 14], [8, 12]], 6: [[2], [1], [10, 15], [9, 13]], 7: [[3], [2], [11], [10, 14]], 8: [[5, 1], [4], [13, 17], [12]], 9: [[6, 2], [5, 0], [14, 18], [13, 16]], 10: [[7, 3], [6, 1], [15, 19], [14, 17]], 11: [[], [7, 2], [], [15, 18]], 12: [[8, 5], [], [16, 21], []], 13: [[9, 6], [8, 4], [17, 22], [16, 20]], 14: [[10, 7], [9, 5], [18, 23], [17, 21]], 15: [[11], [10, 6], [19], [18, 22]], 16: [[13, 9], [12], [21, 25], [20]], 17: [[14, 10], [13, 8], [22, 26], [21, 24]], 18: [[15, 11], [14, 9], [23, 27], [22, 25]], 19: [[], [15, 10], [], [23, 26]], 20: [[16, 13], [], [24, 29], []], 21: [[17, 14], [16, 12], [25, 30], [24, 28]], 22: [[18, 15], [17, 13], [26, 31], [25, 29]], 23: [[19], [18, 14], [27], [26, 30]], 24: [[21, 17], [20], [29], [28]], 25: [[22, 18], [21, 16], [30], [29]], 26: [[23, 19], [22, 17], [31], [30]], 27: [[], [23, 18], [], [31]], 28: [[24, 21], [], [], []], 29: [[25, 22], [24, 20], [], []], 30: [[26, 23], [25, 21], [], []], 31: [[27], [26, 22], [], []]}
Dictionary of pseudo-legal moves for king pieces. Generated only on module import. This dictionary contains all possible moves for king piece (as if there were no other pieces on the board).
Structure:
[(right-up moves), (left-up moves), (right-down moves), (left-down moves)]
- DIAGONAL_SHORT_MOVES = {0: [[], [], [5, 9, 14, 18, 23, 27], [4]], 1: [[], [], [6, 10, 15, 19], [5, 8, 12]], 2: [[], [], [7, 11], [6, 9, 13, 16, 20]], 3: [[], [], [], [7, 10, 14, 17, 21, 24, 28]], 4: [[0], [], [8, 13, 17, 22, 26, 31], []], 5: [[1], [0], [9, 14, 18, 23, 27], [8, 12]], 6: [[2], [1], [10, 15, 19], [9, 13, 16, 20]], 7: [[3], [2], [11], [10, 14, 17, 21, 24, 28]], 8: [[5, 1], [4], [13, 17, 22, 26, 31], [12]], 9: [[6, 2], [5, 0], [14, 18, 23, 27], [13, 16, 20]], 10: [[7, 3], [6, 1], [15, 19], [14, 17, 21, 24, 28]], 11: [[], [7, 2], [], [15, 18, 22, 25, 29]], 12: [[8, 5, 1], [], [16, 21, 25, 30], []], 13: [[9, 6, 2], [8, 4], [17, 22, 26, 31], [16, 20]], 14: [[10, 7, 3], [9, 5, 0], [18, 23, 27], [17, 21, 24, 28]], 15: [[11], [10, 6, 1], [19], [18, 22, 25, 29]], 16: [[13, 9, 6, 2], [12], [21, 25, 30], [20]], 17: [[14, 10, 7, 3], [13, 8, 4], [22, 26, 31], [21, 24, 28]], 18: [[15, 11], [14, 9, 5, 0], [23, 27], [22, 25, 29]], 19: [[], [15, 10, 6, 1], [], [23, 26, 30]], 20: [[16, 13, 9, 6, 2], [], [24, 29], []], 21: [[17, 14, 10, 7, 3], [16, 12], [25, 30], [24, 28]], 22: [[18, 15, 11], [17, 13, 8, 4], [26, 31], [25, 29]], 23: [[19], [18, 14, 9, 5, 0], [27], [26, 30]], 24: [[21, 17, 14, 10, 7, 3], [20], [29], [28]], 25: [[22, 18, 15, 11], [21, 16, 12], [30], [29]], 26: [[23, 19], [22, 17, 13, 8, 4], [31], [30]], 27: [[], [23, 18, 14, 9, 5, 0], [], [31]], 28: [[24, 21, 17, 14, 10, 7, 3], [], [], []], 29: [[25, 22, 18, 15, 11], [24, 20], [], []], 30: [[26, 23, 19], [25, 21, 16, 12], [], []], 31: [[27], [26, 22, 17, 13, 8, 4], [], []]}
Same as
DIAGONAL_LONG_MOVES
but contains only first 2 squares of the move. (one for move and one for capture)