Pages:
Author

Topic: Introducing Cardwars - page 3. (Read 7071 times)

legendary
Activity: 1218
Merit: 1000
May 22, 2011, 07:29:19 PM
#35
Well... just figured it was double paying on ties and was double 1/100.
This second bug actually covered up the double paying and added that 1% "commission".

initial bug is here:

         case 'war':
                   $warbet = $cardwars->bet/100;
                    $realbet = $warbet/100;

The switch that calls the functions.
Second bug is in that class.
bug 1 + bug 2 = 1% commission on war ties
legendary
Activity: 1218
Merit: 1000
May 22, 2011, 07:14:59 PM
#34
Here's the whole class code, I just keep browsing it up and down and still can't find what went wrong:

Code:
  class Cardwars{
  
    var 
$game_id;
    var 
$bet 0;
    var 
$tie 0;
    var 
$warbet 0;
    var 
$pointer 0;
    var 
$output = array();
    var 
$deck = array();
    var 
$betLines = array();
      
    function 
Cardwars($game){
        
$this->game_id $game['id'];
        
$this->deck explode(",",$game['baralho']);
        
$this->bet $game['bet'];
        
$this->tie $game['tie'];
        
$this->pointer $game['ponteiro'];
    }
  
      function 
init_game(){
        
$this->resetVars();  
        
$this->output[] = ".$this->game_id."\" name=\"Cardwars\" response=\"init\">";
        
$this->output[] = "";    
        
$this->output[] = "";
      }  
      
      
      function 
getComponentOutput(){
          global 
$x;
          
$x->addComponent(implode("\r\n",$this->output));
      }      
      
      
     function 
resetVars(){
         
$sql "UPDATE cardwars SET baralho='',ponteiro=0 WHERE id = " $this->game_id;
         
mysql_query($sql);
     }
     
     
      function 
start_deck(){
          
$cartas = array("A","2","3","4","5","6","7","8","9","10","J","Q","K");
          
$naipes = array("c","s","d","h");
          
$baralho = array();
          foreach(
$cartas as $c){
              foreach(
$naipes as $n){
                  
$baralho[] = $c $n;
              }
          }
          
mt_srand(microtime() * 100000 rand());
          
shuffle($baralho); 
          
$this->deck $baralho;
          
$this->pointer 0;
          
mysql_query("UPDATE cardwars SET baralho = '".implode(",",$baralho)."', bet=0,tie=0,ponteiro=0 WHERE id = " $this->game_id);         
      }           
      
      
        function 
getCardValue($card){
            
$cv substr($card,0,1);
            
$cout 0;
            switch(
$cv){
                case 
'A'$cout 14; break;
                case 
'2'$cout 2; break;
                case 
'3'$cout 3; break;
                case 
'4'$cout 4; break;
                case 
'5'$cout 5; break;
                case 
'6'$cout 6; break;
                case 
'7'$cout 7; break;
                case 
'8'$cout 8; break;
                case 
'9'$cout 9; break;
                case 
'1'$cout 10; break;
                case 
'J'$cout 11; break;
                case 
'Q'$cout 12; break;
                case 
'K'$cout 13; break;
            }  
            return 
$cout;  
        }       
      
      function 
deal(){
          global 
$bank,$Player;
           
$this->output[] = '.$this->game_id.'" name="Cardwars" response="deal">';
           
           if(
$this->bet 0){
               
mysql_query("UPDATE cardwars SET bet = "$this->bet" WHERE id =" $this->game_id);
           }
           if(
$this->tie 0){
               
mysql_query("UPDATE cardwars SET tie = "$this->tie" WHERE id =" $this->game_id);
           }           
           
$ucard $this->deck[$this->pointer];
           
$this->pointer++;
           
$dcard $this->deck[$this->pointer];
           
$this->pointer++;               

           
$dcardVal $this->getCardValue($dcard);
           
$ucardVal $this->getCardValue($ucard);

           
$this->updatePointer();
           if(
$dcardVal $ucardVal){
               
$bank->method "update";
               
$this->betLines[] = '.$this->bet.'" won="0" />';
               if(
$this->tie 0){
                    
$this->betLines[] = '.$this->tie.'" won="0" />';
                    
$bt $this->tie $this->bet;
                    
$bank->addBalanceLineX(-$bt);
               }else{
                   
$bank->addBalanceLineX(-$this->bet);
                   
$this->betLines[] = '';
               }
               
$this->output[] = '.$ucard.'" dealer="'.$dcard.'" state="loss" />';
               
$this->resetVars();
           }elseif(
$dcardVal $ucardVal){
               
$bank->method "update";
               
$betWin $this->bet 2;
               
$this->betLines[] = '.$this->bet.'" won="'.$betWin.'" />';
               
$bank->payPrize($betWin/100);
               if(
$bank->play == "r"){
                   
$Player->updateReal($betWin/100);
               }else{
                   
$Player->updateFree($betWin/100);
               }
               if(
$this->tie 0){          
                    
$this->betLines[] = '.$this->tie.'" won="0" />';
                    
$bt $this->tie $this->bet;
                    
$bank->addBalanceLineX(-$this->tie);
               }else{
                   
$bank->addBalanceLineX($this->bet);
                   
$this->betLines[] = '';
               }
               
$this->output[] = '.$ucard.'" dealer="'.$dcard.'" state="win" />';
               
$this->resetVars();               
           }elseif(
$dcardVal == $ucardVal){
              
$bank->method "update";
              
$this->betLines[] = '.$this->bet.'" won="0" />';
               if(
$this->tie 0){
                    
$this->betLines[] = '.$this->tie.'" won="0" />';
                    
$bt $this->tie $this->bet;
                    
$bank->addBalanceLineX(-$bt);                  
               }else{
                   
$bank->addBalanceLineX(-$this->bet);
                   
$this->betLines[] = '';
               }
               
$this->output[] = '.$ucard.'" dealer="'.$dcard.'" state="tie" />';              
               
           }
           
           if(!empty(
$this->betLines)) $this->output[] = implode("\r\n",$this->betLines);
           
$this->output[] = "";
      }
      
      
      function 
surrender(){
          global 
$bank,$Player;
          
$bank->method "update";
          
$this->output[] = '.$this->game_id.'" name="Cardwars" response="surrender">';
          
$this->output[] = '';
          
$bwon $this->bet /2;
          
$this->betLines[] = '.$bwon.'" won="'.$bwon.'" />';
          
$this->betLines[] = '.$bwon.'" won="0" />';
          
$bank->addBalanceLineX($bwon);
          
$bank->payPrize($bwon/100);
          if(
$bank->play == "r"){
                
$Player->updateReal($bwon/100);
          }else{
                
$Player->updateFree($bwon/100);
          }
          if(
$this->tie 0){
                   
$tieWon = ($this->tie 10) + $this->tie;
                    
$this->betLines[] = '.$this->tie.'" won="'.$tieWon.'" />';
                  
$bank->addBalanceLineX($tieWon);
                  
$bank->payPrize($tieWon/100);
                  if(
$bank->play == "r"){
                        
$Player->updateReal($tieWon/100);
                  }else{
                        
$Player->updateFree($tieWon/100);
                  }                    
                                  
          }else{
              
$this->betLines[] = '';              
          }
           if(!empty(
$this->betLines)) $this->output[] = implode("\r\n",$this->betLines);
           
$this->output[] = "";
           
$this->resetVars();                    
      }
      
      
      function 
war(){
          global 
$bank,$Player;
           
$this->output[] = '.$this->game_id.'" name="Cardwars" response="war">';          
          
           
$ucard $this->deck[$this->pointer];
           
$this->pointer++;
           
$dcard $this->deck[$this->pointer];
           
$this->pointer++;               

           
$dcardVal $this->getCardValue($dcard);
           
$ucardVal $this->getCardValue($ucard);          
          
           
$this->updatePointer();
          if(
$dcardVal $ucardVal){
               
$bank->method "update";
               
$this->betLines[] = '.$this->bet.'" won="0" />';
               
$this->betLines[] = '.$this->bet.'" won="0" />';
               if(
$this->tie 0){
                      
$tieWon = ($this->tie 10) + $this->tie;
                    
$this->betLines[] = '.$this->tie.'" won="'.$tieWon.'" />';
                  
$bank->addBalanceLineX($tieWon);
                  
$bank->payPrize($tieWon/100);
                  if(
$bank->play == "r"){
                        
$Player->updateReal($tieWon/100);
                  }else{
                        
$Player->updateFree($tieWon/100);
                  }                    
                                
               }else{
                   
$bank->addBalanceLineX(-$this->bet);
                   
$this->betLines[] = '';
               }
               
$this->output[] = '.$ucard.'" dealer="'.$dcard.'" state="loss" />';
          }else{
               
$bank->method "update";
               
$betWin $this->bet 2;
               
$this->betLines[] = '.$this->bet.'" won="'.$betWin.'" />';
               
$this->betLines[] = '.$this->bet.'" won="'.$betWin.'" />';
               
$bank->payPrize(($betWin 2)/100);
               if(
$bank->play == "r"){
                   
$Player->updateReal(($betWin 2)/100);
               }else{
                   
$Player->updateFree(($betWin 2)/100);
               }
               if(
$this->tie 0){          
                       
$tieWon = ($this->tie 10) + $this->tie;
                    
$this->betLines[] = '.$this->tie.'" won="'.$tieWon.'" />';
                  
$bank->addBalanceLineX($tieWon);
                  
$bank->payPrize($tieWon/100);
                  if(
$bank->play == "r"){
                        
$Player->updateReal($tieWon/100);
                  }else{
                        
$Player->updateFree($tieWon/100);
                  }  
               }else{
                   
$bank->addBalanceLineX($this->bet 2);
                   
$bank->addBalanceLineX($this->bet 2);
                   
$this->betLines[] = '';
               }
               
$this->output[] = '.$ucard.'" dealer="'.$dcard.'" state="win" />';             
          }
          
           if(!empty(
$this->betLines)) $this->output[] = implode("\r\n",$this->betLines);
           
$this->output[] = "";
           
$this->resetVars();           
      }
      function 
updatePointer(){
          
mysql_query("UPDATE cardwars SET ponteiro = {$this->pointer} WHERE id = " $this->game_id);
      }      
  }
