Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,5 @@ venv.bak/
*.txt
*.bak
dojo.py
.vscode/

70 changes: 36 additions & 34 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,53 @@
### 06/06/2023 - Sub
- Modified the count_trainer function, allow the user to select their name, how many decks, and how many cards to deal out. Once all the cards are dealt, a count is requested, if the user is incorrect, a log is displayed showing the count throughout the deals
- Some known bugs are introduced with the new confirm_integer function, more information in the TODO.md
- Cleaned up .md files for cleaner documentation

### 01/09/2023 - Sub
- Refactored all of the code in card_functions black_jack _functions, and blackjack_count_trainer.
- Now both functions are using classes for cards, decks, and hands.
- Sub classes overwrite certain functions for particular duties.
- Removed all remaining old code, building from scratch should be easier.

### 05/02/2019 - Sub
Seperated all of the working code into corresponding files (basic card features into card_functions and basic blackjack features into blk_jak_functions).
The game_over function sits in the main file, due to it needing to run a function from card_functions, yet referencing blackjack terms (busting).
Moving the functions required turning them all into pass throughs, and some may pass through more than needed.
Removed some of the testing prints.
In it's current state, you can go through 1, 2, or 6 decks, with busting causing you to restart all over.
- Separated all of the working code into corresponding files (basic card features into card_functions and basic blackjack features into blk_jak_functions).
- The game_over function sits in the main file, due to it needing to run a function from card_functions, yet referencing blackjack terms (busting).
- Moving the functions required turning them all into pass through, and some may pass through more than needed.
- Removed some of the testing prints.
- In it's current state, you can go through 1, 2, or 6 decks, with busting causing you to restart all over.

### 04/26/2019 - Sub
Backed up all of the python2 code into a corresponding folder.
Created Python3 version of a majority of the code, currently all in the file test.py.
Added in automatic conversion of aces from 11 to 1, should the next drawn card cause you to bust.
- Backed up all of the python2 code into a corresponding folder.
- Created Python3 version of a majority of the code, currently all in the file test.py.
- Added in automatic conversion of aces from 11 to 1, should the next drawn card cause you to bust.

### 04/04/2017
Added a check for going over 21 (busting)
Attempted to turn most of the game section into a function, but got tripped up over local vs global variable (I should know this). Will attempt again when I know exactly what I wnat/need to make local.
Increased PlayerHand array to 7 card total.
- Added a check for going over 21 (busting)
- Attempted to turn most of the game section into a function, but got tripped up over local vs global variable (I should know this). Will attempt again when I know exactly what I want/need to make local.
- Increased PlayerHand array to 7 card total.

### 04/03/2017
Changed how a player indicates Hit/Stand, and Deal/NoDeal.
Fully implemented the PlayerHand array/list during the game.

Need to work on ending game when player "busts".
- Changed how a player indicates Hit/Stand, and Deal/NoDeal.
- Fully implemented the PlayerHand array/list during the game.
- Need to work on ending game when player "busts".

### 11/15/2016
Added a way to increment the PLayerHand array. Not much use now, but will help when the player wants to hit more than once. With taht said, the next step is to change the "if total < 21" clause to a loop...without breaking anything...
Should also handle a "Bust" scenario in the near future.
- Added a way to increment the PLayerHand array. Not much use now, but will help when the player wants to hit more than once. With that said, the next step is to change the "if total < 21" clause to a loop...without breaking anything...
- Should also handle a "Bust" scenario in the near future.

### 11/07/2016
Created an initialization function to maybe save a few lines of code? Declared variables in function as globals which seemed to resolve the initialization breakage before.
- Created an initialization function to maybe save a few lines of code? Declared variables in function as globals which seemed to resolve the initialization breakage before.

### 11/06/2016
Started working on the Hit or Stand functionality, but there is a lot of work to be done. The program, so far, can add one more card when a "Hit" is requested.
This brings us to adding parameters when a "Bust" happens.
Changed card variables into an array for better organization and manipulation.
- Started working on the Hit or Stand functionality, but there is a lot of work to be done. The program, so far, can add one more card when a "Hit" is requested.
- This brings us to adding parameters when a "Bust" happens.
- Changed card variables into an array for better organization and manipulation.

### 11/05/2016
Moved the ace checker so the user can know the had before decidibg on 1 or 11.
- Moved the ace checker so the user can know the had before deciding on 1 or 11.

### 11/04/2016
Revisited code and tried to condense. Still working on it.
Fixed most major breaks, but will need to clean that up a bit too with Exception handlers.
Separated setup functions for better organization. Setup is now in bjsetup.py
Added ace card handling and printed a total sum.

###### To Do

