vb code tag to display your code with the proper formatting.
It looks like the score function assumes that the global field array will be populated, and to calculate each teams score, you call it twice. The rack array can use any two characters that you want and the character to count are passed to the score function.
Is that correct?
I just have a quick question about this code. Was it intentional to define the rack array as being 9x4? In the game, the rack is 8x3. If I followed the code correctly, it appears that none of the extra spots are used, meaning that there are 12 useless cells in the array.
Otherwise, this looks good. I’m trying to get my own scoring algorithm done and also having a hard time with the singletons.
As far as execution speed, I’m not sure that this would make much of a difference, but would it be equivalent to replace lines 16 through 22 with:
while(c<8 && rack[c]**==piece) c++;
Also, how fast is the pow function compared to say, an array that you make that just contains the correct number of points for a given length? This would also allow you not to use math.h.
and then replace:
-Corrected a couple of brackets.
-I’ve also written my own version of a score keeping program, though I’m sure it runs many times slower than yours because it does fun things like passing lots of structures by value. Depending on what your using it for though, performance might not really be an issue and you might want to take a look. See: http://www.chiefdelphi.com/forums/showthread.php?t=51408**