Skip to content

Optimize generate_pseudo_legal_moves for improved performance#1

Open
codelion wants to merge 1 commit intomasterfrom
improve-perf
Open

Optimize generate_pseudo_legal_moves for improved performance#1
codelion wants to merge 1 commit intomasterfrom
improve-perf

Conversation

@codelion
Copy link
Copy Markdown
Owner

Applied performance optimizations to the generate_pseudo_legal_moves method discovered through automated code evolution using OpenEvolve.

  1. Loop consolidation for pawn promotions: Replaced 4 separate yield statements with a single loop over promotion pieces, reducing function call overhead
  2. Early bitwise filtering for double pawn moves: Filter by rank before bit shifting ((single_moves & BB_RANK_3) << 8) instead of after, eliminating redundant operations
  • Added test_move_generation_performance.py to demonstrate and verify optimizations
  • Validates correctness across multiple board positions (starting position, en passant, promotions)
  • Benchmarks performance with 100,000 iterations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant