Bitcoin Forum
May 04, 2024, 09:10:26 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: « 1 [2] 3 4 »  All
  Print  
Author Topic: Introducing Cardwars  (Read 6976 times)
BCEmporium (OP)
Legendary
*
Offline Offline

Activity: 1218
Merit: 1000



View Profile
May 22, 2011, 11: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

██████████████████            ██████████
████████████████              ██████████
██████████████          ▄█   ███████████
████████████         ▄████   ███████████
██████████        ▄███████  ████████████
████████        ▄█████████  ████████████
██████        ▄███████████  ████████████
████       ▄██████████████ █████████████
██      ▄███████████████████████████████
▀        ███████████████████████████████
▄          █████████████████████████████
██▄         ▀███████████████████████████
████▄        ▀██████████████████████████
██████▄        ▀████████████████████████
████████▄        ████████████████▀ █████
██████████▄       ▀█████████████  ██████
████████████▄       ██████████   ███████
██████████████▄      ▀██████    ████████
████████████████▄▄     ███     █████████
███████████████████▄    ▀     ██████████
█████████████████████▄       ███████████
███████████████████████▄   ▄████████████





▄█████████████████   ███             ███   ███   ███▄                ▄███            █████            ████████████████   ████████████████▄             █████
███▀                 ███             ███   ███   ████▄              ▄████           ███████           ███                ███           ▀███           ███████
███                  ███             ███   ███   █████▄            ▄█████          ███▀ ▀███          ███                ███            ███          ███▀ ▀███
███                  ███             ███   ███   ███ ███▄        ▄███ ███        ▄███▀   ▀███▄        ███                ███           ▄███        ▄███▀   ▀███▄
███                  ███████████████████   ███   ███  ▀██▄      ▄██▀  ███       ▄███▀     ▀███▄       ████████████████   ████████████████▀        ▄███▀     ▀███▄
███                  ███             ███   ███   ███   ▀███    ███▀   ███      ▄███▀       ▀███▄      ███                ███        ███          ▄███▀       ▀███▄
███                  ███             ███   ███   ███    ▀███  ███▀    ███     ▄███▀         ▀███▄     ███                ███         ███        ▄███▀         ▀███▄
███▄                 ███             ███   ███   ███      ██████      ███    ▄███             ███▄    ███                ███          ███      ▄███             ███▄
▀█████████████████   ███             ███   ███   ███       ████       ███   ▄███               ███▄   ████████████████   ███           ███    ▄███               ███▄

|
  TRUE BLOCKCHAIN GAMING PLATFORM 
DECENTRALISED AUTONOMOUS UNIVERSES

  HOME PAGE                                                                  WHITE PAPER 
|
1714857026
Hero Member
*
Offline Offline

Posts: 1714857026

View Profile Personal Message (Offline)

Ignore
1714857026
Reply with quote  #2

1714857026
Report to moderator
The grue lurks in the darkest places of the earth. Its favorite diet is adventurers, but its insatiable appetite is tempered by its fear of light. No grue has ever been seen by the light of day, and few have survived its fearsome jaws to tell the tale.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714857026
Hero Member
*
Offline Offline

Posts: 1714857026

View Profile Personal Message (Offline)

Ignore
1714857026
Reply with quote  #2

1714857026
Report to moderator
1714857026
Hero Member
*
Offline Offline

Posts: 1714857026

View Profile Personal Message (Offline)

Ignore
1714857026
Reply with quote  #2

1714857026
Report to moderator
1714857026
Hero Member
*
Offline Offline

Posts: 1714857026

View Profile Personal Message (Offline)

Ignore
1714857026
Reply with quote  #2

1714857026
Report to moderator
tomcollins
Full Member
***
Offline Offline

Activity: 182
Merit: 101


View Profile
May 22, 2011, 11: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.
tomcollins
Full Member
***
Offline Offline

Activity: 182
Merit: 101


View Profile
May 22, 2011, 11: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.
luv2drnkbr
Hero Member
*****
Offline Offline

Activity: 793
Merit: 1016



View Profile
May 22, 2011, 11: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.