### 04/04/2017
1. Attempt to functionalize the main secion of the game since it gets called more than once.
2. Now that the PlayerHand mechanics are figured out, need to start Dealer functionality so the player gets a sense of winning against an opponent.
3. Betting functionality
4. More verbose output for count training (this includes true and running counts).
- Revisited code and tried to condense. Still working on it.
- Fixed most major breaks, but will need to clean that up a bit too with Exception handlers.
- Separated setup functions for better organization. Setup is now in bjsetup.py
- Added ace card handling and printed a total sum.
56 changes: 0 additions & 56 deletions Deck.py

This file was deleted.

16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,22 @@ by MasterChen @chenb0x
and Sub-Lockdown
----------------------

#### DISCLAIMER: It is NOT ILLEGAL to count cards on a table in Las Vegas, HOWEVER, it IS illegal to use an apparatus outside of your own mind (devices, etc) while at a table. Please use discretion and understand that this is a mental exercise.
#### DISCLAIMER: It is NOT ILLEGAL to count cards on a table in Las Vegas, HOWEVER, it IS illegal to use an apparatus outside of your own mind (devices, etc) while at a table. Please use discretion and understand that this is a mental exercise. This is not designed for use at a Vegas table, but rather to prepare your mind before going to a table.


###### This is a BlackJack trainer. It trains the user on how to count cards using the High/Low or Revere(Plus/Minus) method of counting

###### This is not designed for use at a Vegas table, but rather to prepare your mind before going to a table.
2, 3, 4, 5, 6 -> +1
7, 8, 9 -> +0
10, Jack, Queen, King, Ace -> -1

###### Usage
-----

To run the trainer:

python count_trainer.py

Once running, enter a name, how many decks you would like to use* and how many cards to be dealt*. Afterwards it will run through the cards, and then ask for the count, and inform you if correct; if you are incorrect, it will show you a log of all the cards dealt, and the current count to review. To play again, just run it again.

* Currently a known issue with the function used, check the CHANGELOG and TODO to see if resolved (this disclaimer should be removed upon that event)
9 changes: 9 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# TODO List

These are a collection of features that need to be implemented, modified, or otherwise corrected.

Feature | File | Reason
---------|------|-------------
Hand.selectCard() | card_functions.py | needs to be changed to deal with duplicate card values. Right now it will just select the first matching if you only enter the value.
confirm_integer() | card_functions.py | currently takes any integer, needs to be able to confirm if negative or positive (ie how many decks), as well as a cap (ie how many cards there can be in x decks)
blackjack_game.py | blackjack_game.py | needs to be created, most likely will need expanding on the blackjack_functions.py
22 changes: 0 additions & 22 deletions blackjack_count_trainer.py

This file was deleted.

75 changes: 75 additions & 0 deletions blackjack_functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env python3

# We are an import and import company
import sys
import card_functions

# Variable Setup
text_count = "What is the count?"

class BlackJackHAND(card_functions.Hand):
def __init__(self, name):
"""Creates a hand from card functions, with the added variable of total and eleven."""
self.total = 0
self.eleven = 0
self.count = 0
super().__init__(name)

def drawCard(self, deck):
"""Draws a card from a deck and then updates the hand total."""
card = deck.drawCard()
self.hand.append(card)
self.valueCounter(card.value)
self.hiloCounter(card.value)
return self

def bustCheck(self):
"""Checks if hand total is over 21, meaning the hand is bust and out of the round"""
if self.total > 21:
return True
else:
return False

def listState(self):
"""Lists the name and total of the hand."""
print(f"Play Name: {self.name}")
self.showHand()
if self.bustCheck():
print(f"Current card value: {self.total} BUSTED")
else:
print(f"Current card value: {self.total}")

def valueCounter(self, card):
"""Checks the value of the card, and updates the hand's total."""
if card in ['J', 'Q', 'K']:
self.total += 10
elif card == 'A':
if self.total + 11 > 21:
self.total += 1
else:
self.total += 11
self.eleven += 1
else:
self.total += int(card)
if self.total > 21 and self.eleven > 0:
self.total -= 10
self.eleven -= 1
return self

def hiloCounter(self, card):
"""Takes the value of the card, and updates the hand's count."""
try:
thisCard = int(card)
if thisCard <= 6:
self.count += 1
elif thisCard <= 9:
self.count += 0
except:
if card in ['10', 'J', 'Q', 'K', 'A']:
self.count += -1
return self

# Message if run directly
if __name__ == "__main__":
print("This file contains basic blackjack functions")
sys.exit()
82 changes: 0 additions & 82 deletions blk_jak_functions.py

This file was deleted.

Loading