dogedice.me (OP)
|
|
March 25, 2015, 10:45:11 AM |
|
It happened again. Even though it says right on the table that the dealer hits soft 17: ... I bet 1 CLAM, was dealt 11 vs. dealer's 3, so I doubled, the dealer got soft 17, stood, and won! ... Such sadness. I tried verifying this hand to see whether I would have won or not if the game wasn't buggy, but I couldn't get it to verify. First I tried using the Ruby code from the FAQ: but it won't even run. It complains: bitdice.rb:7:in `<main>': uninitialized constant Digest (NameError)
so it looks like the code isn't really complete. I don't know much Ruby at all, but I was able to get past that by adding: require 'digest/sha1'
Then it complained: bitdice.rb:13:in `<main>': undefined local variable or method `initial_deck' for main:Object (NameError)
so I added a definition for the initial deck. I finished up with this: SECRET='7fc84a2d8dbf0d50b79bd771677354dd85b1b64129f6f54f7fb4def6973aba2598044eaa826a6020d41be7ec255e88b43c1b0afc2522c657aa6922b7852414d6' USER_SEED='everymagicseed' USER_ID='8798' USER_BET_NUMBER='73'
require 'digest/sha1'
# generates bet hash string bet_hash = Digest::SHA512.hexdigest (SECRET + ':' + USER_SEED + ':' + USER_ID + ':' + USER_BET_NUMBER) # bet_hash = '49dde939d58d494f4dbb3a510b86abe4f62d2c17a6a83bb3f5f9991a47cdac77b38008f8caf6938c6e491e6fd54ab020b1b961c787fd296cad4b2cae4ce540f6' # pass hash to Mersenne Twister print 'bet_hash: ', bet_hash, "\n" @random = Random.new(bet_hash.to_i(16))
deck = ['AS', '2S', '3S', '4S', '5S', '6S', '7S', '8S', '9S', '10S', 'JS', 'QS', 'KS', 'AH', '2H', '3H', '4H', '5H', '6H', '7H', '8H', '9H', '10H', 'JH', 'QH', 'KH', 'AD', '2D', '3D', '4D', '5D', '6D', '7D', '8D', '9D', '10D', 'JD', 'QD', 'KD', 'AC', '2C', '3C', '4C', '5C', '6C', '7C', '8C', '9C', '10C', 'JC', 'QC', 'KC'] * 8
# shuffle deck deck.shuffle!(random: @random)
# now deck contains shuffled deck print deck, "\n"
and it outputs this: bet_hash: 49dde939d58d494f4dbb3a510b86abe4f62d2c17a6a83bb3f5f9991a47cdac77b38008f8caf6938c6e491e6fd54ab020b1b961c787fd296cad4b2cae4ce540f6 ["7C", "4D", "2S", "10S", "9C", "8H", "AC", "5H", "3H", "6S", "9S", "8D", "5C", "7C", "3H", "9H", "QH", "2S", "8S", "9H", "KH", "4S", "9S", "8C", "KS", "5S", "7C", "4S", "QS", "QC", "10H", "JH", "JH", "KS", "7D", "7D", "6C", "QH", "4S", "4D", "7H", "KS", "AS", "3C", "2S", "AS", "QH", "8H", "7S", "3C", "5D", "2D", "5D", "JD", "QS", "JD", "QS", "9D", "9D", "2D", "JH", "2C", "9C", "2D", "7H", "6C", "8C", "7C", "8S", "JD", "7S", "9H", "3S", "8S", "7S", "4H", "7D", "8D", "6S", "KH", "AC", "QD", "KH", "QC", "3D", "3S", "8H", "3D", "3H", "4C", "QS", "QS", "6D", "9H", "8S", "JD", "AC", "3D", "JH", "4S", "5D", "2D", "AH", "7S", "3D", "6S", "5S", "5C", "QD", "8C", "5C", "KC", "6C", "4H", "AD", "KS", "5C", "7C", "5D", "7H", "AD", "JD", "2D", "4S", "6H", "3H", "2C", "6S", "QD", "6D", "QS", "AD", "5S", "3H", "AD", "6H", "9H", "8S", "3C", "2H", "2H", "6C", "5D", "7S", "2H", "QC", "4D", "9S", "6H", "7H", "JS", "6S", "8H", "KD", "6C", "6D", "7D", "10C", "10S", "QD", "9D", "2D", "QD", "2C", "4D", "10H", "9D", "3C", "AC", "KC", "KC", "8C", "JS", "QS", "6D", "9H", "JC", "3C", "KD", "7S", "JS", "10C", "8S", "5H", "6C", "6H", "5H", "2H", "2S", "4C", "9D", "2H", "3D", "JC", "JH", "AS", "AS", "9D", "5H", "KS", "KH", "3H", "AD", "8H", "8H", "3C", "10C", "5S", "10C", "3S", "6H", "5D", "AD", "5H", "9C", "4H", "KH", "4H", "10D", "2D", "JH", "3S", "10H", "7H", "10D", "AC", "JH", "6D", "QC", "6H", "10S", "4S", "4C", "AH", "10C", "4D", "10S", "JC", "10D", "5C", "8C", "KD", "AH", "KD", "4H", "10D", "KC", "AH", "KD", "8D", "7H", "8H", "10H", "AH", "6H", "QH", "4D", "9S", "5H", "10D", "9C", "8S", "2S", "3D", "10H", "JC", "8D", "QC", "7D", "JS", "JD", "7D", "JS", "7C", "4C", "6H", "9H", "4C", "8H", "KS", "8D", "QC", "2S", "4S", "10H", "8D", "QC", "4H", "JS", "8C", "10C", "5S", "AC", "6D", "9C", "10H", "3C", "9D", "5C", "2C", "6S", "5H", "JC", "AH", "9S", "KC", "AS", "9S", "5H", "5S", "AD", "10D", "6D", "AS", "KD", "5S", "6S", "3D", "4C", "AH", "8C", "5S", "AS", "10D", "9D", "10H", "JH", "4H", "7H", "7H", "JD", "5C", "JS", "6C", "AS", "QS", "10D", "9C", "KC", "5D", "9H", "2H", "4C", "QD", "AC", "2C", "9S", "7D", "2C", "2C", "9C", "2H", "2C", "5D", "QH", "JS", "3H", "3H", "9C", "KD", "10S", "AH", "4S", "KH", "QH", "QH", "10S", "QD", "10S", "KH", "KD", "6C", "KS", "JC", "4C", "4D", "4D", "2S", "2S", "4H", "QH", "3C", "7S", "3S", "3S", "KC", "JD", "6D", "KS", "JC", "QC", "8C", "2D", "7C", "3S", "5C", "KH", "QD", "7S", "AC", "7C", "8S", "10S", "AD", "8D", "7D", "2H", "8D", "3S", "10C", "6S", "KC", "JC", "9S", "10C", "3D"]
Note that the 'bet hash' is the same as I see when I click the bet ID: so at least the sha512 part of the code is getting the right hash. But I don't see how the final shuffle corresponds to the cards I was dealt. My first card was 9C, but there's no 9C near either end of the shuffled deck output. What am I doing wrong now? Maybe the Ruby code in the FAQ could be improved so that it will actually run and give the same shuffle as the game is using. I will check the soft 17 bug, with validation here's the correct code: require 'digest'
SECRET='7fc84a2d8dbf0d50b79bd771677354dd85b1b64129f6f54f7fb4def6973aba2598044eaa826a6020d41be7ec255e88b43c1b0afc2522c657aa6922b7852414d6' USER_SEED='everymagicseed' USER_ID='8798' USER_BET_NUMBER='73'
deck = %w[AS 2S 3S 4S 5S 6S 7S 8S 9S 10S JS QS KS AH 2H 3H 4H 5H 6H 7H 8H 9H 10H JH QH KH AD 2D 3D 4D 5D 6D 7D 8D 9D 10D JD QD KD AC 2C 3C 4C 5C 6C 7C 8C 9C 10C JC QC KC AS 2S 3S 4S 5S 6S 7S 8S 9S 10S JS QS KS AH 2H 3H 4H 5H 6H 7H 8H 9H 10H JH QH KH AD 2D 3D 4D 5D 6D 7D 8D 9D 10D JD QD KD AC 2C 3C 4C 5C 6C 7C 8C 9C 10C JC QC KC AS 2S 3S 4S 5S 6S 7S 8S 9S 10S JS QS KS AH 2H 3H 4H 5H 6H 7H 8H 9H 10H JH QH KH AD 2D 3D 4D 5D 6D 7D 8D 9D 10D JD QD KD AC 2C 3C 4C 5C 6C 7C 8C 9C 10C JC QC KC AS 2S 3S 4S 5S 6S 7S 8S 9S 10S JS QS KS AH 2H 3H 4H 5H 6H 7H 8H 9H 10H JH QH KH AD 2D 3D 4D 5D 6D 7D 8D 9D 10D JD QD KD AC 2C 3C 4C 5C 6C 7C 8C 9C 10C JC QC KC AS 2S 3S 4S 5S 6S 7S 8S 9S 10S JS QS KS AH 2H 3H 4H 5H 6H 7H 8H 9H 10H JH QH KH AD 2D 3D 4D 5D 6D 7D 8D 9D 10D JD QD KD AC 2C 3C 4C 5C 6C 7C 8C 9C 10C JC QC KC AS 2S 3S 4S 5S 6S 7S 8S 9S 10S JS QS KS AH 2H 3H 4H 5H 6H 7H 8H 9H 10H JH QH KH AD 2D 3D 4D 5D 6D 7D 8D 9D 10D JD QD KD AC 2C 3C 4C 5C 6C 7C 8C 9C 10C JC QC KC AS 2S 3S 4S 5S 6S 7S 8S 9S 10S JS QS KS AH 2H 3H 4H 5H 6H 7H 8H 9H 10H JH QH KH AD 2D 3D 4D 5D 6D 7D 8D 9D 10D JD QD KD AC 2C 3C 4C 5C 6C 7C 8C 9C 10C JC QC KC AS 2S 3S 4S 5S 6S 7S 8S 9S 10S JS QS KS AH 2H 3H 4H 5H 6H 7H 8H 9H 10H JH QH KH AD 2D 3D 4D 5D 6D 7D 8D 9D 10D JD QD KD AC 2C 3C 4C 5C 6C 7C 8C 9C 10C JC QC KC]
bet_hash = Digest::SHA512.hexdigest (SECRET + ':' + USER_SEED + ':' + USER_ID + ':' + USER_BET_NUMBER) random = Random.new(bet_hash.to_i(16)) deck.shuffle!(random: random)
p deck
|