Re: приехали


Автор сообщения: Roger
Дата и время сообщения: 25 October 2004 at 18:41:33:

В ответ на сообщение: Re: поехали... софтина

Ув. d-te,

Надеюсь, вы представляете себе, что rand() выдаёт результат от 0 до 32767 (0x7fff). RAND_МАХ, как не трудно догадаться, также равно 32767. Поэтому threshold в Вашей программе равен 16383, а выражение (rand() < threshold) имеет вероятность 16383/32768 - меньше 1/2. Причём эта ошибка не в пользу казино.

В основном Ваша программа глючит не по этому, а из-за Вашего странного способа вычислять bet. Вероятность того, что bet будет равен players[j] при столь странном его вычислении крайне мала (при players[j]=1 вероятность ненулевой ставки равна 1/32768). Из-за этого Ваша программа быстро скатывается к players[j]=1, молотит миллионы нулевых ставок и лишь изредка заменяет игроков.

Из мелких замечаний - постарайтесь воздержаться от вычислений типа log(0).

С Вашего позволения я заменил несколько строчек в программе.

int threshold = (RAND_MAX+1) * 1 / 2;
...
value = ceil( test = -(PLAYER_VALUE) * log( ((double)rand()+1)/ (RAND_MAX+1) ) );
...
bet = 1+(players[j] * rand()) /(RAND_MAX+1);


А теперь насладитесь результатом:

0049999: casino= 188344, players= 595, common= -188940, losers= 68498 (tst= OK)
0099999: casino= 569114, players= 322, common= -569438, losers= 137553 (tst= OK)

0149999: casino= 949010, players= 379, common= -949390, losers= 206627 (tst= OK)

