Skip to main content

No project description provided

Project description

Blackjack Reinforcement Learning

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.


1. env.py: The Custom Blackjack Environment

The CustomBlackjackEnv 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 optionally Double Down or Split depending 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 environment
  • NeuroJack.dqn_agent → Standard DQN agent implementation
  • NeuroJack.double_dqn_agent → Double DQN agent implementation

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 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

neurojack-0.1.0.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

neurojack-0.1.0-py3-none-any.whl (28.7 kB view details)

Uploaded Python 3

File details

Details for the file neurojack-0.1.0.tar.gz.

File metadata

  • Download URL: neurojack-0.1.0.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.10.18 Windows/10

File hashes

Hashes for neurojack-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8d2493a5f1fcf98ff2b0780f7861bb17c636e4d672b6054d5ef0be96671abc1a
MD5 c2340db3859464910319836716763d9e
BLAKE2b-256 f8aa3d19fa1fbde0d4b1f0bddb8f65263cda4d373813f3e70f240a0a44cd61e9

See more details on using hashes here.

File details

Details for the file neurojack-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: neurojack-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 28.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.10.18 Windows/10

File hashes

Hashes for neurojack-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 94dd333ee883b915a98b675bf89142503dfa0aeb664219eff439437215590e0f
MD5 5ad8aae85d3fdee50676108ce81dd6d9
BLAKE2b-256 f3b573a4d7f41bce46283d9615524c5a7b9488111066479ee594791b2ec9b570

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page