Skip to content

feat: create bot engine interface and tests#16

Merged
Mgrdich merged 28 commits intomainfrom
bot-v1
Jan 18, 2026
Merged

feat: create bot engine interface and tests#16
Mgrdich merged 28 commits intomainfrom
bot-v1

Conversation

@Mgrdich
Copy link
Owner

@Mgrdich Mgrdich commented Jan 13, 2026

Establish bot package foundation with Engine interface, optional interfaces for advanced features, and comprehensive test coverage.

Mgrdich and others added 5 commits January 13, 2026 11:43
Establish bot package foundation with Engine interface, optional
interfaces for advanced features, and comprehensive test coverage.
Factory infrastructure for creating engines with custom configuration.
Includes placeholder factories and comprehensive validation tests.
First playable bot using random legal move selection. Includes
comprehensive tests and validates bot infrastructure.
Weighted move selection gives Easy bot personality while remaining
beatable. Includes comprehensive statistical tests.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request establishes the foundation for the bot package by implementing core interfaces, factory patterns, and the first working bot opponent (Easy Bot). The implementation includes comprehensive test coverage for interface contracts, factory options, and bot behavior.

Changes:

  • Defined Engine interface and optional interfaces (Configurable, Stateful, Inspectable) with supporting types
  • Implemented factory pattern with functional options for flexible engine configuration
  • Created Easy Bot with weighted random move selection (70% tactical bias towards captures and checks)

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
internal/bot/engine.go Core bot package with Engine interface, optional interfaces (Configurable, Stateful, Inspectable), EngineType and Difficulty enums with String methods
internal/bot/engine_test.go Comprehensive interface contract tests using mock implementations to verify all interfaces work correctly
internal/bot/factory.go Factory functions (NewRandomEngine, NewMinimaxEngine placeholder) and functional options (WithTimeLimit, WithSearchDepth, WithOptions)
internal/bot/factory_test.go Tests for factory options validation, engine creation with various configurations, and option chaining/overrides
internal/bot/random.go Easy Bot implementation with randomEngine struct, weighted move selection favoring captures (70%) and checks (50%), and helper functions for filtering moves
internal/bot/random_test.go Extensive tests covering legal move selection, error cases, weighted selection bias, distribution tests, and edge cases
context/spec/004-bot-opponents/tasks.md Documentation update marking Tasks 1-4 as completed

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Fix en passant detection, add proper RNG seeding, use atomic operations for thread safety, standardize FEN parsing, and improve test error handling
Add ply distance parameter to alphaBeta to adjust mate scores (10000-ply), so mate-in-1 scores higher than mate-in-3. Fixes TestMinimaxEngine_FindsMateInOne.
Add piece-square tables (pawn advancement, knight centralization, rook 7th rank, etc.) and mobility evaluation. Medium/Hard bots now understand piece positioning. Easy bot unchanged (material-only).
Evaluate pawn shield (0.3/pawn), open files near king (0.25/file), and attackers in king zone (0.1/square). Hard bot now understands king safety. Medium/Easy bots unchanged.
Implement Configure() and Info() methods enabling runtime parameter tuning. Supports configuring search depth (1-20), time limits, and evaluation weights (material, piece-square, mobility, king safety). Includes validation and comprehensive test coverage with 7 new tests.
Replace map[string]any with pointer-based struct for engine configuration.
Provides compile-time type safety and clearer API. Update all tests and
documentation accordingly.
Expand go-cli-expert.md with detailed best practices, patterns, and common
pitfalls. Remove config file examples, keep focus on coding standards.
Complete Task 11 of bot opponents spec. Add bot difficulty selection screen,
async bot move execution with thinking messages, proper cleanup on all exit
paths. All bot difficulty levels (Easy/Medium/Hard) now playable in UI.
Add color selection screen allowing users to play as White or Black. When user
plays Black, bot makes the opening move immediately after setup. Includes full
integration tests and navigation for color selection UI.
@Mgrdich
Copy link
Owner Author

Mgrdich commented Jan 14, 2026

@copilot review the code

Copy link

Copilot AI commented Jan 14, 2026

@Mgrdich I've opened a new pull request, #17, to work on those changes. Once the pull request is ready, I'll request review from you.

@Mgrdich Mgrdich merged commit 609a9a6 into main Jan 18, 2026
0 of 2 checks passed
@Mgrdich Mgrdich deleted the bot-v1 branch January 18, 2026 22:08
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.

3 participants