?>



dcard = Dealer Card
ucard = Player Card
1/100 is because the values are passed into the game as int, so instead of 2.00 it passes 200.
full member
Activity: 182
Merit: 101
May 22, 2011, 07:11:49 PM
#33
Ok, looks like the rule *should* be this:

If the player elects to go to war he must raise his bet by an amount equal to his original wager. The dealer will do the same but this is just for show. The dealer will then burn three cards and give the player and dealer another card each. If the player's second card equals or beats the dealer then the player shall win even money on the raise only and the original wager shall push. If the dealer's second card is greater the player shall lose both bets.

It definitely wasn't doing that for play money.  Could have been intentional or not.  I was getting double the payout.  I know I wasn't losing anything extra on the 2nd bet.  That could be where the "commission" was coming from, the 2nd bet was 1/100 of what it was.  I see a lot of bet/100 code, so perhaps that's what's happening on the 2nd bet.
full member
Activity: 182
Merit: 101
May 22, 2011, 07:09:27 PM
#32
This is real odd, playing for play money, and the opposite is happening, I can't stop losing.  I need to run a simulation to see what are the odds someone is behind by 10 bets within 1000 plays or something.  Perhaps I am just unlucky at real money and super lucky at real!

A 95% confidence at 1000 trials of a 50/50 game is plus or minus 32 units.  As I keep telling you, 10 unit swings are common.

