{"id":18266224,"url":"https://github.com/arindal1/blackjack-qlearning-rl","last_synced_at":"2025-04-12T00:32:34.071Z","repository":{"id":200338602,"uuid":"705301872","full_name":"arindal1/blackjack-qlearning-rl","owner":"arindal1","description":"Python script for implementing Q-learning to train an agent to play the game of Blackjack.","archived":false,"fork":false,"pushed_at":"2023-10-16T03:24:56.000Z","size":34,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T20:13:41.634Z","etag":null,"topics":["blackjack","game","machine-learning","qlearning"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arindal1.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}},"created_at":"2023-10-15T16:29:42.000Z","updated_at":"2025-01-06T10:46:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"572a6842-152d-4774-bc7b-b5e6b4f11e89","html_url":"https://github.com/arindal1/blackjack-qlearning-rl","commit_stats":null,"previous_names":["arindal1/blackjack-qlearning-rl"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arindal1%2Fblackjack-qlearning-rl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arindal1%2Fblackjack-qlearning-rl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arindal1%2Fblackjack-qlearning-rl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arindal1%2Fblackjack-qlearning-rl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arindal1","download_url":"https://codeload.github.com/arindal1/blackjack-qlearning-rl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248501425,"owners_count":21114674,"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","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":["blackjack","game","machine-learning","qlearning"],"created_at":"2024-11-05T11:22:33.723Z","updated_at":"2025-04-12T00:32:34.049Z","avatar_url":"https://github.com/arindal1.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AI Blackjack w/ Q-learning\n\n![blackjack](https://images.ctfassets.net/93v9a59si7ol/2aHiswcjTt7sXcWtJ7JzAZ/c8759819f9bc7aabac9c6b86bc95ce66/top-view-of-blackjack-table.png?w=1160\u0026h=640\u0026fit=thumb)\n\nThis project implements a Q-learning-based reinforcement learning solution to play the popular casino card game, Blackjack. The implementation consists of two main components: `BlackjackQLearning`, representing the Q-learning agent, and `BlackjackGame`, modeling the game of Blackjack.\n\n## Introduction\n\nThe Q-learning agent (`BlackjackQLearning`) employs Q-tables to learn an optimal strategy for playing Blackjack. It uses an ε-greedy strategy for action selection during training and updates the Q-table based on rewards obtained during gameplay. The Blackjack game (`BlackjackGame`) simulates the actions of the player and dealer, allowing the Q-learning agent to learn and improve its strategy through interactions.\n\n## Project Structure\n\nThe project structure is as follows:\n- `qlearning.py`: Contains the Q-learning agent implementation.\n- `blackjack.py`: Contains the Blackjack game implementation.\n- `main.py`: Entry point for training the Q-learning agent and evaluating its performance.\n- `ABOUT_THE_CODE.md`: Markdown that explains the code.\n\n## How to Run\n\nTo run the project and train the Q-learning agent, follow these steps:\n\n1. Ensure you have Python installed on your machine.\n\n2. Clone this repository:\n   ```bash\n   git clone https://github.com/yourusername/blackjack-q-learning.git\n   cd blackjack-q-learning\n   ```\n\n3. Run the training script:\n   ```bash\n   python main.py\n   ```\n\n4. The agent will be trained for a specified number of episodes, and test games will be played to evaluate its performance.\n\n***Note:*** You can refer to [ABOUT_THE_CODE](ABOUT_THE_CODE.md) for a line-by-line breakdown.\n\n## Configuration and Parameters\n\nYou can modify the training parameters and other configurations by editing the constants and variables in `main.py` and the relevant parts of `qlearning.py`.\n\n- `alpha`: Learning rate for the Q-learning algorithm.\n- `gamma`: Discount factor for future rewards.\n- `epsilon`: Exploration probability for the ε-greedy strategy.\n- `episodes`: Number of training episodes for the Q-learning agent.\n- `test_games`: Number of test games to evaluate the agent's performance.\n\n## Results\n\nAfter training and testing, the project will display the win rate of the Q-learning agent in playing Blackjack.\n\n## Contributing\n\nFeel free to contribute to this project by opening issues or creating pull requests. Contributions are welcome and encouraged!\n\n## Contact\n\nIf you have any questions or suggestions related to this project, you can reach out to me at:\n\n- GitHub: [arindal1](https://github.com/arindal1)\n- LinkedIn: [arindalchar](https://www.linkedin.com/arindalchar/)\n- Twitter: [arindal_17](https://twitter.com/arindal_17)\n\n---\n\n## Keep creating 🚀\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farindal1%2Fblackjack-qlearning-rl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farindal1%2Fblackjack-qlearning-rl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farindal1%2Fblackjack-qlearning-rl/lists"}