{"id":30658951,"url":"https://github.com/jwc20/bncpy","last_synced_at":"2025-08-31T12:19:58.630Z","repository":{"id":308266513,"uuid":"1032204933","full_name":"jwc20/bncpy","owner":"jwc20","description":"Benjamin and Charlotte, the code guessing game","archived":false,"fork":false,"pushed_at":"2025-08-20T07:24:31.000Z","size":147,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-20T09:12:12.184Z","etag":null,"topics":["benjamin","charlotte","code","game","python","random"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/bncpy/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jwc20.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-05T01:24:03.000Z","updated_at":"2025-08-17T08:43:21.000Z","dependencies_parsed_at":"2025-08-20T09:09:05.705Z","dependency_job_id":"8c443792-66d7-4fb5-8ac9-7c885fc59f5e","html_url":"https://github.com/jwc20/bncpy","commit_stats":null,"previous_names":["jwc20/bnc","jwc20/bncpy"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jwc20/bncpy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwc20%2Fbncpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwc20%2Fbncpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwc20%2Fbncpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwc20%2Fbncpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jwc20","download_url":"https://codeload.github.com/jwc20/bncpy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwc20%2Fbncpy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272978627,"owners_count":25025360,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-31T02:00:09.071Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["benjamin","charlotte","code","game","python","random"],"created_at":"2025-08-31T12:19:53.829Z","updated_at":"2025-08-31T12:19:58.616Z","avatar_url":"https://github.com/jwc20.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv id=\"top\"\u003e\n\n\u003c!-- HEADER STYLE: CLASSIC --\u003e\n\u003cdiv align=\"center\"\u003e\n\n\u003cimg src=\"cow.svg\" width=\"30%\" style=\"position: relative; top: 0; right: 0;\" alt=\"Project Logo\"/\u003e\n\n# BNCPY\n\n\u003cem\u003eUnleashing Collaborative Code-Breaking Fun for Everyone\u003c/em\u003e\n\n\u003c!-- BADGES --\u003e\n\u003cimg src=\"https://img.shields.io/github/license/jwc20/bncpy?style=default\u0026logo=opensourceinitiative\u0026logoColor=white\u0026color=0080ff\" alt=\"license\"\u003e\n\u003cimg src=\"https://img.shields.io/github/last-commit/jwc20/bncpy?style=default\u0026logo=git\u0026logoColor=white\u0026color=0080ff\" alt=\"last-commit\"\u003e\n\u003cimg src=\"https://img.shields.io/github/languages/top/jwc20/bncpy?style=default\u0026color=0080ff\" alt=\"repo-top-language\"\u003e\n\u003cimg src=\"https://img.shields.io/github/languages/count/jwc20/bncpy?style=default\u0026color=0080ff\" alt=\"repo-language-count\"\u003e\n\n\u003c!-- default option, no dependency badges. --\u003e\n\nBenjamin and Charlotte python library\n\nDemo: https://bnc-client-psi.vercel.app\n\nDocs: https://jwc20.github.io/bnc-docs/\n\nMono-repo: https://github.com/jwc20/bnc-game\n\nBE: https://github.com/jwc20/bncapi\n\nFE: https://github.com/jwc20/bnc-client\n\n\n\u003c!-- default option, no dependency badges. --\u003e\n\n\u003c/div\u003e\n\u003cbr\u003e\n\n---\n\n## Table of Contents\n\n- [Table of Contents](#table-of-contents)\n- [Overview](#overview)\n- [Project Structure](#project-structure)\n  - [Project Index](#project-index)\n- [Getting Started](#getting-started)\n  - [Prerequisites](#prerequisites)\n  - [Installation](#installation)\n  - [Usage](#usage)\n\n---\n\n## Overview\n\nbncpy is a robust Python-based game development tool that simplifies the process of creating a code-breaking game.\n\nThis project streamlines the game development process, providing a comprehensive suite of features for building a Bulls and Cows game. The core features include:\n\n- **Game Logic Management:** Handles the setup, progress, and conclusion of the game, ensuring a smooth gaming experience.\n- **Game State Management:** Manages game state, player state, and game configuration, maintaining the integrity of the game.\n\n---\n\n## Project Structure\n\n```sh\n└── bncpy/\n    ├── .github\n    │   └── workflows\n    ├── LICENSE\n    ├── README.md\n    ├── bnc\n    │   ├── __init__.py\n    │   ├── board.py\n    │   ├── game.py\n    │   ├── player.py\n    │   ├── state.py\n    │   └── utils.py\n    ├── example.py\n    ├── pyproject.toml\n    ├── requirements.txt\n    ├── tests\n    │   ├── __init__.py\n    │   ├── test_board.py\n    │   ├── test_game.py\n    │   ├── test_integration.py\n    │   ├── test_player.py\n    │   ├── test_state.py\n    │   └── test_utils.py\n    └── uv.lock\n```\n\n### Project Index\n\n\u003cdetails open\u003e\n\t\u003csummary\u003e\u003cb\u003e\u003ccode\u003eBNCPY/\u003c/code\u003e\u003c/b\u003e\u003c/summary\u003e\n\t\u003c!-- __root__ Submodule --\u003e\n\t\u003cdetails\u003e\n\t\t\u003csummary\u003e\u003cb\u003e__root__\u003c/b\u003e\u003c/summary\u003e\n\t\t\u003cblockquote\u003e\n\t\t\t\u003cdiv class='directory-path' style='padding: 8px 0; color: #666;'\u003e\n\t\t\t\t\u003ccode\u003e\u003cb\u003e⦿ __root__\u003c/b\u003e\u003c/code\u003e\n\t\t\t\u003ctable style='width: 100%; border-collapse: collapse;'\u003e\n\t\t\t\u003cthead\u003e\n\t\t\t\t\u003ctr style='background-color: #f8f9fa;'\u003e\n\t\t\t\t\t\u003cth style='width: 30%; text-align: left; padding: 8px;'\u003eFile Name\u003c/th\u003e\n\t\t\t\t\t\u003cth style='text-align: left; padding: 8px;'\u003eSummary\u003c/th\u003e\n\t\t\t\t\u003c/tr\u003e\n\t\t\t\u003c/thead\u003e\n\t\t\t\t\u003ctr style='border-bottom: 1px solid #eee;'\u003e\n\t\t\t\t\t\u003ctd style='padding: 8px;'\u003e\u003cb\u003e\u003ca href='https://github.com/jwc20/bncpy/blob/master/LICENSE'\u003eLICENSE\u003c/a\u003e\u003c/b\u003e\u003c/td\u003e\n\t\t\t\t\t\u003ctd style='padding: 8px;'\u003e- The LICENSE file provides the legal framework for the project, granting users the freedom to use, modify, and distribute the software under the terms of the MIT License\u003cbr\u003e- It disclaims warranties and limits liability, ensuring Jae W\u003cbr\u003e- Chois rights are protected while encouraging open collaboration and sharing.\u003c/td\u003e\n\t\t\t\t\u003c/tr\u003e\n\t\t\t\t\u003ctr style='border-bottom: 1px solid #eee;'\u003e\n\t\t\t\t\t\u003ctd style='padding: 8px;'\u003e\u003cb\u003e\u003ca href='https://github.com/jwc20/bncpy/blob/master/requirements.txt'\u003erequirements.txt\u003c/a\u003e\u003c/b\u003e\u003c/td\u003e\n\t\t\t\t\t\u003ctd style='padding: 8px;'\u003e- Requirements.txt serves as a manifest for the projects Python dependencies, generated automatically by uv from pyproject.toml\u003cbr\u003e- It lists libraries like anyio, certifi, httpx, and others, indicating their versions and interdependencies\u003cbr\u003e- This file is crucial for ensuring consistent environment setup across different development and deployment scenarios.\u003c/td\u003e\n\t\t\t\t\u003c/tr\u003e\n\t\t\t\t\u003ctr style='border-bottom: 1px solid #eee;'\u003e\n\t\t\t\t\t\u003ctd style='padding: 8px;'\u003e\u003cb\u003e\u003ca href='https://github.com/jwc20/bncpy/blob/master/pyproject.toml'\u003epyproject.toml\u003c/a\u003e\u003c/b\u003e\u003c/td\u003e\n\t\t\t\t\t\u003ctd style='padding: 8px;'\u003e- The pyproject.toml file serves as the configuration blueprint for the bncpy project, a game developed by Jae W\u003cbr\u003e- Choi\u003cbr\u003e- It outlines the build system, project details, dependencies, and formatting rules\u003cbr\u003e- The project requires Python 3.12 or higher and uses tools like setuptools and wheel for building and packaging\u003cbr\u003e- It also specifies coding style guidelines using the ruff tool.\u003c/td\u003e\n\t\t\t\t\u003c/tr\u003e\n\t\t\t\t\u003ctr style='border-bottom: 1px solid #eee;'\u003e\n\t\t\t\t\t\u003ctd style='padding: 8px;'\u003e\u003cb\u003e\u003ca href='https://github.com/jwc20/bncpy/blob/master/example.py'\u003eexample.py\u003c/a\u003e\u003c/b\u003e\u003c/td\u003e\n\t\t\t\t\t\u003ctd style='padding: 8px;'\u003e- Example.py demonstrates the functionality of a collaborative and competitive game mode in a code-breaking game\u003cbr\u003e- It showcases the process of setting up the game, adding players, submitting guesses, and tracking game status\u003cbr\u003e- The script also tests JSON serialization and deserialization of the game state.\u003c/td\u003e\n\t\t\t\t\u003c/tr\u003e\n\t\t\t\u003c/table\u003e\n\t\t\u003c/blockquote\u003e\n\t\u003c/details\u003e\n\t\u003c!-- bnc Submodule --\u003e\n\t\u003cdetails\u003e\n\t\t\u003csummary\u003e\u003cb\u003ebnc\u003c/b\u003e\u003c/summary\u003e\n\t\t\u003cblockquote\u003e\n\t\t\t\u003cdiv class='directory-path' style='padding: 8px 0; color: #666;'\u003e\n\t\t\t\t\u003ccode\u003e\u003cb\u003e⦿ bnc\u003c/b\u003e\u003c/code\u003e\n\t\t\t\u003ctable style='width: 100%; border-collapse: collapse;'\u003e\n\t\t\t\u003cthead\u003e\n\t\t\t\t\u003ctr style='background-color: #f8f9fa;'\u003e\n\t\t\t\t\t\u003cth style='width: 30%; text-align: left; padding: 8px;'\u003eFile Name\u003c/th\u003e\n\t\t\t\t\t\u003cth style='text-align: left; padding: 8px;'\u003eSummary\u003c/th\u003e\n\t\t\t\t\u003c/tr\u003e\n\t\t\t\u003c/thead\u003e\n\t\t\t\t\u003ctr style='border-bottom: 1px solid #eee;'\u003e\n\t\t\t\t\t\u003ctd style='padding: 8px;'\u003e\u003cb\u003e\u003ca href='https://github.com/jwc20/bncpy/blob/master/bnc/board.py'\u003eboard.py\u003c/a\u003e\u003c/b\u003e\u003c/td\u003e\n\t\t\t\t\t\u003ctd style='padding: 8px;'\u003e- Board.py manages the game board for a Bulls and Cows game, handling the initialization and validation of game parameters such as code length, number of colors, and number of guesses\u003cbr\u003e- It also manages the game state, including tracking guesses, evaluating the correctness of guesses, and determining game outcomes.\u003c/td\u003e\n\t\t\t\t\u003c/tr\u003e\n\t\t\t\t\u003ctr style='border-bottom: 1px solid #eee;'\u003e\n\t\t\t\t\t\u003ctd style='padding: 8px;'\u003e\u003cb\u003e\u003ca href='https://github.com/jwc20/bncpy/blob/master/bnc/game.py'\u003egame.py\u003c/a\u003e\u003c/b\u003e\u003c/td\u003e\n\t\t\t\t\t\u003ctd style='padding: 8px;'\u003e- Game.py manages the game logic for a board game involving multiple players\u003cbr\u003e- It handles the setup, progress, and conclusion of the game, including player actions such as submitting guesses and setting secret codes\u003cbr\u003e- The module ensures consistency across player boards and determines the games winner(s).\u003c/td\u003e\n\t\t\t\t\u003c/tr\u003e\n\t\t\t\t\u003ctr style='border-bottom: 1px solid #eee;'\u003e\n\t\t\t\t\t\u003ctd style='padding: 8px;'\u003e\u003cb\u003e\u003ca href='https://github.com/jwc20/bncpy/blob/master/bnc/utils.py'\u003eutils.py\u003c/a\u003e\u003c/b\u003e\u003c/td\u003e\n\t\t\t\t\t\u003ctd style='padding: 8px;'\u003e- Bnc/utils.py` serves as a utility module in the codebase, providing essential functions for validating user input, generating random guesses, calculating game scores, and fetching random numbers\u003cbr\u003e- It ensures the integrity of the game logic and enhances the overall functionality of the application.\u003c/td\u003e\n\t\t\t\t\u003c/tr\u003e\n\t\t\t\t\u003ctr style='border-bottom: 1px solid #eee;'\u003e\n\t\t\t\t\t\u003ctd style='padding: 8px;'\u003e\u003cb\u003e\u003ca href='https://github.com/jwc20/bncpy/blob/master/bnc/player.py'\u003eplayer.py\u003c/a\u003e\u003c/b\u003e\u003c/td\u003e\n\t\t\t\t\t\u003ctd style='padding: 8px;'\u003e- Player, located at bnc/player.py, represents a participant in the game, maintaining their name and game board\u003cbr\u003e- It provides methods to set a secret code, make a guess, and check the game status\u003cbr\u003e- It interacts with the Board class to evaluate guesses and determine game outcomes.\u003c/td\u003e\n\t\t\t\t\u003c/tr\u003e\n\t\t\t\t\u003ctr style='border-bottom: 1px solid #eee;'\u003e\n\t\t\t\t\t\u003ctd style='padding: 8px;'\u003e\u003cb\u003e\u003ca href='https://github.com/jwc20/bncpy/blob/master/bnc/state.py'\u003estate.py\u003c/a\u003e\u003c/b\u003e\u003c/td\u003e\n\t\t\t\t\t\u003ctd style='padding: 8px;'\u003e- The \u003ccode\u003estate.py\u003c/code\u003e module in the Bulls and Cows game codebase manages the game state, player state, and game configuration\u003cbr\u003e- It handles player actions such as submitting guesses, adding or removing players, and resetting the game\u003cbr\u003e- It also validates game configurations and maintains the games state, including tracking winners and remaining guesses.\u003c/td\u003e\n\t\t\t\t\u003c/tr\u003e\n\t\t\t\u003c/table\u003e\n\t\t\u003c/blockquote\u003e\n\t\u003c/details\u003e\n\t\u003c!-- .github Submodule --\u003e\n\t\u003cdetails\u003e\n\t\t\u003csummary\u003e\u003cb\u003e.github\u003c/b\u003e\u003c/summary\u003e\n\t\t\u003cblockquote\u003e\n\t\t\t\u003cdiv class='directory-path' style='padding: 8px 0; color: #666;'\u003e\n\t\t\t\t\u003ccode\u003e\u003cb\u003e⦿ .github\u003c/b\u003e\u003c/code\u003e\n\t\t\t\u003c!-- workflows Submodule --\u003e\n\t\t\t\u003cdetails\u003e\n\t\t\t\t\u003csummary\u003e\u003cb\u003eworkflows\u003c/b\u003e\u003c/summary\u003e\n\t\t\t\t\u003cblockquote\u003e\n\t\t\t\t\t\u003cdiv class='directory-path' style='padding: 8px 0; color: #666;'\u003e\n\t\t\t\t\t\t\u003ccode\u003e\u003cb\u003e⦿ .github.workflows\u003c/b\u003e\u003c/code\u003e\n\t\t\t\t\t\u003ctable style='width: 100%; border-collapse: collapse;'\u003e\n\t\t\t\t\t\u003cthead\u003e\n\t\t\t\t\t\t\u003ctr style='background-color: #f8f9fa;'\u003e\n\t\t\t\t\t\t\t\u003cth style='width: 30%; text-align: left; padding: 8px;'\u003eFile Name\u003c/th\u003e\n\t\t\t\t\t\t\t\u003cth style='text-align: left; padding: 8px;'\u003eSummary\u003c/th\u003e\n\t\t\t\t\t\t\u003c/tr\u003e\n\t\t\t\t\t\u003c/thead\u003e\n\t\t\t\t\t\t\u003ctr style='border-bottom: 1px solid #eee;'\u003e\n\t\t\t\t\t\t\t\u003ctd style='padding: 8px;'\u003e\u003cb\u003e\u003ca href='https://github.com/jwc20/bncpy/blob/master/.github/workflows/publish.yml'\u003epublish.yml\u003c/a\u003e\u003c/b\u003e\u003c/td\u003e\n\t\t\t\t\t\t\t\u003ctd style='padding: 8px;'\u003e- Publishing Python Package to PyPI automates the process of packaging and uploading Python projects to the Python Package Index\u003cbr\u003e- It triggers on a new release, sets up Python, installs dependencies, builds the package, stores the distribution, and uploads it to PyPI using GitHub Actions.\u003c/td\u003e\n\t\t\t\t\t\t\u003c/tr\u003e\n\t\t\t\t\t\u003c/table\u003e\n\t\t\t\t\u003c/blockquote\u003e\n\t\t\t\u003c/details\u003e\n\t\t\u003c/blockquote\u003e\n\t\u003c/details\u003e\n\u003c/details\u003e\n\n---\n\n## Getting Started\n\n### Prerequisites\n\nThis project requires the following dependencies:\n\n- **Programming Language:** Python\n- **Package Manager:** Pip, Uv\n\n### Installation\n\nBuild bncpy from the source and intsall dependencies:\n\n1. **Clone the repository:**\n\n```sh\ngit clone https://github.com/jwc20/bncpy\n```\n\n2. **Navigate to the project directory:**\n\n```sh\ncd bncpy\n```\n\n3. **Install the dependencies:**\n\n\u003c!-- SHIELDS BADGE CURRENTLY DISABLED --\u003e\n\n```sh\npip install -r requirements.txt\n```\n\n\u003c!-- SHIELDS BADGE CURRENTLY DISABLED --\u003e\n\n```sh\nuv sync --all-extras --dev\n```\n\nAlternatively, you can pip install:\n\n```bash\n# Install package from PyPi\npip install bncpy\n```\n\n### Usage\n\n```python\nfrom bnc import Board, Game, Player\nfrom bnc.utils import generate_guess, get_random_number\n\n# Game configuration\nconfig = {\n  \"code_length\": 4,\n  \"num_of_colors\": 6,\n  \"num_of_guesses\": 10\n}\n\n# Create players with boards\nplayers = [\n  Player(name=\"Jae\", board=Board(**config)),\n  Player(name=\"Soo\", board=Board(**config)),\n  Player(name=\"Benjamin\", board=Board(**config)),\n  Player(name=\"Charlotte\", board=Board(**config))\n]\n\n# Create game with secret code\nsecret_code = get_random_number(length=4, max_value=5)  # Random 4-digit code\ngame = Game(players, secret_code=secret_code)\n\n# Submit guesses\ngame.submit_guess(players[0], \"1234\")\ngame.submit_guess(players[1], generate_guess(config[\"code_length\"], config[\"num_of_colors\"]))  # Random guess\n\n# Check game state\nprint(game.state)\nplayers[0].board.display_board()\n\n# Check winners\nif game.winners:\n  for winner in game.winners:\n    print(f\"Winner: {winner.name}\")\n```\n\n### Setting the secret code\n\n- **Multiple ways to set secret codes:**\n  - Via Game initialization: `Game(players, secret_code=\"1234\")`\n  - Per player: `player.set_secret_code_to_board(\"1234\")`\n  - Random generation: `game.set_random_secret_code()`\n\n### Testing\n\nBncpy uses the **pytest** test framework. Run the test suite with:\n\n**Using [pip](https://pypi.org/project/pip/):**\n\n```sh\npytest\n```\n\n**Using [uv](https://docs.astral.sh/uv/):**\n\n```sh\nuv run pytest tests/\n```\n\n### Dependencies\n\n- [httpx](https://github.com/encode/httpx)\n- [jsonpickle](https://github.com/jsonpickle/jsonpickle)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwc20%2Fbncpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjwc20%2Fbncpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwc20%2Fbncpy/lists"}