{"id":19580776,"url":"https://github.com/mirzaim/card-game-ai-agent","last_synced_at":"2025-10-08T00:57:31.281Z","repository":{"id":257471123,"uuid":"858346987","full_name":"mirzaim/Card-Game-AI-Agent","owner":"mirzaim","description":"AI agent that solves a card sorting game using search algorithms like BFS, IDS, and A-Star.","archived":false,"fork":false,"pushed_at":"2024-09-16T18:31:46.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-30T04:45:40.094Z","etag":null,"topics":["a-star","bfs","card-game","ids","ids-algorithm"],"latest_commit_sha":null,"homepage":"","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/mirzaim.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-09-16T18:29:12.000Z","updated_at":"2024-09-16T18:34:18.000Z","dependencies_parsed_at":"2024-09-17T00:48:50.376Z","dependency_job_id":"25ff73ba-e407-4b8a-a060-3f10ed9cc8d9","html_url":"https://github.com/mirzaim/Card-Game-AI-Agent","commit_stats":null,"previous_names":["mirzaim/card-game-ai-agent"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mirzaim/Card-Game-AI-Agent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirzaim%2FCard-Game-AI-Agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirzaim%2FCard-Game-AI-Agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirzaim%2FCard-Game-AI-Agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirzaim%2FCard-Game-AI-Agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mirzaim","download_url":"https://codeload.github.com/mirzaim/Card-Game-AI-Agent/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirzaim%2FCard-Game-AI-Agent/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278872149,"owners_count":26060524,"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-10-07T02:00:06.786Z","response_time":59,"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":["a-star","bfs","card-game","ids","ids-algorithm"],"created_at":"2024-11-11T07:29:44.788Z","updated_at":"2025-10-08T00:57:31.265Z","avatar_url":"https://github.com/mirzaim.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Card Game AI Agent\n\nThis repository contains implementations of various search algorithms applied to problem-solving, focusing on a **[Simple Card Game](#simple-card-game)**.\n\n## Project Structure\n\n```\n.\n├── Pipfile\n├── a_star_test.py\n├── bfs_test.py\n├── ids_test.py\n├── problems\n│   └── colored_cards\n│       └── playground.py  # The problem setup and state definitions\n└── search_algorithms\n    └── classic.py         # The core search algorithms\n```\n\n## Simple Card Game\n\n### Problem Description\nYou have `M` colors of cards, each numbered 1 to `N`, arranged in `K` columns. The goal is to sort the cards such that:\n- Each column contains cards of the same color.\n- Cards in each column are sorted in descending order.\n\nYou can only move the top card from one column to another if the destination card has a higher number.\n\n### Search Algorithms\nThree different search algorithms are implemented to solve this problem:\n1. **Breadth-First Search (BFS)**: Explores the state space level by level.\n2. **Iterative Deepening Search (IDS)**: Combines depth-first and breadth-first approaches by progressively deepening the search limit.\n3. **A-Star Search**: Uses a heuristic function to optimize the search by prioritizing states closer to the goal.\n\n### Classes Overview\n\n- **Card**: Represents a card with a number and color.\n- **Playground**: Represents the state of the game, including card arrangement and available actions.\n- **ColoredCards**: Defines the problem by specifying the initial state, available actions, and goal state.\n- **WellDefinedProblem**: An abstract class defining the structure for a problem that can be solved using search algorithms.\n\n### Sample Input\n```\n4 3 5   # 4 numbers, 3 colors, 5 columns\n4y\n2g 4r 3y 3g 2y\n1y 4g 1r\n1g 2r 3r\n#\n```\n\n### Sample Output\n```\nstarted\ndepth: 12\n1 --\u003e 3\n2 --\u003e 3\n2 --\u003e 4\n1 --\u003e 4\n1 --\u003e 0\n3 --\u003e 4\n3 --\u003e 0\n2 --\u003e 0\n1 --\u003e 2\n3 --\u003e 2\n3 --\u003e 2\n4 --\u003e 2\nsolution:\n4y 3y 2y 1y\n2g\n4r 3r 2r 1r\n1g\n4g 3g\n\nexpanded nodes: 1510\nproduced nodes: 12397\n```\n\n### Usage\n\nTo play the game, follow these steps:\n1. Clone the repository.\n2. Install the required dependencies using `pipenv install`.\n3. For each algorithm, choose one of `a_star_test.py`, `ids_test.py`, or `bfs_test.py` to run.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmirzaim%2Fcard-game-ai-agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmirzaim%2Fcard-game-ai-agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmirzaim%2Fcard-game-ai-agent/lists"}