Skip to content

Create CodeBreaker.BotWithString project using string-based algorithm and add unit tests#319

Merged
christiannagel merged 3 commits intomainfrom
copilot/fix-318
Sep 17, 2025
Merged

Create CodeBreaker.BotWithString project using string-based algorithm and add unit tests#319
christiannagel merged 3 commits intomainfrom
copilot/fix-318

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 17, 2025

This PR implements a new string-based version of the bot project that works with the Games API using string arrays instead of binary data, as requested in the issue.

What's New

CodeBreaker.BotWithString Project:

  • StringCodeBreakerAlgorithms: Core algorithms adapted from the binary version but operating entirely with string[] arrays
  • StringBotGameRunner: Demonstration class showing integration with the GameAPIs client
  • Complete project structure with proper configuration and documentation

CodeBreaker.BotWithString.Tests Project:

  • 25 comprehensive unit tests covering all algorithms and edge cases
  • Mock-based integration tests for the game runner functionality
  • Full coverage of all game types (Game6x4, Game8x5, Game5x5x4)

Key Implementation Details

The string-based algorithms provide equivalent functionality to the binary version:

// Generate all possible combinations for a game
var combinations = StringCodeBreakerAlgorithms.GenerateAllPossibleCombinations(
    GameType.Game6x4, 
    new[] { "Red", "Blue", "Green", "Yellow" });

// Filter based on game results
var filtered = combinations
    .HandleBlackMatches(GameType.Game6x4, blackHits, guess)
    .HandleWhiteMatches(GameType.Game6x4, whiteHits, guess);

Benefits Over Binary Version

  • Direct API compatibility: Works seamlessly with IGamesClient string-based methods
  • Improved readability: String operations are more intuitive than bit manipulation
  • Easier debugging: Color names are human-readable throughout the algorithm
  • Simplified logic: No bit masks, shifts, or binary encoding required

Testing Coverage

All algorithms are thoroughly tested with scenarios including:

  • Exact position matches (black hits)
  • Correct color, wrong position matches (white hits)
  • Partial matches for Game5x5x4 (blue hits)
  • No matches filtering
  • Edge cases and error conditions
  • Game runner integration with various scenarios

The implementation maintains the same algorithmic approach as the original binary version while providing a more accessible string-based interface for future benchmark comparisons.

Fixes #318.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits September 17, 2025 09:25
… and comprehensive tests

Co-authored-by: christiannagel <1908285+christiannagel@users.noreply.github.com>
…omprehensive tests, and documentation

Co-authored-by: christiannagel <1908285+christiannagel@users.noreply.github.com>
Copilot AI changed the title [WIP] Create CodeBreaker.BotWithString project using string-based algorithm and add unit tests Create CodeBreaker.BotWithString project using string-based algorithm and add unit tests Sep 17, 2025
@christiannagel christiannagel marked this pull request as ready for review September 17, 2025 10:13
@christiannagel christiannagel merged commit f6929de into main Sep 17, 2025
3 checks passed
@christiannagel christiannagel deleted the copilot/fix-318 branch September 17, 2025 10:13
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.

Create CodeBreaker.BotWithString project using string-based algorithm and add unit tests

2 participants