anonīms Posted March 13, 2013 Report Share Posted March 13, 2013 Ideja ir sekojoša. Ir spēlētājs1 un spēlētājs2, kuriem attiecīgi reitingi tiek atņemti un tad pārbauda kāda ir starpība. Protams šo visu var maukt IF'os, bet es šoreiz no kaut kā tāda gribētu izvairīties, tādēļ gribēju zināt vai ir kāds cits, kārtīgāks variants? Piemērs: #1 Spēlētājs1 (retings 500) uzvar spēlētāju2( reitings 50), tātad 450 ppunkti starpā un spēlētājs1 saņem 1 reitinga punktu #2 Spēlētājs2 (reitings 10) uzvar spēlētājs2 (reitings 5) = 5 punkti, tātad spēlētājs1 saņem 15 punktus. Quote Link to comment Share on other sites More sharing options...
php newbie Posted March 13, 2013 Report Share Posted March 13, 2013 es mēģinātu uztaisīt tabulu: from to winHigh winLow 0 30 15 15 31 60 14 16 61 90 13 17 ... kur from, to - intervāls, winHigh - punktu skaits ja vinnē stiprākais, winLow - ja vinnē vajākaisstarpību ņemtu ka absolūto vertību un ja + ņemtu winHight, ja - winLow kolonnu. vai nu from to win ... -91 -60 17 -61 -30 16 -31 0 15 0 30 15 31 60 14 61 90 13 ... un selektē pēc reitingu starpības Quote Link to comment Share on other sites More sharing options...
anonīms Posted March 13, 2013 Author Report Share Posted March 13, 2013 huh, gribās jau kaut kā iztikt bez papildus tabulas, bet nu paturēšu prātā ieteikumu. Ir vēl kādi varianti? Quote Link to comment Share on other sites More sharing options...
php newbie Posted March 13, 2013 Report Share Posted March 13, 2013 (edited) $dif = abs(-150); echo 15 - floor((abs($dif - 1)/30)); echo '<br>'; echo 15 + floor((abs($dif - 1)/30)); kur $diff - reitingu starpība. Un atsevišķu apstrādi kad $dif > 450 p.s. tomēr matemātika ir vajadzīga http://php.lv/f/topic/18967-par-programmetajiem/page-2#entry147529 Edited March 13, 2013 by php newbie Quote Link to comment Share on other sites More sharing options...
anonīms Posted March 14, 2013 Author Report Share Posted March 14, 2013 php newbie, bet re cik reti ^_^ :D Quote Link to comment Share on other sites More sharing options...
xPtv45z Posted March 14, 2013 Report Share Posted March 14, 2013 http://en.wikipedia.org/wiki/Elo_rating_system Quote Link to comment Share on other sites More sharing options...
anonīms Posted March 14, 2013 Author Report Share Posted March 14, 2013 Nē, nē. Mēs pašlaik sēžam uz elo un šī sistēma Mūs neinteresē. Quote Link to comment Share on other sites More sharing options...
xPtv45z Posted March 14, 2013 Report Share Posted March 14, 2013 Bet tas ir tieši tas pats, ko tu aprakstīji - punktu piešķiršana atkarībā pēc spēlētāju reitingiem. :) Quote Link to comment Share on other sites More sharing options...
anonīms Posted March 14, 2013 Author Report Share Posted March 14, 2013 (edited) labi, pierunāts. Parunājos un turpināsim tomēr izmantot elo, bet rezultātu vēl /4 izdalīsim Edit; Array([R3] => 977[R4] => 923[s1] => 5[s2] => 4[R1] => 900[R2] => 1000[P1] => +77[P2] => -77) ;/ baidi daudz vienīgi sāk ņemt nost, ja tikai 100 punkti starpā, bet abiem viņi ir daudz Edited March 14, 2013 by anonīms Quote Link to comment Share on other sites More sharing options...
anonīms Posted March 14, 2013 Author Report Share Posted March 14, 2013 (edited) Uzlobotā versiju. Izmantošu šo :) class elo_calculator { public function rating($S1,$S2,$R1,$R2) { if (empty($S1) OR empty($S2) OR empty($R1) OR empty($R2)) return null; if ($S1!=$S2) { if ($S1>$S2) { $E=60-round(1/(1+pow(10,(($R2-$R1)/400)))*60); $R['R3']=$R1+$E; $R['R4']=$R2-$E; } else { $E=60-round(1/(1+pow(10,(($R1-$R2)/400)))*60); $R['R3']=$R1-$E; $R['R4']=$R2+$E; }} else { if ($R1==$R2) { $R['R3']=$R1; $R['R4']=$R2; } else { if($R1>$R2) { $E=(60-round(1/(1+pow(10,(($R1-$R2)/400)))*60))-(120-round(1/(1+pow(10,(($R2-$R1)/400)))*60)); $R['R3']=$R1-$E; $R['R4']=$R2+$E; } else { $E=(60-round(1/(1+pow(10,(($R2-$R1)/400)))*60))-(120-round(1/(1+pow(10,(($R1-$R2)/400)))*60)); $R['R3']=$R1+$E; $R['R4']=$R2-$E; }}} $R['S1']=$S1; $R['S2']=$S2; $R['R1']=$R1; $R['R2']=$R2; $R['P1']=((($R['R3']-$R['R1'])>0)?"+".($R['R3']-$R['R1']):($R['R3']-$R['R1'])); $R['P2']=((($R['R4']-$R['R2'])>0)?"+".($R['R4']-$R['R2']):($R['R4']-$R['R2'])); $R['P1'] = round($R['P1']/4,0); $R['P2'] = round($R['P2']/4,0); if($R['P1'] == 0 || $R['P2'] == 0) { $R['P1'] = 1; $R['P2'] = -1; } return $R; } Array ( [R3] => 150 [R4] => 899940 [s1] => 5 [s2] => 4 [R1] => 90 [R2] => 900000 [P1] => 15 [P2] => -15 ) Array ( [R3] => 930 [R4] => 870 [s1] => 5 [s2] => 4 [R1] => 900 [R2] => 900 [P1] => 8 [P2] => -8 ) Array ( [R3] => 1014 [R4] => 786 [s1] => 5 [s2] => 4 [R1] => 1000 [R2] => 800 [P1] => 4 [P2] => -4 ) Edited March 14, 2013 by anonīms Quote Link to comment Share on other sites More sharing options...
daGrevis Posted March 14, 2013 Report Share Posted March 14, 2013 YES! Tagad nosaukums šim topikam patiešām atbilst! Quote Link to comment Share on other sites More sharing options...
anonīms Posted March 14, 2013 Author Report Share Posted March 14, 2013 Prieks palīdzēt! ^_^ Quote Link to comment Share on other sites More sharing options...
aaxc Posted March 14, 2013 Report Share Posted March 14, 2013 Kas tā par modi gāzt visu vienā lielā nesaprotamā klucī, nedomājot, ka kādam citam iespējams tas būs nākotnē jālabo. Takš vismaz noformatējam kā nākas ... class elo_calculator { public function rating($S1, $S2, $R1, $R2) { if (empty($S1) || empty($S2) || empty($R1) || empty($R2)) return null; if ($S1 != $S2) { if ($S1 > $S2) { $E = 60 - round(1 / (1 + pow(10, ( ($R2 - $R1) / 400 ))) * 60); $R['R3'] = $R1 + $E; $R['R4'] = $R2 - $E; } else { $E = 60 - round(1 / (1 + pow(10, ( ($R1 - $R2) / 400 ))) * 60); $R['R3'] = $R1 - $E; $R['R4'] = $R2 + $E; } } else { if ($R1 == $R2) { $R['R3'] = $R1; $R['R4'] = $R2; } else { if($R1 > $R2) { $E = 60 - round(1 / (1 + pow(10,( ($R1 - $R2) / 400 ))) * 60)) - (120 - round(1 / (1 + pow(10, ( ($R2-$R1)/400 ))) * 60); $R['R3'] = $R1 - $E; $R['R4'] = $R2 + $E; } else { $E = 60 - round(1 / (1 + pow(10, ( ($R2-$R1) / 400 ))) * 60)) - (120 - round(1 / (1 + pow(10, ( ($R1-$R2) / 400))) * 60); $R['R3'] = $R1 + $E; $R['R4'] = $R2-$E; } } } $R['S1'] = $S1; $R['S2'] = $S2; $R['R1'] = $R1; $R['R2'] = $R2; $R['P1'] = (($R['R3'] - $R['R1']) > 0) ? "+".($R['R3'] - $R['R1']) : ($R['R3'] - $R['R1']); $R['P2'] = (($R['R4'] - $R['R2']) > 0) ? "+".($R['R4'] - $R['R2']) : ($R['R4'] - $R['R2']); $R['P1'] = round($R['P1'] / 4, 0); $R['P2'] = round($R['P2'] / 4, 0); if($R['P1'] == 0 || $R['P2'] == 0) { $R['P1'] = 1; $R['P2'] = -1; } return $R; } } Šādi nav mazliet saprotamāk un vieglāk rediģējami? Quote Link to comment Share on other sites More sharing options...
Kavacky Posted March 14, 2013 Report Share Posted March 14, 2013 Kas tas par vājprātu? (($R['R3'] - $R['R1']) > 0) ? "+".($R['R3'] - $R['R1']) : ($R['R3'] - $R['R1']) Quote Link to comment Share on other sites More sharing options...
daGrevis Posted March 14, 2013 Report Share Posted March 14, 2013 Haha... PHP. :D Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.