BCEmporium (OP)
Legendary
*
Offline Offline

Activity: 1218
Merit: 1000



View Profile
May 22, 2011, 11: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".

██████████████████            ██████████
████████████████              ██████████
██████████████          ▄█   ███████████
████████████         ▄████   ███████████
██████████        ▄███████  ████████████
████████        ▄█████████  ████████████
██████        ▄███████████  ████████████
████       ▄██████████████ █████████████
██      ▄███████████████████████████████
▀        ███████████████████████████████
▄          █████████████████████████████
██▄         ▀███████████████████████████
████▄        ▀██████████████████████████
██████▄        ▀████████████████████████
████████▄        ████████████████▀ █████
██████████▄       ▀█████████████  ██████
████████████▄       ██████████   ███████
██████████████▄      ▀██████    ████████
████████████████▄▄     ███     █████████
███████████████████▄    ▀     ██████████
█████████████████████▄       ███████████
███████████████████████▄   ▄████████████





▄█████████████████   ███             ███   ███   ███▄                ▄███            █████            ████████████████   ████████████████▄             █████
███▀                 ███             ███   ███   ████▄              ▄████           ███████           ███                ███           ▀███           ███████
███                  ███             ███   ███   █████▄            ▄█████          ███▀ ▀███          ███                ███            ███          ███▀ ▀███
███                  ███             ███   ███   ███ ███▄        ▄███ ███        ▄███▀   ▀███▄        ███                ███           ▄███        ▄███▀   ▀███▄
███                  ███████████████████   ███   ███  ▀██▄      ▄██▀  ███       ▄███▀     ▀███▄       ████████████████   ████████████████▀        ▄███▀     ▀███▄
███                  ███             ███   ███   ███   ▀███    ███▀   ███      ▄███▀       ▀███▄      ███                ███        ███          ▄███▀       ▀███▄
███                  ███             ███   ███   ███    ▀███  ███▀    ███     ▄███▀         ▀███▄     ███                ███         ███        ▄███▀         ▀███▄
███▄                 ███             ███   ███   ███      ██████      ███    ▄███             ███▄    ███                ███          ███      ▄███             ███▄
▀█████████████████   ███             ███   ███   ███       ████       ███   ▄███               ███▄   ████████████████   ███           ███    ▄███               ███▄

|
  TRUE BLOCKCHAIN GAMING PLATFORM 
DECENTRALISED AUTONOMOUS UNIVERSES

  HOME PAGE                                                                  WHITE PAPER 
|
luv2drnkbr
Hero Member
*****
Offline Offline

Activity: 793
Merit: 1016



View Profile
May 22, 2011, 11: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

tomcollins
Full Member
***
Offline Offline

Activity: 182
Merit: 101


View Profile
May 22, 2011, 11: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.
tomcollins
Full Member
***
Offline Offline

Activity: 182
Merit: 101


View Profile
May 22, 2011, 11: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.
luv2drnkbr
Hero Member
*****
Offline Offline

Activity: 793
Merit: 1016



View Profile
May 23, 2011, 12:02:32 AM
 #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

luv2drnkbr
Hero Member
*****
Offline Offline

Activity: 793
Merit: 1016



View Profile
May 23, 2011, 12:04:07 AM
 #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.

tomcollins
Full Member
***
Offline Offline

Activity: 182
Merit: 101


View Profile
May 23, 2011, 12:07:21 AM
 #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.
tomcollins
Full Member
***
Offline Offline

Activity: 182
Merit: 101


View Profile
May 23, 2011, 12:09:27 AM
 #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.
tomcollins
Full Member
***
Offline Offline

Activity: 182
Merit: 101


View Profile
May 23, 2011, 12:11:49 AM
 #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.
BCEmporium (OP)
Legendary
*
Offline Offline

Activity: 1218
Merit: 1000



View Profile
May 23, 2011, 12:14:59 AM
 #34

Here's the whole class code, I just keep browsing it up and down and still can't find what went wrong:

Code:
<?php
  
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[] = "<component err_code=\"0\" game_session=\"".$this->game_id."\" name=\"Cardwars\" response=\"init\">";
        
$this->output[] = "<result chip_values=\"10,50,100,250,1000\" default_chip=\"1\" stake_max=\"1000\" stake_min=\"10\" />";    
        
$this->output[] = "</component>";
      }  
      
      
      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[] = '<component err_code="0" game_session="'.$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[] = '<bet name="ante" staked="'.$this->bet.'" won="0" />';
               if(
$this->tie 0){
                    
$this->betLines[] = '<bet name="tie" staked="'.$this->tie.'" won="0" />';
                    
$bt $this->tie $this->bet;
                    
$bank->addBalanceLineX(-$bt);
               }else{
                   
$bank->addBalanceLineX(-$this->bet);
                   
$this->betLines[] = '<bet name="tie" staked="0" won="0" />';
               }
               
$this->output[] = '<result player="'.$ucard.'" dealer="'.$dcard.'" state="loss" />';
               
$this->resetVars();
           }elseif(
$dcardVal $ucardVal){
               
$bank->method "update";
               
$betWin $this->bet 2;
               
$this->betLines[] = '<bet name="ante" staked="'.$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[] = '<bet name="tie" staked="'.$this->tie.'" won="0" />';
                    
$bt $this->tie $this->bet;
                    
$bank->addBalanceLineX(-$this->tie);
               }else{
                   
$bank->addBalanceLineX($this->bet);
                   
$this->betLines[] = '<bet name="tie" staked="0" won="0" />';
               }
               
$this->output[] = '<result player="'.$ucard.'" dealer="'.$dcard.'" state="win" />';
               
$this->resetVars();               
           }elseif(
$dcardVal == $ucardVal){
              
$bank->method "update";
              
$this->betLines[] = '<bet name="ante" staked="'.$this->bet.'" won="0" />';
               if(
$this->tie 0){
                    
$this->betLines[] = '<bet name="tie" staked="'.$this->tie.'" won="0" />';
                    
$bt $this->tie $this->bet;
                    
$bank->addBalanceLineX(-$bt);                  
               }else{
                   
$bank->addBalanceLineX(-$this->bet);
                   
$this->betLines[] = '<bet name="tie" staked="0" won="0" />';
               }
               
$this->output[] = '<result player="'.$ucard.'" dealer="'.$dcard.'" state="tie" />';              
               
           }
           
           if(!empty(
$this->betLines)) $this->output[] = implode("\r\n",$this->betLines);
           
$this->output[] = "</component>";
      }
      
      
      function 
surrender(){
          global 
$bank,$Player;
          
$bank->method "update";
          
$this->output[] = '<component err_code="0" game_session="'.$this->game_id.'" name="Cardwars" response="surrender">';
          
$this->output[] = '<result player="" dealer="" state="" />';
          
$bwon $this->bet /2;
          
$this->betLines[] = '<bet name="ante" stake="'.$bwon.'" won="'.$bwon.'" />';
          
$this->betLines[] = '<bet name="back" stake="'.$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[] = '<bet name="tie" staked="'.$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[] = '<bet name="tie" staked="0" won="0" />';              
          }
           if(!empty(
$this->betLines)) $this->output[] = implode("\r\n",$this->betLines);
           
$this->output[] = "</component>";
           
$this->resetVars();                    
      }
      
      
      function 
war(){
          global 
$bank,$Player;
           
$this->output[] = '<component err_code="0" game_session="'.$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[] = '<bet name="ante" staked="'.$this->bet.'" won="0" />';
               
$this->betLines[] = '<bet name="bet" staked="'.$this->bet.'" won="0" />';
               if(
$this->tie 0){
                      
$tieWon = ($this->tie 10) + $this->tie;
                    
$this->betLines[] = '<bet name="tie" staked="'.$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[] = '<bet name="tie" staked="0" won="0" />';
               }
               
$this->output[] = '<result player="'.$ucard.'" dealer="'.$dcard.'" state="loss" />';
          }else{
               
$bank->method "update";
               
$betWin $this->bet 2;
               
$this->betLines[] = '<bet name="ante" staked="'.$this->bet.'" won="'.$betWin.'" />';
               
$this->betLines[] = '<bet name="bet" staked="'.$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[] = '<bet name="tie" staked="'.$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[] = '<bet name="tie" staked="0" won="0" />';
               }
               