10 units, then 20 (smaller) units after that?  Based on the bug I already found?  Sure, it's possible.  I wasn't at 1000 trials, no way.  If I played more than 200 hands I'd be surprised.

You have an easy way to calculate the probability?  I'll write a program real quick to test it out based on the actual probabilities of what the game should have been.
full member
Activity: 182
Merit: 101
May 22, 2011, 07:07:21 PM
#31
Just hit a war, won, and got paid what I would have expected ($40-commission) in play money.  Really weird.

If you have logs of the hands, that would be super sweet to look at.  I'd like to get to the bottom of this.  I trust you aren't trying to scam anyone, and either it's a misunderstanding of the rules or a bug somewhere.

I was paying attention to my balance and I'm fairly sure (although not 100%) that I got paid the full amount, eg 39.90

You were playing play money?  I was noticing full payout on play money.  I wasn't paying close enough attention at real money to know.  I think at play-money, he wasn't charging enough on ties when you lose (you have to double your bet).  If the opposite problem exists at real (I have to speculate since I can't test it anymore), everything makes perfect sense.  I don't understand a lot of the external parts of the code for what he posted (it didn't even seem to really have the option for users to surrender or not, so I don't see where that code is), so there's no way to verify it.

I'm pretty sure that's the problem.  Hopefully he can get that part of the code or investigate it (I'd be happy to test on a different account with house money that I couldn't cash out if I won) to try to identify the problem.

It's always possible I ran 10 standard deviations below normal over my few hundred hands, but based on the play money problem I think I found, a bug seems more likely.
hero member
Activity: 793
Merit: 1026
May 22, 2011, 07:04:07 PM
#30
This is real odd, playing for play money, and the opposite is happening, I can't stop losing.  I need to run a simulation to see what are the odds someone is behind by 10 bets within 1000 plays or something.  Perhaps I am just unlucky at real money and super lucky at real!

A 95% confidence at 1000 trials of a 50/50 game is plus or minus 32 units.  As I keep telling you, 10 unit swings are common.
hero member
Activity: 793
Merit: 1026
May 22, 2011, 07:02:32 PM
#29
Just hit a war, won, and got paid what I would have expected ($40-commission) in play money.  Really weird.

If you have logs of the hands, that would be super sweet to look at.  I'd like to get to the bottom of this.  I trust you aren't trying to scam anyone, and either it's a misunderstanding of the rules or a bug somewhere.

I was paying attention to my balance and I'm fairly sure (although not 100%) that I got paid the full amount, eg 39.90
full member
Activity: 182
Merit: 101
May 22, 2011, 06:58:04 PM
#28
As I watched on the database:

From the initial 100 FBTC:

tomcollins: +7%, had been down to -5% at least
luv2drnkbr: +160%

This all in fun play, same algorithm, "just eyes" didn't touch anything.

Yes, tom, this game wages well the player during the wars, but before the player get a war he may lost a lot.
Also, by the looks of the DB, and assuming luv2 would make the same entrance you did I must say I'd been *F* lucky... as your luck seams to be down either for real or play, while his doesn't.

Still I'll "sleep over it" to decide whether to put this on or not. It's almost 1 AM here and I want to run more statistical analysis on it along with find that annoying 1% "commission".

I was betting 10 FBTC though, so that represents only a 16 unit upswing.  Please please put the game back in as it was, I'll be your bestest friend forever and ever.   Cheesy

16 unit upswing is absolutely huge in this game.  It's almost like we are playing as the dealer for play money, and player for real money.  If the codepath is different for real vs. play, that might explain it.  Something is not right.  I think for play money, we are paying only half as much as we should on tie-loss, but with real money, it's the opposite (pay full amount for tie-loss, get half the payout for tie-win).  The numbers seem to match up perfectly.

Hopefully it's a bug and BCE finds it tomorrow.  I'd greatly appreciate knowing what happened.
full member
Activity: 182
Merit: 101
May 22, 2011, 06:55:45 PM
#27
As I watched on the database:

From the initial 100 FBTC:

tomcollins: +7%, had been down to -5% at least
luv2drnkbr: +160%

This all in fun play, same algorithm, "just eyes" didn't touch anything.

Yes, tom, this game wages well the player during the wars, but before the player get a war he may lost a lot.
Also, by the looks of the DB, and assuming luv2 would make the same entrance you did I must say I'd been *F* lucky... as your luck seams to be down either for real or play, while his doesn't.

Still I'll "sleep over it" to decide whether to put this on or not. It's almost 1 AM here and I want to run more statistical analysis on it along with find that annoying 1% "commission".

Ok, seeing something weird on play money.  I play on fast mode so it's harder to see what's going on.  I got a tie.  Was betting 10BTC.  I went to war, and my balance as only .10 less afterward. I would have expected it to drop by 10BTC again.

I'm up 200% on play money now, played a TON of hands, though.  It's possible I'm just unlucky, but something seems off.  The code you put up is missing a few pieces so I'm not quite sure how it works.

dcard is dealer card?  

Get some sleep, we'll get to the bottom of it tomorrow.  Thanks for looking into it.
hero member
Activity: 793
Merit: 1026
May 22, 2011, 06:55:07 PM
#26
As I watched on the database:

From the initial 100 FBTC:

tomcollins: +7%, had been down to -5% at least
luv2drnkbr: +160%

This all in fun play, same algorithm, "just eyes" didn't touch anything.

Yes, tom, this game wages well the player during the wars, but before the player get a war he may lost a lot.
Also, by the looks of the DB, and assuming luv2 would make the same entrance you did I must say I'd been *F* lucky... as your luck seams to be down either for real or play, while his doesn't.

Still I'll "sleep over it" to decide whether to put this on or not. It's almost 1 AM here and I want to run more statistical analysis on it along with find that annoying 1% "commission".

I was betting 10 FBTC though, so that represents only a 16 unit upswing.  Please please put the game back in as it was, I'll be your bestest friend forever and ever.   Cheesy
legendary
Activity: 1218
Merit: 1000
May 22, 2011, 06:50:26 PM
#25
As I watched on the database:

From the initial 100 FBTC:

tomcollins: +7%, had been down to -5% at least
luv2drnkbr: +160%

This all in fun play, same algorithm, "just eyes" didn't touch anything.

Yes, tom, this game wages well the player during the wars, but before the player get a war he may lost a lot.
Also, by the looks of the DB, and assuming luv2 would make the same entrance you did I must say I'd been *F* lucky... as your luck seams to be down either for real or play, while his doesn't.

Still I'll "sleep over it" to decide whether to put this on or not. It's almost 1 AM here and I want to run more statistical analysis on it along with find that annoying 1% "commission".
hero member
Activity: 793
Merit: 1026
May 22, 2011, 06:50:05 PM
#24
This is real odd, playing for play money, and the opposite is happening, I can't stop losing.  I need to run a simulation to see what are the odds someone is behind by 10 bets within 1000 plays or something.  Perhaps I am just unlucky at real money and super lucky at real!

Are you joking!?  10 unit swings are insanely common in 50/50 games.
full member
Activity: 182
Merit: 101
May 22, 2011, 06:47:01 PM
#23
Just hit a war, won, and got paid what I would have expected ($40-commission) in play money.  Really weird.

If you have logs of the hands, that would be super sweet to look at.  I'd like to get to the bottom of this.  I trust you aren't trying to scam anyone, and either it's a misunderstanding of the rules or a bug somewhere.
full member
Activity: 182
Merit: 101
May 22, 2011, 06:44:45 PM
#22
I was up a lot, lost a lot since then.

The problem may be that it doesn't pay enough when you win on wars.  That might account for it.  It's annoying because I need to get a war then win to see if it's right, plus I need to remember what my balance was before the bet.

If that's the case, then my losses is pretty much expectations, but that doesn't seem like that's what it's supposed to be paying me.

For example, I bet $10.  I get a tie, so I go to war, bet another $10.  I should get $39.90 back ($19.90 profit) if I win the war, and bet out my $20.10 if I lose the war.  But what may be happening is I win back only get back $29.90 (my $20 bet plus $10 on the war bet).

Actually, that is how Casino War works in the Casino now that I looked it up.  This is a brutal game for the player even with the tie going to the player (the commission fixes that).

Arg, I think that makes sense at least.  Not quite the rules I was expecting (it's not really well defined).  House edge is gigantic.
legendary
Activity: 1218
Merit: 1000
May 22, 2011, 06:35:42 PM
#21
I'm trying to figure out that 1% and all that statistical math. Back to test bench, to burn that game again.
tomcollins, as far as I can see you're up 48 fun

Edit: checked the db again, now you're about 5 down of the initial 100 fun
full member
Activity: 182
Merit: 101
May 22, 2011, 06:30:37 PM
#20
This is real odd, playing for play money, and the opposite is happening, I can't stop losing.  I need to run a simulation to see what are the odds someone is behind by 10 bets within 1000 plays or something.  Perhaps I am just unlucky at real money and super lucky at real!
hero member
Activity: 793
Merit: 1026
May 22, 2011, 06:29:17 PM
#19
Holy s....!!!
You guys don't waste time!  Huh
I decided to take cardwars out while re-checking its engine.

Oh gay I was just about to deposit.  Why'd you take it offline?  Was Tom right and he was being cheated (by accident of course!) or did you discover the 2x payment and 1% commision glitches..Huh
full member
Activity: 182
Merit: 101
May 22, 2011, 06:22:25 PM
#18
legendary
Activity: 1218
Merit: 1000
May 22, 2011, 06:22:00 PM
#17
Holy s....!!!
You guys don't waste time!  Huh
I decided to take cardwars out while re-checking its engine.
legendary
Activity: 1218
Merit: 1000
May 22, 2011, 06:17:46 PM
#16
Still can't find where is that 1% going:

Here's the "war" code:

Code:
      function war(){
          global 
$bank,$Player;
           
$this->output[] = '.$this->game_id.'" name="Cardwars" response="war">';          
           
$ucard $this->deck[$this->pointer];
           
$this->pointer++;
           
$dcard $this->deck[$this->pointer];
           
$this->pointer++;

           
$dcardVal $this->getCardValue($dcard);
           
$ucardVal $this->getCardValue($ucard); 

          if(
$dcardVal $ucardVal){
               
$bank->method "update";
               
$this->betLines[] = '.$this->bet.'" won="0" />';
               
$this->betLines[] = '.$this->bet.'" won="0" />';
               if(
$this->tie 0){
                      
$tieWon = ($this->tie 10) + $this->tie;
                    
$this->betLines[] = '.$this->tie.'" won="'.$tieWon.'" />';
                  
$bank->addBalanceLineX($tieWon);
                  
$bank->payPrize($tieWon/100);
                  if(
$bank->play == "r"){
                        
$Player->updateReal($tieWon/100);
                  }else{
                        
$Player->updateFree($tieWon/100);
                  }                    
                                
               }else{
                   
$bank->addBalanceLineX(-$this->bet);
                   
$this->betLines[] = '';
               }
               
$this->output[] = '.$ucard.'" dealer="'.$dcard.'" state="loss" />';
          }else{
               
$bank->method "update";
               
$betWin $this->bet 2;
               
$this->betLines[] = '.$this->bet.'" won="'.$betWin.'" />';
               
$this->betLines[] = '.$this->bet.'" won="'.$betWin.'" />';
               
$bank->payPrize(($betWin 2)/100);
               if(
$bank->play == "r"){
                   
$Player->updateReal(($betWin 2)/100);
               }else{
                   
$Player->updateFree(($betWin 2)/100);
               }
               if(
$this->tie 0){          
                       
$tieWon = ($this->tie 10) + $this->tie;
                    
$this->betLines[] = '.$this->tie.'" won="'.$tieWon.'" />';
                  
$bank->addBalanceLineX($tieWon);
                  
$bank->payPrize($tieWon/100);
                  if(
$bank->play == "r"){
                        
$Player->updateReal($tieWon/100);
                  }else{
                        
$Player->updateFree($tieWon/100);
                  }  
               }else{
                   
$bank->addBalanceLineX($this->bet 2);
                   
$bank->addBalanceLineX($this->bet 2);
                   
$this->betLines[] = '';
               }
               
$this->output[] = '.$ucard.'" dealer="'.$dcard.'" state="win" />';             
          }
    }
?>


What happened tomcollins?
Pages:
Jump to: