Older Contests
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP ContestsOlder Contests

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today!
  #1  
Old February 19th, 2004, 01:32 PM
Basseq Basseq is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Richmond
Posts: 5 Basseq User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to Basseq
[Blackjack] Weird Money (Bug?)

Alright, so I'm calculating whether the last hand was won, lost, or pushed based on if my $result["money"] went up, down, or stayed the same from the last hand. Simple stuff.

I calculate whether it's a win or loss before I call MakeBet(), but it's OK because the hand is over and the money is correct. However, every once in a while (I can't distinguish a pattern) the money will change right after MakeBet().

Yes, I'm taking into account that I'm losing money betting. Here's some simple code:

php Code:
Original - php Code
  1. $lasthandmoney = $result["money"];
  2. $result = MakeBet($bet);
  3. $thishandmoney = $result["money"] + $bet;


So $thishandmoney and $lasthandmoney should be the same, right? And it usually is, except for every once in a while... For example, I had $1000, bet $1, and won. $lasthandmoney equals $1001, but $thishandmoney, after betting another $1, then equaled $1003!

At first I thought it was my script, but I added a couple lines in miniplay.php, and I'm getting the same thing. Any ideas?

Reply With Quote
  #2  
Old February 19th, 2004, 02:58 PM
tchala tchala is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Manchester, UK
Posts: 59 tchala User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
[Blackjack] RE: Weird Money (Bug?)

If you're trying to find out if you won or lost why not just look at the cards?

Funny Money...

Just looked thru it all - think I worked out what's happening

You got a BlackJack but it didn't add the winnings in until you called MakeBet


Reply With Quote
  #3  
Old February 19th, 2004, 03:18 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
[Blackjack] RE: Weird Money (Bug?)

Well, I COULD look at the cards... money's a little simpler. Whatever.

And I thought about the Blackjack thing, but I have the script printing whenever it hits or holds. I've seen it hit once, then hold at 20, and the bug occurs. Unless 20 is blackjack. ;)

Reply With Quote
  #4  
Old February 19th, 2004, 03:22 PM
Basseq Basseq is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Richmond
Posts: 5 Basseq User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to Basseq
[Blackjack] RE: Weird Money (Bug?)

Oops... that's me, being anonymous. Here's an example I just ran: bank's at $1002, and I bet $1. I hit twice, and stand at 19, winning the hand. Thus, I should have $1003. But after MakeBet, I have $1005.

Reply With Quote
  #5  
Old February 19th, 2004, 04:16 PM
Basseq Basseq is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Richmond
Posts: 5 Basseq User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to Basseq
[Blackjack] RE: Weird Money (Bug?)

ha! I think you got it, tchala. It finds the $lasthandmoney, then calls MakeBet(), but if you get blackjack, it'll count it as a win and add the money before $thishandmoney is called. That's what it is... thanks.

Reply With Quote
  #6  
Old February 19th, 2004, 04:54 PM
tchala tchala is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Manchester, UK
Posts: 59 tchala User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
[Blackjack] RE: Weird Money (Bug?)

First off looking at the cards is easy. Pinch Matt's BestVal() from blackjacklib.php and call it summat else (or write yer own)

php Code:
Original - php Code
  1.  
  2. $his=MyBestVal($result["dealercards"]);
  3. if($his>21) $his = 0;
  4. for($i=0;$i<count($result["yourcards"]);$i++) {
  5.   $mine=MyBestVal($result["yourcards"][$i]);
  6.   if($mine>21) $mine = 0;
  7.   if($his>$mine) {
  8.     // I lost
  9.   } else if ($his==mine) {
  10.     // A draw
  11.   } else {
  12.     // I won
  13.   }
  14. }


Or summat along those lines

I'm doing a little test or 3 on the funny money thing - ley u know later

The funny money thing is potentially quite bad as you're never sure how much you have and this may affect your betting at some point - looks like it's bet * 1.5 atm but with splits etc could be higher

Reply With Quote
  #7  
Old February 19th, 2004, 06:19 PM
Reggino Reggino is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Wijk aan Zee, The Netherlands
Posts: 16 Reggino User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Reggino
[Blackjack] RE: Weird Money (Bug?)

It's not strange nor a bug. If you would check $result["status"] right after betting, you would see "HANDOVER" and conclude you had a BlackJack.

I agree it looks strange though when you look a it without this check...

Reply With Quote
  #8  
Old February 19th, 2004, 06:34 PM
tchala tchala is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Manchester, UK
Posts: 59 tchala User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
[Blackjack] RE: Weird Money (Bug?)

At the end of the hand the status is always HANDOVER

HANDOVER don't mean you got a blackjack, it means the hand is over

Reply With Quote
  #9  
Old February 19th, 2004, 06:52 PM
Reggino Reggino is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Wijk aan Zee, The Netherlands
Posts: 16 Reggino User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Reggino
[Blackjack] RE: Weird Money (Bug?)

true, but if you make a bet, and immediately after that the status changes to "HANDOVER", you know it must have been a Blackjack.

But to end all misunderstandings, i think it's best to count your money each time status is "HANDOVER", after each turn...

Reply With Quote
  #10  
Old February 19th, 2004, 07:05 PM
tchala tchala is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Manchester, UK
Posts: 59 tchala User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
[Blackjack] RE: Weird Money (Bug?)

Counting it myself ain't a lot of good. Try going to your bank manager and saying 'I know I got $10 more in my account' - you won't get very far

The take the worst concievable problem - sod all chance of it happening - two winners are within $X * 1.5 at the end and the looser's last hand had a blackjack...

Matt's our Bank manager - if at the end of the game he reckons we got $999 then we got $999 (no matter what we reckon)

Reply With Quote
  #11  
Old February 19th, 2004, 07:23 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
[Blackjack] RE: Weird Money (Bug?)

Err... i lost it. Anyway, i'm interested in your testresults :-)...

By the way, where's Matt? I haven't seen him in a few days around here and I'ld like to see some form of acknowledgement for my subscription

Reply With Quote
  #12  
Old February 19th, 2004, 07:23 PM
Reggino Reggino is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Wijk aan Zee, The Netherlands
Posts: 16 Reggino User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Reggino
[Blackjack] RE: Weird Money (Bug?)

That last post was mine.

Reply With Quote
  #13  
Old February 19th, 2004, 07:50 PM
tchala tchala is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Manchester, UK
Posts: 59 tchala User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
[Blackjack] RE: Weird Money (Bug?)

Well, just got around to weaving myself a little software butterfly net

Gonna go catch me a BlackJack and see what's happening...

Got one - 2nd hand too! - let's go see what the little bugger's doing (thank god for PHP debuggers)

Reply With Quote
  #14  
Old February 19th, 2004, 08:21 PM
tchala tchala is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Manchester, UK
Posts: 59 tchala User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
[Blackjack] RE: Weird Money (Bug?)

I can see exactly what's happening (dunno why yet)

The BlackJack I just trapped was actually a pair of aces so it split

At the start of the hand I've got 990, I ante up 10 and get my cards (2 aces) so I got 980 left in the pot.

It goes thru my play routine and comes out the other end with 970, the cost of the split having been deducted.

I've got A+8 and a BJ, can't see dealer quite yet

At this point state _should_ be HANDOVER but it's actually YOURTURN

I step into MakeBet() and can see everything - dealer's bust with 6,4,2,K

Dealer pays me 20 + 25 (stake back plus winnings - 1 win, 1 BJ) so I now got 1005 as he took off my 10 stake for this hand while in MakeBet()

This time it's a normal hand - I go into my playcode with a 6+2 - he's got a 3

Coming out the other side he's been dead lucky (3, 8, K), I lost that hand but the status is correctly set to HANDOVER

Everything works as expected from then on

It's definitely the BlackJack

Reply With Quote
  #15  
Old February 20th, 2004, 01:04 AM
Basseq Basseq is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Richmond
Posts: 5 Basseq User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to Basseq
[Blackjack] RE: Weird Money (Bug?)

Yep... it is. My script wasn't registering blackjacks fast enough, so I wasn't seeing the pattern. It it kind of odd seeing your bank account jump or drop by 3x your bet. I rewrote the win/loss script, too, just to avoid this problem.

Reply With Quote