No project description provided
Project description
NeuroJack
A Blackjack Reinforcement Learning Project
This project implements a reinforcement learning system to train an agent to play Blackjack. It features a custom environment and two types of Deep Q-Learning (DQN) agents to explore different learning strategies.
Instalation
You can install the neurojack package using pip.
To do this, use the following command in your terminal:
pip install neurojack
Note: This package is hosted on the PyPI (Python Package Index) repository. Ensure your pip configuration is up to date and allows installations from https://pypi.org/simple/
1. env.py: The Custom Blackjack Environment
The BlackjackEnv class defines a flexible and highly configurable Blackjack game environment. It is built from scratch to allow for specific rule sets and advanced features beyond standard library environments.
Key Features
- Customizable Rules: Supports multiple rule variations, including different numbers of decks, variable payouts, and specific dealer rules.
- Card Counting: Optionally tracks a running count and a true count, enabling more advanced state representations.
- State Representation: The observation space includes:
- Player’s hand sum
- Dealer’s visible card
- Usable ace indicator
- Optional card counting values (if enabled)
- Action Space: Supports common actions (
Hit,Stand), and optionallyDouble DownorSplitdepending on the rule set.
2. dqn_agent.py: The Deep Q-Network Agent
The DQNAgent implements a Deep Q-Network to learn the optimal strategy for Blackjack.
How It Works
- Q-Networks: Uses two neural networks — a main Q-network for training and a target Q-network for stable updates.
- Experience Replay: Stores past experiences (state, action, reward, next state) in a replay buffer to improve sample efficiency and reduce correlation between updates.
- Epsilon-Greedy Policy: Balances exploration and exploitation by occasionally taking random actions during training.
3. double_dqn_agent.py: The Double DQN Agent
The DoubleDQNAgent extends the standard DQN approach to address overestimation of Q-values, leading to more accurate and stable learning.
Key Improvements
- Decoupled Action Selection: Uses the main Q-network to select actions while the target Q-network evaluates their values.
- Stabilized Updates: This separation reduces bias and improves the accuracy of Q-value estimates.
Project Structure
-
/neurojack/env/→ Custom Blackjack environmentcard.py→ Defines the Card class, handling suits and values.deck.py→ Implements the Deck class for card management.env.py→ Core Blackjack environment logic.playerhand.py→ Manages a player's hand and hand values.values.py→ Defines constants for card values.
-
/neurojack/agent/→ Agent implementationsdqn_agent.py→ Standard DQN agent.double_dqn_agent.py→ Double DQN agent.
-
/neurojack/memory/replay_buffer.py→ Implements the replay buffer for experience storage. -
/neurojack/model/q_model.py→ Defines the Q-network model.
This modular design allows easy switching between different agents and experimentation with various reinforcement learning strategies while keeping the core Blackjack logic consistent.
License
This project is licensed under the MIT License.
Copyright (c) 2024 Razvan Nica (dafaqboomduck)
You are free to use, modify, and distribute this software in accordance with the terms of the license.
The software is provided “as is”, without warranty of any kind.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file neurojack-0.1.1.tar.gz.
File metadata
- Download URL: neurojack-0.1.1.tar.gz
- Upload date:
- Size: 23.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.4 CPython/3.10.18 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7b27e5391914f38983b25cfc053dca9fcf31fb393ced37e08cd5420f666c8e4
|
|
| MD5 |
9431e26f42621381798e69a3311ef6ac
|
|
| BLAKE2b-256 |
808041c0e2dc05ba85c7245cb83b96b11eb4100b45f9ef8e0a4499a0c7f9302c
|
File details
Details for the file neurojack-0.1.1-py3-none-any.whl.
File metadata
- Download URL: neurojack-0.1.1-py3-none-any.whl
- Upload date:
- Size: 29.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.4 CPython/3.10.18 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f8694293e39d587d0bafd60b50be6028a3e2278f7be0b81a7a67c8330108553
|
|
| MD5 |
dfb02e9904c0196b13e2cb58ccb2285f
|
|
| BLAKE2b-256 |
1878bae451b4aa00a885e0ea333999fbb2e6f87df94c085a8cb29fbd03f9bdb8
|