
Originally Posted by
redtop43
This question must have been asked before but - I'm looking for VBA code to deal blackjack.
I want to test play deviations. I can alter the deal/shuffle code myself.
Anyone know where this might exist? I don't want to do the heavy lifting of re-inventing the wheel.
I program in C++ under cygwin OS, so I don't know how easy it is for you to spawn subprocesses under VBA. I just integrate the Eric Farmer C++ code into any new functionality that I require. If I had to write a simulator and I could not integrate Eric's code directly into my project, I would do a simple workaround with a master-slave arrangement.
Can you generate input to an external executable file from VBA? If you can, you can make strategy.exe a slave to your VBA program.
If I make a text file called 'redtop' and use this as input to Eric's strategy.exe program, it will perform almost any BJ calculation I could ever want for a simulator.
This command instructs the program to use the file as input:
Code:
./strategy.exe < redtop
where the contents of the redtop file are:
6
y
y
y
n
y
y
n
n
n
1.5
prob.txt
7 2 2 6
0 0
This is the key for the lines in the input file:
Code:
Enter number of decks, or 0 to enter shoe: 6
Enter 'Y' or 'y' if dealer hits soft 17: y
Enter 'Y' or 'y' if doubling down is allowed on any total: y
Enter 'Y' or 'y' if doubling down is allowed on soft hands: y
Enter 'Y' or 'y' if doubling down is allowed on any number of cards: n
Enter 'Y' or 'y' if doubling down is allowed after splitting pairs: y
Enter 'Y' or 'y' if resplitting pairs is allowed: y
Enter 'Y' or 'y' if resplitting aces is allowed: n
Enter 'Y' or 'y' if CDZ- (vs. CDP) post-split strategy is used: y
Enter 'Y' or 'y' if late surrender is allowed: n
Enter blackjack payoff (normally 1.5): 1.5
This takes less than a second to run and generates a file named prob.txt. If your VBA can read the output file and capture the console output, you will have a lot of detailed information about this particular hand. It should be simple to parse the prob.txt file to get all the primary and secondary strategy choices for any given hand.
If this is too slow for what you have in mind, then you might be able to create a large set of files ahead of time to store the information that you need for your simulation. You have not provided much information about the problem you are trying to solve. If you need to be able to simulate deep into the deck, then you might want to keep the slave program attached to the VBA output and use it to do a stream of calculations for your sim. Note that you can set the exact contents of the shoe rather than just start with 6 decks as I have done.
You should be able to do two-way communication between master and slave processes by using pipes or by spawning a subprocess and redirection the I/O file descriptors.
Bookmarks