BBGameZone.net PBBG Network | BuildingBrowserGames | Top-PBBG
March 11, 2010, 07:10:09 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Our Scripts Vault contains many game scripts that you can use to create your own game!
 
  Home   Forum   Help Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: From the Trenches :: Issue #1  (Read 2168 times)
codestryke
Administrator
Level 31
*****

Reputation: 18
Offline Offline

Posts: 519



View Profile WWW
« on: December 13, 2006, 05:12:51 PM »

Ok I'm going to start a series of articles, topics that talk about game design, programming and admin'ing an online game that I've picked up along the way. I'm not sure with what frequency these articles will get published, and with the holidays upon us they will probably dip for a couple weeks Wink However I've run across a LOT of things that I've learned that my be of some use to any budding game programmer / designer...

My apologies Zeg if this was posted in the wrong forum Wink

Durning the time of running BordelloBattles I decided to add a casino option to the game (I think the wife and I just got back from Vegas so I was full of ideas LOL). I hunted around and really couldn't find any Blackjack or Poker programs written in PHP, PERL or ASP that were really of any worth.. Those that I did find wanted me to pay for the scripts, pfft I can code so I'll just write them myself. Writing those two (blackjack and video poker) were great programming exercises.. Lots of conditionals to check for, lot of little things you need to keep track of etc etc... Anyways those two items aren't the focus of the article the real focus is on the slots I also added.

The slots, at the time, were the easiest to code, heck take a bunch of pictures put them in a set of three arrays and randomize one from each array.. If they match a given sequence you win X amount.. Not the most difficult thing to write LOL... So I put the slots up along with the blackjack and video poker and it was a huge success in the game.. Blackjack took a lot of work because I wasn't fully aware of ALL the rules and just coded a quick version of it.. After the players got a hold of it they wanted double downs, splits and every other damn that a blackjack table had...

So the game went 3-4 rounds (months) without any problems with the casino.... Then it happened a bunch of very "creative" players had found out that the slots won more often then they lost..So these "creative" players all downloaded Opera and basically had Opera automatically "click" the bet button every 20 seconds and were basically making HUGE amounts of cash off the slot machines...

Anyone know why?

I'll tell ya, for those that don't know.. It's because rand and mt_rand randomize numbers in an even pattern, or try to at least. Because of this the slots were winning more then they were losing Wink I tried a number of hacks to try and get the slots to return a set, or close to a set of percentages... Scoured the internet trying to find (in detail) how slots work. Found a lot of casino sites with basic rules, some articles with "how they work" but were very very basic. Eventually though I came across this link http://wizardofodds.com/slots/slotapx2.html which finally described, in the detail I needed, how slots really work and the mathematics behind it.

Course I'll skip over all the drama that played out on the actual game between the players since this was "sort of" an exploit that the "creative" players were using, yet not really because it was working the way I coded it. It caused a lot of problems and many users were very angry at myself and the game because of this.

Moral of the story, just because the task looks easy to accomplish doesn't always mean it is easy to, and, if it is to easy, well then maybe it was to easy and something not readily "obvious" is wrong Smiley

Oh and this article was inspired by a thread here of where to find games and someone offered up links to some slot code. Might want to check how that code is generating a "winning" spin before you put it up on your game Smiley




Logged

Creating online addictions, one game at a time:
www.extremecast.com
nano
Level 11
*

Reputation: 4
Offline Offline

Posts: 74


XHTML, CSS, JS, PHP and MySQL are my pantheon.


View Profile
« Reply #1 on: December 14, 2006, 03:42:47 PM »

That's a very informative article, thanks! I think you should continue writing more.
Logged
Zeggy
Global Moderator
Level 35
*****

Reputation: 10
Offline Offline

Posts: 1,148



View Profile WWW
« Reply #2 on: December 18, 2006, 12:08:23 PM »

I agree with nano, that is some great advice! You should write some more  -|-
Logged
npshmear
Level 6
*

Reputation: 0
Offline Offline

Posts: 26


View Profile
« Reply #3 on: January 11, 2007, 11:42:07 AM »

I think you should write more as well.  I am a new programmer, and this entire forum has really helped me to begin programming games.  I knwo that I need to start somewhere and browser based games are the easiest (other then c++ etc).

But please do keep posting, I like hearing the thoughts of people who know what their talking about so I may learn all that I can!

nps
Logged
Broda
Level 13
*

Reputation: 2
Offline Offline

Posts: 97



View Profile WWW
« Reply #4 on: March 23, 2007, 10:40:02 AM »

Informative post and the link is definitely bookmarked Smiley
Logged
sokii
Level 14
*

Reputation: 1
Offline Offline

Posts: 105


Bored? Yea me too... :/


View Profile WWW
« Reply #5 on: November 08, 2007, 06:57:44 PM »

