Author Topic: Prizes with rounding  (Read 1247 times)

loltruck

  • Newbie
  • *
  • Posts: 4
    • View Profile
Prizes with rounding
« on: October 26, 2009, 01:18:51 PM »
Hi,

I got the following problem - and I think it is caused by a small bug in TTD, but let me describe first.

I have edited autoprizes.xml to have TTD adjust the prizes depending on entries. I also want "straight" figures for prices, so I want the prices rounded to a figure dividable by 5. So i use the rounding function which does not work that well as I thought. When rounding using the method ("to nearest" or "up") it can happen that the leftover pot is negative - which means the sum of all prizes is higher than the prizepool! The negative leftover pot does not get substracted from the prizes which have "share leftover" ticked which I think is a bug.

One workaround I found for this problem is that I declare prices with a combined percentage of less than 100% and add the leftover pot to 1st prize. I would have more liked to round other prizes up and substract the needed money for rounding from 1st prize.

Anyway - i think you should take a look at this, Corey!

Thanks and best regards,
Matthias

Corey Cooper

  • Administrator
  • Hero Member
  • *****
  • Posts: 6216
    • View Profile
Re: Prizes with rounding
« Reply #1 on: October 27, 2009, 10:41:22 AM »
It isn't a bug.  If the software were to ensure when you rounded up that it didn't exceed a specific amount, then it wouldn't technically be rounding.  If you think about it, when you round UP you're saying (for example), "I want this prize to be 10% of the pot, unless 10% isn't evenly divisible by X, in which case I want it to be MORE than 10% of the pot".  By definition you are going to exceed the pot if your prizes are rounded this way, unless they all happen to be evenly divisible by X.

The "Leftover" is meant to divide up any leftover pot - and nothing more.  If your prizes exceed the pot amount, there isn't anything left over, thus nothing left to distribute to make sure the pot is entirely awarded.

The workaround for this is to set your prizes to round down, and assign the leftover to one or more of the prizes.  Then the prize total won't exceed the pot amount, and all of the pot will be allocated.