| 10-13-2009, 05:21 PM | #1 |
Not so sure if this should be posted here, but it kinda involves script. I've made this script which I plan to release in a few hours (or tomorrow if I don't have the time), which is related to betting. I have two issues with it, of which n.o2 is the most important. 1: I have no idea what to name it. I've called it "BettingUtils" as of now, but I'm not so sure if that's a proper name. 2: If you were to use this betting system of mine, would you prefer passing on a real or an integer when doing bets [call Bet( instance, player, on what, <amount>]? (Consider that the most probable form would be Gold == Integer) Right now it's taking real as parameter, but what would you prefer? |
| 10-14-2009, 05:08 AM | #2 |
2. I would prefer integers. Much simpler in my opinion. |
| 10-14-2009, 08:02 AM | #3 |
If this is a single modular script, I believe Utils is the appropriate convention. As for betting type, integers are much better IMO for several reasons. As chobibo said, they're a lot simpler than reals. Also, they're more accurate - reals (especially those generated from user input) have horrible precision most of the time, which makes (in)equalities break at times. For instance, JASS:local real r = S2R("90") if r == 90. then call BJDebugMsg ("90. == 90.") else call BJDebugMsg ("Jass reals are suck.") endif Say you want players to be able to bet in chat. Red types -wager 50. His wager is then converted to a real and stored. Later, a trigger checks for bets less than or equal to 50. If the player's input of "50" got stored as 50.0000001, the expression fails. Bad. Besides, in real life everybody bids integers anyway. Even if you bid $0.50, that's technically 50 cents. A 2:1 return would leave a $0.50 bidder with $1.00 (100 cents); a 3:1 return would leave a $1.00 bidder with $1.33 (133 cents), and so forth. You wouldn't have $1.333333... in cash or in betting chips (though you might in a bank account, depending on how that's run). Bets and returns truncate; integers truncate. |
| 10-14-2009, 08:52 AM | #4 |
Bear in mind == has some leeway, != has to be exactly the same to go false (I think). So it's possible x == y and x != y. Not sure if it's similar for >= and <=. |
| 10-14-2009, 12:25 PM | #5 |
Thanks chobibo for opinion, and thank you cosmicat for useful information. I don't doubt it's true because I've heared it being mentioned in other places too. -- Because I recently got another system approved in hive and don't wish to spam them with scripts, I might just show you BettingUtil's header and you can tell me if you'd find it easy and useful, or just horrible (yeah, another public-contact question). JASS://=========================================================================== //== //== BettingUtils //== ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ //== Let's you bet with a player in a certain betting instance, and the profit //== will be distributed to winning players according to how much they bet //== (the player who bet the most will have the most back). //== You should note that this - although it'll be used for it in most cases - //== does not handle gold; only integers. What you're betting with is up to you. //== How you generate the number which wins, how much the bookmarker should have //== or what you're actually betting on is not this system's work; you'll have to //== do that yourself. //== Perfectly suited for 1vs1 Gladiator matches and similar. //== //== Functions //== ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ //== function InitBetInstance takes nothing returns hashtable //!= Allocates memmory for the betting instance. Should be used to prevent //!= gamecrash, but might work fine without. //!= //== function Bet takes hashtable WhichInstance, player WhichPlayer, integer WhichNumber, integer Amount returns nothing //!= The main betting function, where the player bets a certain amount //!= of something on a certain number. //!= This also initializes the betting instance. //!= //!= WhichInstance: Which betting instance (which hashtable) the bet applies to //!= WhichPlayer: The player who's betting //!= WhichNumber: On which number the player's betting on //!= Amount: Amount just indicates how much of something the player is betting. //!= //== function GetPlayerProfit takes hashtable WhichInstance, player WhichPlayer returns integer //!= Returns the amount of the bet the player has won (if he didn't win, he gets nothing back) //!= If no winning number is set, the amount bet by the player subtracted by the bookmarker's profit //!= is returned. //!= //!= WhichInstance: Which betting instance (which hashtable) the bet applies to //!= //== function SetWinningNumber takes hashtable WhichInstance, integer WinningNumber returns nothing //!= Sets the winning number for the betting instance. //!= //!= WhichInstance: Which betting instance (which hashtable) the bet applies to //!= WinningNumber: Which number won the bet //!= //== function SetBookmarkerProfit takes hashtable WhichInstance, real Fraction returns nothing //!= Sets the bookmarker's fraction of the profit. //!= By default is 0% //!= //!= WhichInstance: Which betting instance (which hashtable) the bet applies to //!= Fraction: The bookmarker's fraction of the profit (0.23 means 23% is cut //!= off from the total pool) //!= //== function ResetBetInstance takes hashtable WhichInstance returns nothing //!= Resets the betting instance //!= //=========================================================================== |
| 10-14-2009, 01:27 PM | #6 |
BettingUtils? Utils is shorthand for utilities, which is used primarily for libraries that take something and simplify it or standardize it. Since betting isn't even in WC3 normally, I don't think it's really that applicable. Call it BettingLib or something, or maybe just GamblingScript. Furthermore, who the heck is actually going to have use for something like that? I mean, random number generator with associated winnings. It'd only be useful in maps that... Err.. Have gambling. That's such a limited scope, and really, it should be easily coded without the library. I wouldn't use a hashtable, I'd just use a struct. |
| 10-14-2009, 02:00 PM | #7 |
1: Okay, then I'll come up with a better name 2: This was requested by a friend of mine so obviously someone needs it 3: I've played at least 4 maps with gambling, all of them were of the concept "bet 200 gold on a hero and if he wins you get 200% back". I simply wish to enhance this gameplay feature because 1on1 combats are often imbalanced, and thus everyone gets 600 extra gold without actually have done any real betting. |
| 10-14-2009, 02:09 PM | #8 | ||
Quote:
Quote:
|
| 10-14-2009, 02:43 PM | #9 | |
Quote:
That'll balance the betting, not the heroes. And I think that all of those 4 maps need it, which makes it useful, unlike a trigger that kills everyhing in the map. Which I've never seen in a map. |
| 10-14-2009, 02:55 PM | #10 | ||
Quote:
Quote:
Anyways, all this system has to do is manage two percents and check an integer. I don't think that does enough to even merit a script resource. |
| 10-14-2009, 03:45 PM | #11 |
I'm not uploading it here anyway, so that's not a problem. Edit: Wait... You're saying that I shouldn't upload my script because the it's too easy to make? Then why hasn't anyone made (and used) it yet? |
| 10-14-2009, 03:58 PM | #12 |
GambleEngine v1.00 |
| 10-14-2009, 05:00 PM | #13 | ||
Quote:
Quote:
|
| 10-14-2009, 05:06 PM | #14 |
Sorry chobibo but I can't find it :/ Fine, you win. I won't upload it, but my friend will enjoy it though. Thanks! |
