View previous topic :: View next topic |
Author |
Message |
bratwurst "A Set of Mop Squeezers"
Joined: 19 Jun 2005 Posts: 64
|
Posted: Wed Oct 04, 2006 2:49 pm Post subject: Just did my first ranking system with the software |
|
|
I'm trying to get TM to use the ranking system in place at a tournament series I have been going to.
Here are the specs of the system that the host has in place:
1) Points are accumulated each tournament towards the final tournament, where your chip count is a multiplier of points earned.
2) winner is given points based on multipling 1.5 x buyin number
3) final table (8 players) are awarded points on order of finish
4) all others are awarded points based on how many people were in tournament - 8 (people who made final table).
Example, 12 entries. Winner gets 18 points. 2nd place gets 11, 3rd gets 10, 4th gets 9, etc. All those who do not make final table get 4 points. This setup isn't really my favorite but it is what the host likes and it has worked ok so far. I'm sitting in 4th so I can't complain too much.
One final note before the code, I really think a good enhancement would be a "test your formula" widget, so after writing this code I could actually throw some tests at it to make sure the formula is spitting out what I want it to. The one below is fairly simple but I could see more complex formulas being a real PITA to test by hand and brain power alone.
Here's the formula I came up with in TM:
Code: | score = if ( (a == 1.0)) then ((b * 1.5)) else if ((a >= 8.0)) then (((b + 1.0) - a)) else ((a - 8.0))
where
a = Player Finish
b = Tournament Buy-in Count
Score accumulation method: Total
Score weighting method: Equal
Score decay rate: 0.0
Score number format: Integer
Minimum tournament participation: 0 tournaments |
Thanks to Dix for the tutorial posted as a sticky in this forum. _________________ 40 |
|
Back to top |
|
|
bratwurst "A Set of Mop Squeezers"
Joined: 19 Jun 2005 Posts: 64
|
Posted: Wed Oct 04, 2006 2:55 pm Post subject: |
|
|
I see an error after looking at my code, I have the > wrong in the then statement. Should be a <= 8, where I have a >= 8.
This is why I think a good enhancement would be a testing widget. _________________ 40 |
|
Back to top |
|
|
bratwurst "A Set of Mop Squeezers"
Joined: 19 Jun 2005 Posts: 64
|
Posted: Sun Oct 15, 2006 12:44 pm Post subject: |
|
|
OK question on my formula, which is now changed to this:
score = if ( (a == 1.0)) then ((b * 1.5)) else if ((a <= 8.0)) then (((b + 1.0) - a)) else (((b - 8.0) / 2.0))
where
a = Player Finish
b = Tournament Buy-in Count
Is there a way where if the points are say, 14.5 or 16.5, etc, they always round up to the next integer? Currently I have a guy with 24.5 points and if it is set to Integer it rounds down to 24. _________________ 40 |
|
Back to top |
|
|
drneau Site Admin
Joined: 13 Feb 2005 Posts: 2385 Location: Woodbury, MN
|
Posted: Sun Oct 15, 2006 4:42 pm Post subject: |
|
|
bratwurst wrote: | OK question on my formula, which is now changed to this:
score = if ( (a == 1.0)) then ((b * 1.5)) else if ((a <= 8.0)) then (((b + 1.0) - a)) else (((b - 8.0) / 2.0))
where
a = Player Finish
b = Tournament Buy-in Count
Is there a way where if the points are say, 14.5 or 16.5, etc, they always round up to the next integer? Currently I have a guy with 24.5 points and if it is set to Integer it rounds down to 24. |
It's there a "ROUND" function? _________________ --
Dr. Neau (not a real doctor)
http://drneau.com
http://home.comcast.net/~jneau |
|
Back to top |
|
|
bratwurst "A Set of Mop Squeezers"
Joined: 19 Jun 2005 Posts: 64
|
Posted: Wed Jan 17, 2007 11:11 am Post subject: |
|
|
To follow up from a long time ago, since I just did a couple changes yesterday to this formula...
There was a ROUND function, but it dropped the .5 down. For example, 3.5 became 3.
So I tried using the CEILING function and it brought it up. 3.5 becomes 4.
I'm not sure if that is the way it is designed or if these are core JAVA functions. Kind of confusing.
Anyway, my formula now reads:
score = if ( (a == 1.0)) then (ceil((b * 1.5))) else if ((a <= 8.0)) then (((b + 1.0) - a)) else (ceil(((b - 8.0) / 2.0)))
where
a = Player Finish
b = Tournament Buy-in Count
Score accumulation method: Total
Score weighting method: Equal
Score decay rate: 0.0
Score number format: Integer
Minimum tournament participation: 0 tournaments _________________ 40 |
|
Back to top |
|
|
drneau Site Admin
Joined: 13 Feb 2005 Posts: 2385 Location: Woodbury, MN
|
Posted: Wed Jan 17, 2007 11:35 am Post subject: |
|
|
bratwurst wrote: | To follow up from a long time ago, since I just did a couple changes yesterday to this formula...
There was a ROUND function, but it dropped the .5 down. For example, 3.5 became 3.
So I tried using the CEILING function and it brought it up. 3.5 becomes 4.
I'm not sure if that is the way it is designed or if these are core JAVA functions. Kind of confusing.
Anyway, my formula now reads:
score = if ( (a == 1.0)) then (ceil((b * 1.5))) else if ((a <= 8.0)) then (((b + 1.0) - a)) else (ceil(((b - 8.0) / 2.0)))
where
a = Player Finish
b = Tournament Buy-in Count
Score accumulation method: Total
Score weighting method: Equal
Score decay rate: 0.0
Score number format: Integer
Minimum tournament participation: 0 tournaments |
It uses the Java round() function, which adds 0.5 to the number and returns the integer portion.
Are you sure you were rounding 3.5 and not 3.4999? _________________ --
Dr. Neau (not a real doctor)
http://drneau.com
http://home.comcast.net/~jneau |
|
Back to top |
|
|
bratwurst "A Set of Mop Squeezers"
Joined: 19 Jun 2005 Posts: 64
|
Posted: Wed Jan 17, 2007 11:42 am Post subject: |
|
|
I don't think so, but I'll run through the math to be sure
score = if ( (a == 1.0)) then (round((b * 1.5)))
a = Player Finish
b = Tournament Buy-in Count
if ((a==1) then (round((23*1.5))
15*1.5=22.5
22.5 should round up to 23. Using the formula above, its taking me down to 22 in the program. _________________ 40 |
|
Back to top |
|
|
bratwurst "A Set of Mop Squeezers"
Joined: 19 Jun 2005 Posts: 64
|
Posted: Wed Jan 17, 2007 11:46 am Post subject: |
|
|
Maybe there is an error somewhere in how I wrote the formula? because the end of my formula looks to be using ROUND normally. This is the final statement, where it says that for everyone who does not make the final table, the score is equal to the number of buys minus 8(final table number) divided by 2. This might be an order of operations difference.
else (round((b-8.0)/2)))
Showing my work here...
round((15-8)/2)
round(7/2)
round(3.5)
4 _________________ 40 |
|
Back to top |
|
|
Dix "Royal Flush - No Hat"
Joined: 17 Jun 2005 Posts: 246 Location: W.Poland Maine - USA
|
Posted: Wed Jan 17, 2007 1:37 pm Post subject: |
|
|
There's something wierd going on in Java here... it's certainly not rounding correctly.
Just for giggles I took one of our 15 player tourneys and just did a (round(playerfinish/2)) on it
Code: | score = round((a / 2.0))
where
a = Player Finish
Score accumulation method: Total
Score weighting method: Equal
Score decay rate: 0.0
Score number format: Double
Minimum tournament participation: 0 tournaments |
And here's the results.
15 = 8
13 = 6
11 = 6
9 = 4
7 = 4
5 = 2
3 = 2
1 = 0
While 1, 3, 7, 11, & 15 were rounded correctly, 5, 9, & 13 were not.
I tried a quick google search for java rounding errors but came up empty. _________________ - Dix |
|
Back to top |
|
|
drneau Site Admin
Joined: 13 Feb 2005 Posts: 2385 Location: Woodbury, MN
|
Posted: Wed Jan 17, 2007 2:13 pm Post subject: |
|
|
Dix wrote: | There's something wierd going on in Java here... it's certainly not rounding correctly.
Just for giggles I took one of our 15 player tourneys and just did a (round(playerfinish/2)) on it
Code: | score = round((a / 2.0))
where
a = Player Finish
Score accumulation method: Total
Score weighting method: Equal
Score decay rate: 0.0
Score number format: Double
Minimum tournament participation: 0 tournaments |
And here's the results.
15 = 8
13 = 6
11 = 6
9 = 4
7 = 4
5 = 2
3 = 2
1 = 0
While 1, 3, 7, 11, & 15 were rounded correctly, 5, 9, & 13 were not.
I tried a quick google search for java rounding errors but came up empty. |
Well, I took a quick look at the code.
Since I treat everything as "double" internally, I am using "rint" and not "round".
"rint" rounds to the closest integer and returns a double. However, if integers are equidistant, IT FAVOURS THE EVEN INTEGER!!! D'ARG!!! D'ARG!!!! WHY WOULD ANYONE WANT THAT?!?!?
So, for future releases, I'll be using y = floor (x + 0.5) rather than rint...
Hope nobody missed a championship due to this. _________________ --
Dr. Neau (not a real doctor)
http://drneau.com
http://home.comcast.net/~jneau |
|
Back to top |
|
|
bratwurst "A Set of Mop Squeezers"
Joined: 19 Jun 2005 Posts: 64
|
Posted: Wed Jan 17, 2007 2:24 pm Post subject: |
|
|
OK so should I use "ceiling"? I found the explanation for it in JAVA, but it basically means jack squat to me. I think this is basically saying:
if a number is whole (for example, 3) it returns the whole number.
If a number has a decimal, it returns the next whole number (for example, 3.2 = 4, or 2.5 = 3).
Am I right?
In any given case with my formula, the only decimal number I can get is going to be a half, basically X.5. So the number should always go up to the next number anyway.
Quote: | ceil
public static double ceil(double a)Returns the smallest (closest to negative infinity) double value that is not less than the argument and is equal to a mathematical integer. Special cases:
If the argument value is already equal to a mathematical integer, then the result is the same as the argument.
If the argument is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument.
If the argument value is less than zero but greater than -1.0, then the result is negative zero.
Note that the value of Math.ceil(x) is exactly the value of -Math.floor(-x).
Parameters:
a - a value.
Returns:
the smallest (closest to negative infinity) floating-point value that is not less than the argument and is equal to a mathematical integer. |
_________________ 40 |
|
Back to top |
|
|
Dix "Royal Flush - No Hat"
Joined: 17 Jun 2005 Posts: 246 Location: W.Poland Maine - USA
|
Posted: Wed Jan 17, 2007 2:28 pm Post subject: |
|
|
OK... so when something bugs me I don't give up easily... I did some more searching... maybe this will give Doc a head start.
Seems that Java isn't the only place this is a problem... Microsoft VB guys struggle with this one too...
Quote: | This was discussed last month. Microsoft uses Bankers Rounding.
Bankers rounding is the number is rounded to the nearest even number.
Example. 11.5 would be rounded to 12, but 8.5 would be rounded to 8.
Microsoft has an article on it on their website. |
Seems Java is using the same "banker's rounding"... always going to an even number.
I managed to scare up a couple links from Sun's Java docs on the subject in case that might help you out any Doc.
http://java.sun.com/j2se/1.5.0/docs/api/java/math/RoundingMode.html
http://java.sun.com/j2se/1.4.2/docs/api/java/math/BigDecimal.html
EDIT: OK, so I'm late to the party.... as usual.
But at least I did find an answer to the question of "why anyone would want to do that"... which makes a small amount of sense I guess...
Quote: | Banker's Rounding
When you add rounded values together, always rounding .5 in the same direction results in a bias that grows with the more numbers you add together. One way to minimize the bias is with banker's rounding.
Banker's rounding rounds .5 up sometimes and down sometimes. The convention is to round to the nearest even number, so that both 1.5 and 2.5 round to 2, and 3.5 and 4.5 both round to 4. Banker's rounding is symmetric.
In Visual Basic for Applications, the following numeric functions perform banker's rounding: CByte(), CInt(), CLng(), CCur(), and Round().
There are no Excel spreadsheet functions that perform banker's rounding.
http://support.microsoft.com/kb/196652 |
_________________ - Dix |
|
Back to top |
|
|
Dix "Royal Flush - No Hat"
Joined: 17 Jun 2005 Posts: 246 Location: W.Poland Maine - USA
|
Posted: Wed Jan 17, 2007 3:27 pm Post subject: |
|
|
bratwurst wrote: | OK so should I use "ceiling"? |
Actually, you should use the "floor" function as Doc pointed out above to get it to round the way you want
floor (x + 0.5)
Where x = the value you want rounded
Well... OK.. you COULD use ceiling(x-.5)... pick your poison.
for example... instead of (round((b * 1.5)))
you would use... (floor(((b * 1.5)+.5)))
However, You may be overlooking a simple solution to your problem... why round off at all?
There is something else you should realize... and something I explain to my players....
If you use the Score number format: Integer Players will always be ranked in the league results report according to ACTUAL points and not the displayed rounded off points.
for example... let's say you have a player with 7.5 points and another with 8 points who are 4th and 5th in the league standings... the league standings will show the player with 8 points as being in sole possession of 4th place and the other player will be ranked as 5th... even though the report is showing both of them appearing to have 8 points.
If you round off the points INSIDE of your formula (using either the round() or floor(x+.5) method) then both players will be reported as being tied for 4th place in the rankings.
Which is why I prefer to not round off points inside the formula and just let the Score number format: Integer get rid of all the decimal places.
I just tell everyone that just because the rounded off points appear to make two players equal, the report is accurate as far as position in the rankings go because they are based on actual fractional points before rounding off. _________________ - Dix |
|
Back to top |
|
|
|