The Tournament Director Forums

Main => Help Me => Topic started by: poorplayer on August 10, 2008, 09:46:39 AM

Title: Formula problem
Post by: poorplayer on August 10, 2008, 09:46:39 AM
Hi, before all i need to say thanks for this great program!!! I just downloaded it and i'm amazing! The sofware is fully customizable and very simple to understand. Anyway i'm getting some troubles with formulas, i made a php script to calculate the point but i've not understood how translate it.

php script:
Quote
$buy_in = $_GET['a'];

$players = $_GET['b'];

$posizione = $_GET['c'];


if ( $buy_in <= 50) {

   $buy_in = 1 ;

}

elseif ( $buy_in <= 110) {

   $buy_in = 2 ;

}

elseif ( $buy_in <= 220) {

   $buy_in = 3 ;

}

elseif ( $buy_in <= 330) {

   $buy_in = 4 ;

}

elseif ( $buy_in >= 331) {

   $buy_in = 6 ;

}

if ( $players <= 20) {

   $players = 2 ;

}

elseif ( $players <= 30) {

   $players = 2.5 ;

}

elseif ( $players <= 40) {

   $players = 3 ;

}

elseif ( $players <= 50) {

   $players = 3.5 ;

}

elseif ( $players >= 51) {

   $players = 5 ;

}


if ( $posizione == 1 ) {

   $posizione = 150 ;

}

elseif ( $posizione == 2) {

   $posizione = 120 ;

}

elseif ( $posizione == 3) {

   $posizione = 100 ;

}

elseif ( $posizione == 4) {

   $posizione = 80 ;

}

elseif ( $posizione == 5) {

   $posizione = 60 ;

}

elseif ( $posizione == 6) {

   $posizione = 50 ;

}

elseif ( $posizione == 7) {

   $posizione = 40 ;

}

elseif ( $posizione == 8 ) {

   $posizione = 30 ;

}

elseif ( $posizione == 9) {

   $posizione = 20 ;

}

elseif ( $posizione == 10) {

   $posizione = 10 ;

}

      
elseif ( $posizione <= 20) {

   $posizione = 5 ;

}

elseif ( $posizione <= 30) {

   $posizione = 4 ;

}

elseif ( $posizione <= 40) {

   $posizione = 3 ;

}

elseif ( $posizione <= 50) {

   $posizione = 2 ;

}

elseif ( $posizione >= 51) {

   $posizione = 1 ;

}

      
$total = $buy_in * $players * $posizione ;


I've converted the script in this way:

Quote
if ( br <= 50), assign ("buyin",1) &&
if ( br <= 110), assign ("buyin",2)&&
if ( br <= 220),assign ("buyin",3) &&
if ( br <= 330),assign ("buyin",4) &&
if ( br >= 331),assign ("buyin",6) &&

if ( n <= 20), assign ("player",2)&&
if ( n <= 30), assign ("player",2.5)&&
if ( n <= 40), assign ("player",3)&&
if ( n <= 50), assign ("player",3.5)&&
if ( n <= 51), assign ("player",5)&&

if ( r == 1 ), assign ("pos",150)&&
if ( r == 2), assign ("pos",120)&&
if ( r == 3), assign ("pos",100)&&
if ( r == 4), assign ("pos",80)&&
if ( r == 5), assign ("pos",60)&&
if ( r == 6), assign ("pos",50)&&
if ( r == 7), assign ("pos",40)&&
if ( r == 8 ), assign ("pos",30)&&
if ( r == 9), assign ("pos",20)&&
if ( r == 10), assign ("pos",10)&&
if ( r <= 20), assign ("pos",5)&&
if ( r <= 30), assign ("pos",4)&&
if ( r <= 40), assign ("pos",3)&&
if ( r <= 50), assign ("pos",2)&&
if ( r >= 51), assign ("pos",1)&&

buyin * player * pos

Unfortunatly the script doesn't works and i cant understand why, i'm a very beginner coder :'(.
Could someone help me? thanks in advanced
Title: Re: Formula problem
Post by: Phaze on August 10, 2008, 09:54:30 AM
uhhhh yeah, I'll help ya, and there are some other guys that will help ya too, but could you just explain what you wanna give points for.... I don't understand any of that stuff you posted ;D
Title: Re: Formula problem
Post by: poorplayer on August 10, 2008, 11:41:09 AM
I think u need just to know php to understand what i wrote. Anyway look at this pick

(http://img291.imageshack.us/img291/7899/axbxcec8.th.png) (http://img291.imageshack.us/my.php?image=axbxcec8.png)

ie.
if the buyin is 100(2) and player are 35(3) and your final position is 3(100) u should get 600 points

AxBxC
Title: Re: Formula problem
Post by: Corey Cooper on August 10, 2008, 12:36:46 PM
There's probably a less complicated way to do it, but here's what I came up with:

assign("buyin", max(1 + if(bc > 50, 1) + if(bc > 110, 1) + if(bc > 220, 1) + if(bc > 330, 2), 6))
assign("player", 2 + min(floor(max(0, n - 11) / 10), 4) * .5 + if(n > 50, 1))
assign("pos", switch(r, 1, 150, 2, 120, 3, 100, 4, 80, 5, 60, 6, 50, 7, 40, 8, 30, 9, 20, 10, 10, 6 - min(floor((r-1)/10), 5)))
buyin * player * pos
Title: Re: Formula problem
Post by: Phaze on August 10, 2008, 01:25:04 PM
right on, I like your formula cory, so nice to assign...

But what the hello is the freakin purpose of creating these complex formulas??? what is wrong with n-r+1???