$this->output[] = '<result player="'.$ucard.'" dealer="'.$dcard.'" state="win" />';             
          }
          
           if(!empty(
$this->betLines)) $this->output[] = implode("\r\n",$this->betLines);
           
$this->output[] = "</component>";
           
$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.

██████████████████            ██████████
████████████████              ██████████
██████████████          ▄█   ███████████
████████████         ▄████   ███████████
██████████        ▄███████  ████████████
████████        ▄█████████  ████████████
██████        ▄███████████  ████████████
████       ▄██████████████ █████████████
██      ▄███████████████████████████████
▀        ███████████████████████████████
▄          █████████████████████████████
██▄         ▀███████████████████████████
████▄        ▀██████████████████████████
██████▄        ▀████████████████████████
████████▄        ████████████████▀ █████
██████████▄       ▀█████████████  ██████
████████████▄       ██████████   ███████
██████████████▄      ▀██████    ████████
████████████████▄▄     ███     █████████
███████████████████▄    ▀     ██████████
█████████████████████▄       ███████████
███████████████████████▄   ▄████████████





▄█████████████████   ███             ███   ███   ███▄                ▄███            █████            ████████████████   ████████████████▄             █████
███▀                 ███             ███   ███   ████▄              ▄████           ███████           ███                ███           ▀███           ███████
███                  ███             ███   ███   █████▄            ▄█████          ███▀ ▀███          ███                ███            ███          ███▀ ▀███
███                  ███             ███   ███   ███ ███▄        ▄███ ███        ▄███▀   ▀███▄        ███                ███           ▄███        ▄███▀   ▀███▄
███                  ███████████████████   ███   ███  ▀██▄      ▄██▀  ███       ▄███▀     ▀███▄       ████████████████   ████████████████▀        ▄███▀     ▀███▄
███                  ███             ███   ███   ███   ▀███    ███▀   ███      ▄███▀       ▀███▄      ███                ███        ███          ▄███▀       ▀███▄
███                  ███             ███   ███   ███    ▀███  ███▀    ███     ▄███▀         ▀███▄     ███                ███         ███        ▄███▀         ▀███▄
███▄                 ███             ███   ███   ███      ██████      ███    ▄███             ███▄    ███                ███          ███      ▄███             ███▄
▀█████████████████   ███             ███   ███   ███       ████       ███   ▄███               ███▄   ████████████████   ███           ███    ▄███               ███▄

|
  TRUE BLOCKCHAIN GAMING PLATFORM 
DECENTRALISED AUTONOMOUS UNIVERSES

  HOME PAGE                                                                  WHITE PAPER 
|
BCEmporium (OP)
Legendary
*
Offline Offline

Activity: 1218
Merit: 1000



View Profile
May 23, 2011, 12:29:19 AM
 #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

██████████████████            ██████████
████████████████              ██████████
██████████████          ▄█   ███████████
████████████         ▄████   ███████████
██████████        ▄███████  ████████████
████████        ▄█████████  ████████████
██████        ▄███████████  ████████████
████       ▄██████████████ █████████████
██      ▄███████████████████████████████
▀        ███████████████████████████████
▄          █████████████████████████████
██▄         ▀███████████████████████████
████▄        ▀██████████████████████████
██████▄        ▀████████████████████████
████████▄        ████████████████▀ █████
██████████▄       ▀█████████████  ██████
████████████▄       ██████████   ███████
██████████████▄      ▀██████    ████████
████████████████▄▄     ███     █████████
███████████████████▄    ▀     ██████████
█████████████████████▄       ███████████
███████████████████████▄   ▄████████████