0199999: casino= 1325054, players= 2792, common= -1327847, losers= 275239 (tst=
OK)
0249999: casino= 1707927, players= 468, common= -1708396, losers= 344394 (tst= O
K)
0299999: casino= 2084167, players= 4874, common= -2089042, losers= 413160 (tst=
OK)
0349999: casino= 1740740, players= 719187, common= -2459928, losers= 480071 (tst
= ERROR)
0399999: casino= 2832461, players= 5189, common= -2837651, losers= 548778 (tst=
OK)
0449999: casino= 3036317, players= 177280, common= -3213598, losers= 616561 (tst
= ERROR)
0499999: casino= 3589101, players= 1265, common= -3590366, losers= 685354 (tst=
OK)
0549999: casino= 3971357, players= 342, common= -3971699, losers= 754833 (tst= O
K)
0599999: casino= 4345585, players= 5795, common= -4351381, losers= 823379 (tst=
OK)
0649999: casino= 4732739, players= 376, common= -4733116, losers= 892147 (tst= O
K)
0699999: casino= 5105171, players= 6591, common= -5111762, losers= 960252 (tst=
OK)
0749999: casino= 5489178, players= 1142, common= -5490320, losers= 1028878 (tst=
OK)
0799999: casino= 5870474, players= 321, common= -5870795, losers= 1098060 (tst=
OK)
0849999: casino= 6253964, players= 326, common= -6254291, losers= 1167591 (tst=
OK)
0899999: casino= 6634563, players= 2788, common= -6637351, losers= 1236174 (tst=
OK)
0949999: casino= 7016293, players= 429, common= -7016723, losers= 1304912 (tst=
OK)
0999999: casino= 7368843, players= 26696, common= -7395540, losers= 1373332 (tst
= OK)
1049999: casino= 7773272, players= 369, common= -7773641, losers= 1442286 (tst=
OK)
1099999: casino= 8089301, players= 65460, common= -8154762, losers= 1511298 (tst
= ERROR)
1149999: casino= 8535178, players= 705, common= -8535884, losers= 1579953 (tst=
OK)
1199999: casino= 8916588, players= 329, common= -8916917, losers= 1648985 (tst=
OK)
1249999: casino= 9293657, players= 2702, common= -9296360, losers= 1717543 (tst=
OK)
1299999: casino= 9673090, players= 3814, common= -9676904, losers= 1786626 (tst=
OK)
1349999: casino= 10052715, players= 2447, common= -10055163, losers= 1855103 (ts
t= OK)
1399999: casino= 10430908, players= 3021, common= -10433929, losers= 1923897 (ts
t= OK)
1449999: casino= 10810581, players= 541, common= -10811122, losers= 1992681 (tst
= OK)
1499999: casino= 11178897, players= 10626, common= -11189523, losers= 2061185 (t
st= OK)
1549999: casino= 11566838, players= 404, common= -11567243, losers= 2129903 (tst
= OK)
1599999: casino= 11948694, players= 758, common= -11949453, losers= 2199002 (tst
= OK)
1649999: casino= 12328671, players= 296, common= -12328968, losers= 2267635 (tst
= OK)
1699999: casino= 12708147, players= 349, common= -12708496, losers= 2336328 (tst
= OK)
1749999: casino= 13090294, players= 315, common= -13090610, losers= 2405457 (tst
= OK)
1799999: casino= 13468757, players= 1816, common= -13470574, losers= 2474235 (ts
t= OK)
1849999: casino= 13851261, players= 396, common= -13851657, losers= 2542810 (tst
= OK)
1899999: casino= 14226973, players= 3957, common= -14230931, losers= 2611523 (ts
t= OK)
1949999: casino= 14609227, players= 323, common= -14609550, losers= 2680494 (tst
= OK)
1999999: casino= 14987665, players= 886, common= -14988551, losers= 2749116 (tst
= OK)
2049999: casino= 15352899, players= 14061, common= -15366961, losers= 2817788 (t
st= OK)
2099999: casino= 15745732, players= 1308, common= -15747041, losers= 2887090 (ts
t= OK)
2149999: casino= 16128918, players= 406, common= -16129324, losers= 2956081 (tst
= OK)
2199999: casino= 16477503, players= 29927, common= -16507430, losers= 3024429 (t
st= OK)
2249999: casino= 16883096, players= 1488, common= -16884585, losers= 3092699 (ts
t= OK)
2299999: casino= 17239309, players= 25354, common= -17264664, losers= 3161462 (t
st= OK)
2349999: casino= 17642869, players= 745, common= -17643615, losers= 3229945 (tst
= OK)
2399999: casino= 18019033, players= 367, common= -18019400, losers= 3298826 (tst
= OK)
2449999: casino= 18229303, players= 163642, common= -18392946, losers= 3366769 (
tst= ERROR)
2499999: casino= 18753672, players= 19771, common= -18773443, losers= 3435937 (t
st= OK)
2549999: casino= 18906217, players= 245736, common= -19151954, losers= 3503441 (
tst= ERROR)
2599999: casino= 19524389, players= 413, common= -19524803, losers= 3571883 (tst
= OK)
2649999: casino= 19901177, players= 1803, common= -19902980, losers= 3640369 (ts
t= OK)
2699999: casino= 18685651, players= 1597887, common= -20283539, losers= 3707921
(tst= ERROR)
2749999: casino= 14192263, players= 6446270, common= -20638534, losers= 3770298
(tst= ERROR)
2799999: casino= 15539756, players= 5440138, common= -20979894, losers= 3831775
(tst= ERROR)
2849999: casino= 21317710, players= 19406, common= -21337116, losers= 3900188 (t
st= OK)
2899999: casino= 17579250, players= 4128183, common= -21707434, losers= 3964250
(tst= ERROR)
2949999: casino= 9743864, players= 12309207, common= -22053072, losers= 4026626
(tst= ERROR)
2999999: casino= 5749443, players= 16646382, common= -22395825, losers= 4088606
(tst= ERROR)
3049999: casino= 6930057, players= 15806032, common= -22736090, losers= 4150154
(tst= ERROR)
3099999: casino= 13158911, players= 9917016, common= -23075928, losers= 4211722
(tst= ERROR)
3149999: casino= 18124601, players= 5292968, common= -23417569, losers= 4274425
(tst= ERROR)
3199999: casino= 20513980, players= 3248779, common= -23762759, losers= 4338031
(tst= ERROR)
3249999: casino= 21367775, players= 2744466, common= -24112241, losers= 4403513
(tst= ERROR)
3299999: casino= 24485364, players= 530, common= -24485894, losers= 4472119 (tst
= OK)
3349999: casino= 24865629, players= 480, common= -24866110, losers= 4541016 (tst
= OK)
3399999: casino= 25246986, players= 558, common= -25247544, losers= 4609824 (tst
= OK)
3449999: casino= 25627384, players= 291, common= -25627676, losers= 4678578 (tst
= OK)
3499999: casino= 26007114, players= 648, common= -26007763, losers= 4747841 (tst
= OK)
3549999: casino= 26368002, players= 18904, common= -26386907, losers= 4816325 (t
st= OK)
3599999: casino= 26764313, players= 1768, common= -26766082, losers= 4884999 (ts
t= OK)
3649999: casino= 27144633, players= 1116, common= -27145750, losers= 4953878 (ts
t= OK)
3699999: casino= 27523317, players= 3066, common= -27526383, losers= 5021965 (ts
t= OK)
3749999: casino= 27903909, players= 416, common= -27904325, losers= 5091083 (tst
= OK)
3799999: casino= 28283633, players= 811, common= -28284444, losers= 5160109 (tst
= OK)
3849999: casino= 28662362, players= 3050, common= -28665413, losers= 5229020 (ts
t= OK)
3899999: casino= 29044065, players= 1343, common= -29045409, losers= 5297159 (ts
t= OK)
3949999: casino= 29416285, players= 7149, common= -29423435, losers= 5365906 (ts
t= OK)
3999999: casino= 29801367, players= 334, common= -29801702, losers= 5434996 (tst
= OK)
4049999: casino= 30061579, players= 118123, common= -30179703, losers= 5503409 (
tst= ERROR)
4099999: casino= 30482121, players= 76747, common= -30558868, losers= 5571925 (t
st= ERROR)
4149999: casino= 22460272, players= 8459952, common= -30920224, losers= 5633828
(tst= ERROR)
4199999: casino= 18897625, players= 12364039, common= -31261665, losers= 5695699
(tst= ERROR)
4249999: casino= 15009981, players= 16592813, common= -31602795, losers= 5757595
(tst= ERROR)
4299999: casino= 16041861, players= 15902054, common= -31943916, losers= 5819919
(tst= ERROR)
4349999: casino= 13303905, players= 18982502, common= -32286407, losers= 5882245
(tst= ERROR)
4399999: casino= 13263688, players= 19364403, common= -32628091, losers= 5944321
(tst= ERROR)
4449999: casino= 11795908, players= 21172996, common= -32968905, losers= 6006458
(tst= ERROR)
4499999: casino= 19774552, players= 13535094, common= -33309646, losers= 6067932
(tst= ERROR)
4549999: casino= 22138334, players= 11512696, common= -33651031, losers= 6130561
(tst= ERROR)
4599999: casino= 21508683, players= 12485223, common= -33993906, losers= 6192905
(tst= ERROR)
4649999: casino= 19298578, players= 15039365, common= -34337944, losers= 6254937
(tst= ERROR)
4699999: casino= 18482910, players= 16197537, common= -34680448, losers= 6316786
(tst= ERROR)
4749999: casino= 5573739, players= 29448003, common= -35021743, losers= 6378880
(tst= ERROR)
4799999: casino= 802136, players= 34559913, common= -35362050, losers= 6440451 (
tst= ERROR)
4849999: casino= -8202185, players= 43904731, common= -35702546, losers= 6502266
(tst= ERROR)
4899999: casino= -9687681, players= 45732008, common= -36044327, losers= 6564144
(tst= ERROR)
4949999: casino= -3377764, play


1807. Возвращение честного шашлычника - Michael 22:41 17.10.04 (223)
К списку тем на странице