I found that a hash table will take care of this for you. You don't have to worry about, and hard-code, in each of your algorithms whether or not you'll need to reuse the dealer probabilities.London Colin said:That's surely the point. The shoe state is not the same. In the example we know it is depleted by two non-eights, compared to if we were evaluating a single hand totalling 21.
Eric does the same optimization as you do, reusing the dealer probs whenever possible. But because of the particular splitting algorithm he is using, he is also reusing them where it is not strictly possible.
That being said, it might well be possible to replace the splitting routine with an entiely new one, without having to vastly modify the existing infrastructure, so that the shoe state is indeed always the same whenever the dealer probs are called upon.
It's simple: You have the following remaining cards (10x1 vector for each rank)
1, 4, 2, 6, 5, 2, 3, 8, 2, 8.
That hashes to a value, let's say 13621445.
You have a function which calculates the dealer probabilities. Before it does any calculations, though, it just check the hash table, see if 13621445 has already been calculated, and if it has return a 7x1 array of dealer probabilities.
I use boost's built in hash table which is actually implemented as a tree, and works extremely fast. It has a built in algorithm for hashing vectors or arrays, and for searching the tree. No coding on your part.
This way, you are always calling your CalculateProbabilities function, which decides itself whether or not it has to actually compute anything, or use an already-computed result. Very elegant and simple to code.