▄█████████████████   ███             ███   ███   ███▄                ▄███            █████            ████████████████   ████████████████▄             █████
███▀                 ███             ███   ███   ████▄              ▄████           ███████           ███                ███           ▀███           ███████
███                  ███             ███   ███   █████▄            ▄█████          ███▀ ▀███          ███                ███            ███          ███▀ ▀███
███                  ███             ███   ███   ███ ███▄        ▄███ ███        ▄███▀   ▀███▄        ███                ███           ▄███        ▄███▀   ▀███▄
███                  ███████████████████   ███   ███  ▀██▄      ▄██▀  ███       ▄███▀     ▀███▄       ████████████████   ████████████████▀        ▄███▀     ▀███▄
███                  ███             ███   ███   ███   ▀███    ███▀   ███      ▄███▀       ▀███▄      ███                ███        ███          ▄███▀       ▀███▄
███                  ███             ███   ███   ███    ▀███  ███▀    ███     ▄███▀         ▀███▄     ███                ███         ███        ▄███▀         ▀███▄
███▄                 ███             ███   ███   ███      ██████      ███    ▄███             ███▄    ███                ███          ███      ▄███             ███▄
▀█████████████████   ███             ███   ███   ███       ████       ███   ▄███               ███▄   ████████████████   ███           ███    ▄███               ███▄

|
  TRUE BLOCKCHAIN GAMING PLATFORM 
DECENTRALISED AUTONOMOUS UNIVERSES

  HOME PAGE                                                                  WHITE PAPER 
|
tomcollins
Full Member
***
Offline Offline

Activity: 182
Merit: 101


View Profile
May 23, 2011, 12:32:13 AM
 #36

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

This is code you didn't post already, right?

Is it doing something different for real vs. fake money?

I really appreciate you looking at this!
BCEmporium (OP)
Legendary
*
Offline Offline

Activity: 1218
Merit: 1000



View Profile
May 23, 2011, 12:39:29 AM
Last edit: May 23, 2011, 12:51:47 AM by BCEmporium
 #37

Nope, it just calls the same functions, the only difference is in those lines:

