Skip to content

Add support for the threefold repetition rule using incremental transposition tables #1

@i13e

Description

@i13e

Currently, Osmanthus does not support the threefold repetition rule, which states that a player can claim a draw if the same position occurs three times with the same player to move. While Python's chess library has support for this rule (see here), it is slow because it does not use incremental transposition tables.

To improve the performance of the engine, we should add support for the threefold repetition rule using incremental transposition tables. This would allow us to quickly check whether a position has occurred three times in the game and avoid recomputing the same position repeatedly.

Specifically, we should implement the following changes:

  1. Add a new transposition table for storing positions and their repetition counts.
  2. Update the move generator to check whether a move would result in a repeated position.
  3. Increment the repetition count in the transposition table whenever a position occurs for the second time.
  4. If a position occurs for the third time, the player can claim a draw.

By implementing these changes, we can ensure that Osmanthus correctly handles the threefold repetition rule while maintaining good performance.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions