You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am having an issue running the program. When I try to run, I get the following below.
python blackjack_original.py BasicStrategy.csv
Traceback (most recent call last):
File "blackjack_original.py", line 468, in
game.play_round()
File "blackjack_original.py", line 436, in play_round
self.player.play(self.shoe)
File "blackjack_original.py", line 261, in play
self.play_hand(hand, shoe)
File "blackjack_original.py", line 275, in play_hand
flag = HARD_STRATEGY[hand.value][self.dealer_hand.cards[0].name]
KeyError: 'Ace'
The KeyError is related to the cards dict? How can I resolve? Thank you
The text was updated successfully, but these errors were encountered:
This error occurs when the:
HARD_STRATEGY = {}
SOFT_STRATEGY = {}
PAIR_STRATEGY = {}
are empty - this is a result of loading an invalid CSV file. See the other post related to " INDEX" error for comments on correctly loading the csv file via the importer.
This is the expected behavior, the sys object receives arguments when calling the script from the command line.
sys.argv[1] is the first argument passed - it should be the name/path to the Strategy.csv file.
EX: python blackjack_sim.py strategy.csv (assumes csv file in same directory as py file.)
In the alternativve, if you are running from within editor, you can remove the argv[1] and just hard code the file name/path:
EX: importer = StrategyImporter('BS.csv')
Hi, I am having an issue running the program. When I try to run, I get the following below.
The KeyError is related to the cards dict? How can I resolve? Thank you
The text was updated successfully, but these errors were encountered: