Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » Finished MUD Scripts Goto page Previous  1, 2
ralgith Posted: Tue Dec 11, 2007 6:28 am
Deal Or No Deal
Leyline
Wanderer


Joined: 03 Feb 2007
Posts: 64

PostPosted: Thu Jan 17, 2008 5:14 am   
 
Raglith,
is the @CR variable something like CasesRemaining?
if so, how is it used compared to CasesLeft?
Reply with quote
Leyline
Wanderer


Joined: 03 Feb 2007
Posts: 64

PostPosted: Thu Jan 17, 2008 5:50 am   
 
Ok, nevermind I got it, but I see in some instances you made sure to list the players case amount (so they do not see it missing and know their case),
but in other alias' you only seem to use @CR (which would be the cases on stage?)
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Jan 17, 2008 6:02 am   
 
Thinking about this, though, if I wanted to make it profitable, I'd just cheat. Make it have a percentage chance of ensuring that they lose (and ensuring that the banker never gives an offer high enough to cause the game to end) or giving them a chance to win. Players wouldn't know the internal workings of the script and it'd be impossible to detect given the strong element of chance in the game.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Leyline
Wanderer


Joined: 03 Feb 2007
Posts: 64

PostPosted: Thu Jan 17, 2008 8:33 am   
 
Ok, whew, here's my 1st attempt at the rewrite,
I named all the variables something more meaningful.
And instead of inplay and numsort, I just made an Amounts on board list,
and as we open cases, I remove that amount from the list, instead of rebuilding and resorting the list every time.
Cases are also now a list.
I made it so playercase # inits a new game also.
Next up, when we run out of choices, I will put in banker offer, and force deal or no deal without opening more cases
(currently you can go negative)


#CLASS {DealOrNoDeal}
#ALIAS InitDonD {
#CLASS DealOrNoDeal
#VAR Cash {1|10|50|100|250|500|750|1000|2000|3000|4000|5000|7500|10000|50000|100000|250000|500000|750000|1000000|2000000|3000000|4000000|5000000|7500000|10000000}
#VAR TurnNumber 1
#VAR TurnCasesPicked 0
#VAR PrevOffer {}
#VAR CaseAmounts {}
#VAR CasesOnStage {}
#LOOP 26 {#additem CasesOnStage %i}
#VAR AmountsOnBoard @Cash
#WHILE (%numitems( @CaseAmounts) < 26) {
#VAR TotalValue %item( @AmountsOnBoard, %random( 1, %numitems( @AmountsOnBoard)))
#ADDITEM CaseAmounts @TotalValue
#DELITEM AmountsOnBoard @TotalValue
}
#VAR AmountsOnBoard @Cash
#VAR AmountsOnBoardPretty ""
#LOOP 26 {#additem AmountsOnBoardPretty %format( "&.0n", %item( @AmountsOnBoard, %i))}
#say Use PlayerCase (x) where x is a number between 1 and 26 to pick a case!
#CLASS 0
}
#ALIAS BankOffer {
#CLASS DealOrNoDeal
#var BankOffer 0
#var TotalValue 0
#loop %numitems( @AmountsOnBoard) {#ADD TotalValue %item( @AmountsOnBoard, %i)}
#MATH BankOffer %int( (@TotalValue / %numitems( @AmountsOnBoard)) * @TurnNumber / 10)
#VAR BankOffer %format( "&.0n", @BankOffer)
#IF (@TurnNumber > 1) {#EXEC @chan The Banker's Current Offer Is: @BankOffer Talens, (Previous: %replace( @PrevOffer, "|", ","))} {#EXEC @chan The Banker's Current Offer Is: @BankOffer Talens}
#if (%ismember( @BankOffer, @PrevOffer)=0) {#VAR PrevOffer %push( @BankOffer, @PrevOffer)}
#CLASS 0
}
#ALIAS DonDInPlay {
#CLASS DealOrNoDeal
#VAR AmountsOnBoardPretty {}
#LOOP %numitems( @AmountsOnBoard) {#ADDITEM AmountsOnBoardPretty %format( "&8.0n", %item( @AmountsOnBoard, %i))}
#EXEC @chan Amounts Left In Play:%crlf%replace( @AmountsOnBoardPretty, "|", " ")
#EXEC @chan Cases Left To Choose From: %subchar( @CasesOnStage, "|", " ")
#VAR CasesToPick %case( @TurnNumber, 6, 5, 4, 3, 2, 1, 1, 1, 1, "Switch?")
#IF (@TurnNumber < 10) {#MATH CasesToPick (@CasesToPick - @TurnCasesPicked)}
#IF (@CasesToPick = 0) {#EXEC BankOffer} {#EXEC @chan Cases Remaining To Open: @CasesToPick}
#CLASS 0
}
#ALIAS Deal {
#IF (@CasesToPick = 0) {
#EXEC @chan Player Accepts Banker's Offer Of: @BankOffer
#EXEC InitDonD
} {
#EXEC @chan You didn't pick all the cases this round, keep playing!
#EXEC DonDInPlay
}
}
#ALIAS NoDeal {
#CLASS DealOrNoDeal
#IF (@CasesToPick = 0) {
#EXEC @chan Player says No Deal!
#ADD TurnNumber 1
#EXEC DonDInPlay
#VAR TurnCasesPicked 0
#EXEC DonDInPlay
} {
#EXEC @chan You didn't pick all the cases this round, keep playing!
#EXEC DonDInPlay
}
#CLASS 0
}
#ALIAS SwitchCases {
#EXEC @chan Player Chooses To Switch Cases, The Case Player Now Has Contains: %item( @CaseAmounts, @CasesOnStage)
#EXEC @chan The Last Remaining Case Contained: %item( @CaseAmounts, @PlayersCase)
}
#ALIAS KeepCase {
#EXEC @chan Player Chooses To Keep Their Case, And It Contains: %item( @CaseAmounts, @PlayersCase)
#EXEC @chan The Last Remaining Case Contained: @{%concat( ""Case"", @CasesOnStage)}
}
#ALIAS OpenCase {
#CLASS DealOrNoDeal
#IF (@CasesToPick > 0) {
#IF (%ismember( %1, @CasesOnStage) > 0) {
#EXEC @chan Case %1 Contains: %item( @CaseAmounts, %1) Talens
#DELITEM CasesOnStage %1
#DELITEM AmountsOnBoard %item( @CaseAmounts, %1)
#ADD TurnCasesPicked 1
} {#EXEC @chan Case Already Chosen}
#EXEC DonDInPlay
} {#EXEC BankOffer}
#CLASS 0
}
#ALIAS PlayerCase {
#CLASS DealOrNoDeal
#EXEC InitDonD
#VAR PlayersCase %1
#DELITEM CasesOnStage %1
#EXEC DonDInPlay
#Class 0
}
#VAR chan { #say}
#VAR TurnCasesPicked {5}
#VAR Cash {1|10|50|100|250|500|750|1000|2000|3000|4000|5000|7500|10000|50000|100000|250000|500000|750000|1000000|2000000|3000000|4000000|5000000|7500000|10000000}
#VAR TurnNumber {2}
#VAR PrevOffer {324,818}
#VAR CasesOnStage {13|14|15|16|17|18|19|20|21|22|23|24|25|26}
#VAR AmountsOnBoard {1|10|50|100|250|2000|4000|5000|100000|250000|500000|1000000|5000000|7500000|10000000}
#VAR PlayersCase {7}
#VAR CasesToPick {0}
#VAR AmountsOnBoardPretty { 1| 10| 50| 100| 250| 2,000| 4,000| 5,000| 100,000| 250,000| 500,000|1,000,000|5,000,000|7,500,000|10,000,000}
#VAR BankOffer {324,818}
#VAR CaseAmounts {2000000|3000000|1000|7500|750|500|250|750000|50000|10000|3000|4000000|1|100|7500000|5000|250000|50|100000|500000|10|4000|2000|5000000|1000000|10000000}
#CLASS 0


Last edited by Leyline on Thu Jan 17, 2008 9:01 am; edited 2 times in total
Reply with quote
Leyline
Wanderer


Joined: 03 Feb 2007
Posts: 64

PostPosted: Thu Jan 17, 2008 8:36 am   
 
Well Fang, I mean what would I do, look at their case and then only offer them a % based on their case? if they chose a low case, I would never get a high # that would prod them into playing more,
and then knocking the high #'s off the board.

I guess the basis of DonD is never profitable, since people go on the show and play for free, and usally leave with a few grand.
And really I would have to make sure they never win over their 10k entry fee.
if I cheated and only ever gave them a % of that, well then hey people would see that really quick too, we never go over our entry fee in offers!
and someone has to win once or twice, I guess it's not a good game to play casino style.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Jan 17, 2008 9:05 am   
 
Basically, because of DoND's basis in probability, the mean return won't be a proper reflection of the risk involved (economic risk equalling, I believe, the sum of the differences from the principal for each value, divided by the principal). Any offer has to reflect the risk value as well as the risk-averseness of the player.