if($bank->play == "r"{
goes to real
}else{
goes to play
}

Code:
<?php
    
require_once("api_engine/classes/cardwars.php");       
    
$cardwars = new Cardwars($r);
    
  switch(
strtolower($do)){
        case 
'init':
                    
$bank->setGeneralRealBalance();
                    
$bank->getComponentOutPut();
                    
$cardwars->init_game();
                    
$cardwars->getComponentOutput();
                    
$x->doOutput();
                    break; 
        case 
'deal':
                    
$totalbet 0;
                    
                    foreach(
$xml->component->bet as $c){
                        
$totalbet += $c->attributes()->stake;
                        switch(
$c->attributes()->name){
                            case 
'ante'$cardwars->bet $c->attributes()->stake;break;
                            case 
'tie'$cardwars->tie $c->attributes()->stake;break;
                        }
                    }    
                    
                    
$realbet $totalbet/100;
                    if(
$bank->play == "r"){       
                        if(
$totalbet/100 $Player->real){
                            echo 
"<error>Insufficient funds!</error>";                               
                            die();                                                 
                        }
                        
$Player->updateReal(-$realbet);
                    }else{
                        if(
$totalbet/100 $Player->free){
                            echo 
"<error>Insufficient funds!</error>";                                         
                            die();                                                 
                        }                        
                        
$Player->updateFree(-$realbet);
                    }
                    
                    
$cardwars->start_deck();
                    
$cardwars->deal();                    
                    
$bank->setGeneralRealBalance();
                    
$bank->getComponentOutPut();                    
                    
$cardwars->getComponentOutput();
                    
$x->doOutput();                        
                    break;
                    
         case 
'surrender':
                    
$cardwars->surrender();
                    
$bank->setGeneralRealBalance();
                    
$bank->getComponentOutPut();                    
                    
$cardwars->getComponentOutput();
                    
$x->doOutput();                            
                    break; 
         case 
'war':
                   
$warbet $cardwars->bet//Fixed here the double 1/100
                    
$realbet $warbet/100;
                    if(
$bank->play == "r"){       
                        if(
$warbet/100 $Player->real){
                            echo 
"<error>Insufficient funds!</error>";                               
                            die();                                                 
                        }
                        
$Player->updateReal(-$realbet);
                    }else{
                        if(
$totalbet/100 $Player->free){
                            echo 
"<error>Insufficient funds!</error>";                                         
                            die();                                                 
                        }                        
                        
$Player->updateFree(-$realbet);
                    }    
                    
                    
$cardwars->warbet $cardwars->bet;
                    
$cardwars->war();
                    
$bank->setGeneralRealBalance();
                    
$bank->getComponentOutPut();                    
                    
$cardwars->getComponentOutput();
                    
$x->doOutput();                           
                    break;
  }    
?>
 


EDIT: I will go to sleep now. House edge ranges 1,71 ~ 2,88%, I didn't thought much of it because my initial draft for these casinos were to play for pennies, meanwhile btc raised "a bit". I probably will fix and put it back but just in mBTCasino with lower limits; therefore even if I get unlucky with the player on the table, the losses are easily covered.

██████████████████            ██████████
████████████████              ██████████
██████████████          ▄█   ███████████
████████████         ▄████   ███████████
██████████        ▄███████  ████████████
████████        ▄█████████  ████████████
██████        ▄███████████  ████████████
████       ▄██████████████ █████████████
██      ▄███████████████████████████████
▀        ███████████████████████████████
▄          █████████████████████████████
██▄         ▀███████████████████████████
████▄        ▀██████████████████████████
██████▄        ▀████████████████████████
████████▄        ████████████████▀ █████
██████████▄       ▀█████████████  ██████
████████████▄       ██████████   ███████
██████████████▄      ▀██████    ████████
████████████████▄▄     ███     █████████
███████████████████▄    ▀     ██████████
█████████████████████▄       ███████████
███████████████████████▄   ▄████████████





▄█████████████████   ███             ███   ███   ███▄                ▄███            █████            ████████████████   ████████████████▄             █████
███▀                 ███             ███   ███   ████▄              ▄████           ███████           ███                ███           ▀███           ███████
███                  ███             ███   ███   █████▄            ▄█████          ███▀ ▀███          ███                ███            ███          ███▀ ▀███
███                  ███             ███   ███   ███ ███▄        ▄███ ███        ▄███▀   ▀███▄        ███                ███           ▄███        ▄███▀   ▀███▄
███                  ███████████████████   ███   ███  ▀██▄      ▄██▀  ███       ▄███▀     ▀███▄       ████████████████   ████████████████▀        ▄███▀     ▀███▄
███                  ███             ███   ███   ███   ▀███    ███▀   ███      ▄███▀       ▀███▄      ███                ███        ███          ▄███▀       ▀███▄
███                  ███             ███   ███   ███    ▀███  ███▀    ███     ▄███▀         ▀███▄     ███                ███         ███        ▄███▀         ▀███▄
███▄                 ███             ███   ███   ███      ██████      ███    ▄███             ███▄    ███                ███          ███      ▄███             ███▄
▀█████████████████   ███             ███   ███   ███       ████       ███   ▄███               ███▄   ████████████████   ███           ███    ▄███               ███▄

|
  TRUE BLOCKCHAIN GAMING PLATFORM 
DECENTRALISED AUTONOMOUS UNIVERSES

  HOME PAGE                                                                  WHITE PAPER 
|
tomcollins
Full Member
***
Offline Offline

Activity: 182
Merit: 101


View Profile
May 23, 2011, 12:54:29 AM
 #38

If I was getting undercharged on war bets and given the full payouts, I must be the most unlucky guy alive to lose that much!  I would have had a 3% edge, and was down 30 bets.  Maybe a .5% chance of it or worse, so it's always possible I am just unlucky!

Still trying to go through the code, some of it is a bit tricky to read.

If you want me to test using the actual game (I'd like to try in real money mode, but I would of course not keep any of the profit or losses since it would just be for testing), I'm open to it.
BCEmporium (OP)
Legendary
*
Offline Offline

Activity: 1218
Merit: 1000



View Profile
May 23, 2011, 01:00:49 AM
 #39

If it helps you to understand what's going "behind the scenes", here's a line of server to client log (from test server):

<?xml version="1.0" encoding="UTF-8"?>
<response response_id="2"> <component name="Balance" response="update">
<generalBalance name="Cardwars" amount="-1000" />
<generalRealBalance amount="10000" />
</component> <component err_code="0" game_session="25" name="Cardwars" response="deal">
<result player="As" dealer="Qs" state="win" />
<bet name="ante" staked="1000" won="2000" />
<bet name="tie" staked="1000" won="0" />
</component></response>

Tomorrow after fixing it, I'll give you the address to test-net.
Still, the only difference between play and real is that button in the corner; at play it's blue and says play for real / in real it's green and says cashier.

██████████████████            ██████████
████████████████              ██████████
██████████████          ▄█   ███████████
████████████         ▄████   ███████████
██████████        ▄███████  ████████████
████████        ▄█████████  ████████████
██████        ▄███████████  ████████████
████       ▄██████████████ █████████████
██      ▄███████████████████████████████
▀        ███████████████████████████████
▄          █████████████████████████████
██▄         ▀███████████████████████████
████▄        ▀██████████████████████████
██████▄        ▀████████████████████████
████████▄        ████████████████▀ █████
██████████▄       ▀█████████████  ██████
████████████▄       ██████████   ███████
██████████████▄      ▀██████    ████████
████████████████▄▄     ███     █████████
███████████████████▄    ▀     ██████████
█████████████████████▄       ███████████
███████████████████████▄   ▄████████████





▄█████████████████   ███             ███   ███   ███▄                ▄███            █████            ████████████████   ████████████████▄             █████
███▀                 ███             ███   ███   ████▄              ▄████           ███████           ███                ███           ▀███           ███████
███                  ███             ███   ███   █████▄            ▄█████          ███▀ ▀███          ███                ███            ███          ███▀ ▀███
███                  ███             ███   ███   ███ ███▄        ▄███ ███        ▄███▀   ▀███▄        ███                ███           ▄███        ▄███▀   ▀███▄
███                  ███████████████████   ███   ███  ▀██▄      ▄██▀  ███       ▄███▀     ▀███▄       ████████████████   ████████████████▀        ▄███▀     ▀███▄
███                  ███             ███   ███   ███   ▀███    ███▀   ███      ▄███▀       ▀███▄      ███                ███        ███          ▄███▀       ▀███▄
███                  ███             ███   ███   ███    ▀███  ███▀    ███     ▄███▀         ▀███▄     ███                ███         ███        ▄███▀         ▀███▄
███▄                 ███             ███   ███   ███      ██████      ███    ▄███             ███▄    ███                ███          ███      ▄███             ███▄
▀█████████████████   ███             ███   ███   ███       ████       ███   ▄███               ███▄   ████████████████   ███           ███    ▄███               ███▄

|
  TRUE BLOCKCHAIN GAMING PLATFORM 
DECENTRALISED AUTONOMOUS UNIVERSES

  HOME PAGE                                                                  WHITE PAPER 
|
tomcollins
Full Member
***
Offline Offline

Activity: 182
Merit: 101


View Profile
May 23, 2011, 01:13:11 AM
 #40

If it helps you to understand what's going "behind the scenes", here's a line of server to client log (from test server):

<?xml version="1.0" encoding="UTF-8"?>
<response response_id="2"> <component name="Balance" response="update">
<generalBalance name="Cardwars" amount="-1000" />
<generalRealBalance amount="10000" />
</component> <component err_code="0" game_session="25" name="Cardwars" response="deal">
<result player="As" dealer="Qs" state="win" />
<bet name="ante" staked="1000" won="2000" />
<bet name="tie" staked="1000" won="0" />
</component></response>

Tomorrow after fixing it, I'll give you the address to test-net.
Still, the only difference between play and real is that button in the corner; at play it's blue and says play for real / in real it's green and says cashier.

The only difference is supposed to be that, of course, but there is some different code paths, so it's always possible for a bug.  I'd like to see the original code on test-net if possible just to pay close attention to the tie situations.  Thanks for looking into this, no rush on anything.
Pages: « 1 [2] 3 4 »  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!