lol nice story :]
Logged

Forum Designer Since: March 23, 2006
raestlyn
Level 28
**

Reputation: 3
Offline Offline

Posts: 430


View Profile
« Reply #6 on: January 24, 2008, 02:48:56 AM »

Nice story and Article Smiley
Logged



I can send you pics of my cocks if you want reference.
vizion
Level 7
*

Reputation: 1
Offline Offline

Posts: 32


View Profile WWW
« Reply #7 on: January 24, 2008, 05:22:44 PM »

Is this a problem for all games of chance that use mt_rand? The reason I ask is that I play a browser-based game that has what's basically a coin-flip game. You place a bet, someone else takes your bet, the code uses mt_rand to determine the winner. It's obviously supposed to be a straight 50/50 shot every time. However, many people on the game claim they can sense patterns after extended play and find the right time to get on winning streaks. As you can imagine, this has caused numerous debates on the forums about how the people who "feel" the patterns are idiots and so on and so on. Could you explain more about how the mt_rand() function might be exploited and the solutions to the problem?
Logged
Chris
Game Owner
Level 35
*

Reputation: 8
Offline Offline

Posts: 1,021


View Profile
« Reply #8 on: April 12, 2008, 06:38:19 AM »

I got similar problem. Strangely it appeared only after 1000 daily players or after switching servers. Or maybe it is not connected and players simply haven't reported it earlier? Change from rand() to mt_rand() improved the situation but did not fix it completely.

Anyone tried if seeding removes the problem? (but they claim that seeding is not required starting at PHP 4.2...)
mt_srand((double)microtime()*1000000 );
Logged

Zeggy
Global Moderator
Level 35
*****

Reputation: 10
Offline Offline

Posts: 1,148



View Profile WWW
« Reply #9 on: April 12, 2008, 12:11:31 PM »

I think mt_rand seeds itself each time it is called, but I'm not sure.
There's probably more information on the PHP website.
Logged
JGadrow
Level 35
**

Reputation: 16
Offline Offline

Posts: 871



View Profile
« Reply #10 on: April 12, 2008, 02:00:54 PM »

Right you are, Zeggy!

Quoted from PHP.net:

Note: As of PHP 4.2.0, there is no need to seed the random number generator with srand() or mt_srand() as this is now done automatically.
Logged

Idiocy - Never underestimate the power of stupid people in large groups.

codestryke
Administrator
Level 31
*****

Reputation: 18
Offline Offline

Posts: 519



View Profile WWW
« Reply #11 on: April 12, 2008, 06:53:49 PM »

Is this a problem for all games of chance that use mt_rand? The reason I ask is that I play a browser-based game that has what's basically a coin-flip game. You place a bet, someone else takes your bet, the code uses mt_rand to determine the winner. It's obviously supposed to be a straight 50/50 shot every time. However, many people on the game claim they can sense patterns after extended play and find the right time to get on winning streaks. As you can imagine, this has caused numerous debates on the forums about how the people who "feel" the patterns are idiots and so on and so on. Could you explain more about how the mt_rand() function might be exploited and the solutions to the problem?

My partner and I talk about this exact subject matter a lot!!! For a very interesting read about random and probability check out the following articles.

http://www.gamasutra.com/features/20061018/sigman_01.shtml

It'll shed a LOT of light on the matter... People tend to find patterns when there is none, in fact, while running a number of games we've found some very interesting superstitions our player's believe. They aren't true of course but it's amazing what patters people will believe they see that simply are not there.

Logged

Creating online addictions, one game at a time:
www.extremecast.com
Chris
Game Owner
Level 35
*

Reputation: 8
Offline Offline

Posts: 1,021


View Profile
« Reply #12 on: April 13, 2008, 04:12:29 PM »

People tend to find patterns when there is none, in fact, while running a number of games we've found some very interesting superstitions our player's believe. They aren't true of course but it's amazing what patters people will believe they see that simply are not there.
Yes, that's probably it. It was after one person started spreading these rumours on my forum that others started to report the problem as well...
Anyway, the mt_rand() seems to be better quality than rand() and that's all we can do under PHP.
Logged

codestryke
Administrator
Level 31
*****

Reputation: 18
Offline Offline

Posts: 519



View Profile WWW
« Reply #13 on: April 13, 2008, 05:16:29 PM »

Anyway, the mt_rand() seems to be better quality than rand() and that's all we can do under PHP.

If you want other ways try the code at.. There are more options Smiley
http://forums.devshed.com/php-development-5/php-randomization-questions-357534.html
Logged

Creating online addictions, one game at a time:
www.extremecast.com
Pages: [1]   Go Up
  Print  
 
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC
SimplePortal 2.2 © 2008-2009
Valid XHTML 1.0! Valid CSS!