DoND is a very difficult game to charge for entry purely because the mean (adjusted for risk) is often very different from the principal. Your offer will have to reflect the mean, but it can also never exceed the principal or the player will just take the offer and play again. The easiest way to ensure that the house wins, then, is to massage the mean (adjusted for risk) so it stays near the principal so that an offer of less than the principal seems fair. Depending on how risk-averse the player is, the true mean can be significantly different from the principal.

But if offers never exceed the principal (which is obviously going to be true) then players will stay in to the very end and then choose between the last two boxes. The easiest way to win then is simply to ensure that one box lower than the principal remains in the game until the end and then, whichever option he chooses, give him that one.

Of course you can't cheat all the time or players will cotton on. But you should be able to do it a lot, enough to ensure profitability.

Equally, even if you're playing the game without cheating, you will still have to account for this disparity between the principal and the mean and, as far as I'm aware, there isn't an easy way to do it.

So yeah. If you want to make money, write a blackjack game.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Fri Jan 18, 2008 6:11 pm   
 
Quote:

So yeah. If you want to make money, write a blackjack game.


LOL, thats funny Fang, since I wrote a blackjack script first ;)
Not sharing that one though :D

I've currently got:
BlackJack
DoND
Slots

I'm working on:
Roulette
Craps
Poker
and anything else that comes to mind ;)
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Leyline
Wanderer


Joined: 03 Feb 2007
Posts: 64

PostPosted: Fri Jan 18, 2008 6:37 pm   
 
So Rag, do you like some of the condensing I did on the dond?

I wrote a blackjack program in basic.
yeah basic like
10 Print "hello"
20 goto 10

ROFL )

"I wrote a techno song once." -- Strongbad
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sat Jan 19, 2008 6:00 am   
 
To tell the truth I didn't even really look at it :)

And I wrote my first game in BASIC as well.
My first several games.

I started with this submarine game I found in a BASIC programming book, I took that and modified it to add Destroyers, make convoys as well as single ships, allow multiple depths (and multiple depth settings for the destroyer's Depth Charges) a deck gun for the sub, limited torpedoes... as real as I could make it. It was awesome. I became an ace sub skipper back in the day :D It eventually got to the point that you could even choose from several different subs including the German Type VII, Type VIIb, Type IX, U-Boats, several classes of US and British subs, and the Japanese I-Boat. In my final version I had every class of warship available during WWII for surface ships (not every type in every class, just every class), however only the destroyers actually fought back against the sub. My best "career" I had, as a German Type IX commander, sunk an American carrier, 2 British Corvettes, 28 different merchant vessels, and a troop ship. Of course, as in real life it ended badly, I was sunk by a Polish destroyer when I attacked a convoy in late 1944 conditions lol! Oh well. Darned Polacks :D

So, programming a little casino games in zScript is cake really, except when I try to write code at 4am!
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Rappy
Wanderer


Joined: 15 Jul 2005
Posts: 96

PostPosted: Sun Sep 21, 2008 10:42 pm   
 
I know this has been here a while, but I saw the post and started my own, incorporating that "Fair Deal" link and came up with this...

Code:

#ALIAS Estimate {
  #CLASS {DealOrNoDeal}
  #VARIABLE Offer 0
  #VARIABLE OfferTest 0
  #ADDITEM cr @PCase
  #FORALL @CR {
    #VARIABLE OfferTest %eval( (%sqrt( %float( @{%concat( "Case", %i)}))) + @OfferTest)
    }
  #VARIABLE Offer %eval( %int( %eval( (@offertest/%numitems( @cr))*(@offertest/%numitems( @cr))))/100)00
  #VARIABLE Offer %format( "&.0n", @Offer)
  #DELITEM cr @PCase
  #IF (@TurnNumber > 1) {
    #VARIABLE ToShow %concat( @Offer, " Gold Coins (", %replace( @PrevOffer, "|", ", "), ")")
    #EXEC @chan The Banker's current offer is: @ToShow
    } {#EXEC @chan The Banker's current offer is: @Offer Gold Coins}
  #VARIABLE PrevOffer %push( @Offer, @PrevOffer)
  #CLASS 0
}


Now this takes into effect the "Fair Deal" but rounds it to the nearest 100 gold coins. If you don't want this, change...

Code:

#VARIABLE Offer %eval( %int( %eval( (@offertest/%numitems( @cr))*(@offertest/%numitems( @cr))))/100)00


to

Code:

#VARIABLE Offer %int( %eval( (@offertest/%numitems( @cr))*(@offertest/%numitems( @cr))))


-Rappy
_________________
Windows 11 Pro,
cMUD 3.34
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » Finished MUD Scripts All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net