Back to project page Divide_And_Conquer_Card_Shuffler.
The source code is released under:
MIT License
If you think the Android project Divide_And_Conquer_Card_Shuffler listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.andrewkeeton.divide.and.conquer.card.shuffler; //w w w . j a va 2 s . c o m public class EstimateTime { /** * moveTypeCounts[deckSize][moveType] gives the number of times moveType occurs when shuffling a * deck of size deckSize. */ public static int moveTypeCounts[][] = { /* {DEAL,PICKUP,BOTTOM} */ {0,0,0}, {0,0,0}, {2,1,0}, {3,1,0}, {4,1,0}, {5,1,0}, {6,1,0}, {7,1,0}, {8,1,0}, {11,2,1}, {14,3,1}, {17,4,1}, {20,5,1}, {23,6,1}, {26,7,1}, {29,8,1}, {32,9,0}, {34,9,0}, {36,9,0}, {38,9,0}, {40,9,0}, {42,9,0}, {44,9,0}, {46,9,0}, {48,9,0}, {50,9,0}, {52,9,0}, {54,9,0}, {56,9,0}, {58,9,0}, {60,9,0}, {62,9,0}, {64,9,0}, {66,9,0}, {68,9,0}, {70,9,0}, {72,9,0}, {74,9,0}, {76,9,0}, {78,9,0}, {80,9,0}, {82,9,0}, {84,9,0}, {86,9,0}, {88,9,0}, {90,9,0}, {92,9,0}, {94,9,0}, {96,9,0}, {98,9,0}, {100,9,0}, {102,9,0}, {104,9,0}, {106,9,0}, {108,9,0}, {110,9,0}, {112,9,0}, {114,9,0}, {116,9,0}, {118,9,0}, {120,9,0}, {122,9,0}, {124,9,0}, {126,9,0}, {128,9,0}, {132,10,1}, {136,11,2}, {140,12,3}, {144,13,4}, {148,14,5}, {152,15,6}, {156,16,7}, {160,17,8}, {164,18,8}, {168,19,8}, {172,20,8}, {176,21,8}, {180,22,8}, {184,23,8}, {188,24,8}, {192,25,8}, {196,26,8}, {200,27,8}, {204,28,8}, {208,29,8}, {212,30,8}, {216,31,8}, {220,32,8}, {224,33,8}, {228,34,8}, {232,35,8}, {236,36,8}, {240,37,8}, {244,38,8}, {248,39,8}, {252,40,8}, {256,41,8}, {260,42,8}, {264,43,8}, {268,44,8}, {272,45,8}, {276,46,8}, {280,47,8}, {284,48,8}, {288,49,8}, {292,50,8}, {296,51,8}, {300,52,8}, {304,53,8}, {308,54,8}, {312,55,8}, {316,56,8}, {320,57,8}, {324,58,8}, {328,59,8}, {332,60,8}, {336,61,8}, {340,62,8}, {344,63,8}, {348,64,8}, {352,65,8}, {356,66,7}, {360,67,6}, {364,68,5}, {368,69,4}, {372,70,3}, {376,71,2}, {380,72,1}, {384,73,0}, {387,73,0}, {390,73,0}, {393,73,0}, {396,73,0}, {399,73,0}, {402,73,0}, {405,73,0}, {408,73,0}, {411,73,0}, {414,73,0}, {417,73,0}, {420,73,0}, {423,73,0}, {426,73,0}, {429,73,0}, {432,73,0}, {435,73,0}, {438,73,0}, {441,73,0}, {444,73,0}, {447,73,0}, {450,73,0}, {453,73,0}, {456,73,0}, {459,73,0}, {462,73,0}, {465,73,0}, {468,73,0}, {471,73,0}, {474,73,0}, {477,73,0}, {480,73,0}, {483,73,0}, {486,73,0}, {489,73,0}, {492,73,0}, {495,73,0}, {498,73,0}, {501,73,0}, {504,73,0}, {507,73,0}, {510,73,0}, {513,73,0}, {516,73,0}, {519,73,0}, {522,73,0}, {525,73,0}, {528,73,0}, {531,73,0}, {534,73,0}, {537,73,0}, {540,73,0}, {543,73,0}, {546,73,0}, {549,73,0}, {552,73,0}, {555,73,0}, {558,73,0}, {561,73,0}, {564,73,0}, {567,73,0}, {570,73,0}, {573,73,0}, {576,73,0}, {579,73,0}, {582,73,0}, {585,73,0}, {588,73,0}, {591,73,0}, {594,73,0}, {597,73,0}, {600,73,0}, {603,73,0}, {606,73,0}, {609,73,0}, {612,73,0}, {615,73,0}, {618,73,0}, {621,73,0}, {624,73,0}, {627,73,0}, {630,73,0}, {633,73,0}, {636,73,0}, {639,73,0}, {642,73,0}, {645,73,0}, {648,73,0}, {651,73,0}, {654,73,0}, {657,73,0}, {660,73,0}, {663,73,0}, {666,73,0}, {669,73,0}, {672,73,0}, {675,73,0}, {678,73,0}, {681,73,0}, {684,73,0}, {687,73,0}, {690,73,0}, {693,73,0}, {696,73,0}, {699,73,0}, {702,73,0}, {705,73,0}, {708,73,0}, {711,73,0}, {714,73,0}, {717,73,0}, {720,73,0}, {723,73,0}, {726,73,0}, {729,73,0}, {732,73,0}, {735,73,0}, {738,73,0}, {741,73,0}, {744,73,0}, {747,73,0}, {750,73,0}, {753,73,0}, {756,73,0}, {759,73,0}, {762,73,0}, {765,73,0}, {768,73,0}, {771,73,0}, {774,73,0}, {777,73,0}, {780,73,0}, {783,73,0}, {786,73,0}, {789,73,0}, {792,73,0}, {795,73,0}, {798,73,0}, {801,73,0}, {804,73,0}, {807,73,0}, {810,73,0}, {813,73,0}, {816,73,0}, {819,73,0}, {822,73,0}, {825,73,0}, {828,73,0}, {831,73,0}, {834,73,0}, {837,73,0}, {840,73,0}, {843,73,0}, {846,73,0}, {849,73,0}, {852,73,0}, {855,73,0}, {858,73,0}, {861,73,0}, {864,73,0}, {867,73,0}, {870,73,0}, {873,73,0}, {876,73,0}, {879,73,0}, {882,73,0}, {885,73,0}, {888,73,0}, {891,73,0}, {894,73,0}, {897,73,0}, {900,73,0}, {903,73,0}, {906,73,0}, {909,73,0}, {912,73,0}, {915,73,0}, {918,73,0}, {921,73,0}, {924,73,0}, {927,73,0}, {930,73,0}, {933,73,0}, {936,73,0}, {939,73,0}, {942,73,0}, {945,73,0}, {948,73,0}, {951,73,0}, {954,73,0}, {957,73,0}, {960,73,0}, {963,73,0}, {966,73,0}, {969,73,0}, {972,73,0}, {975,73,0}, {978,73,0}, {981,73,0}, {984,73,0}, {987,73,0}, {990,73,0}, {993,73,0}, {996,73,0}, {999,73,0}, {1002,73,0}, {1005,73,0}, {1008,73,0}, {1011,73,0}, {1014,73,0}, {1017,73,0}, {1020,73,0}, {1023,73,0}, {1026,73,0}, {1029,73,0}, {1032,73,0}, {1035,73,0}, {1038,73,0}, {1041,73,0}, {1044,73,0}, {1047,73,0}, {1050,73,0}, {1053,73,0}, {1056,73,0}, {1059,73,0}, {1062,73,0}, {1065,73,0}, {1068,73,0}, {1071,73,0}, {1074,73,0}, {1077,73,0}, {1080,73,0}, {1083,73,0}, {1086,73,0}, {1089,73,0}, {1092,73,0}, {1095,73,0}, {1098,73,0}, {1101,73,0}, {1104,73,0}, {1107,73,0}, {1110,73,0}, {1113,73,0}, {1116,73,0}, {1119,73,0}, {1122,73,0}, {1125,73,0}, {1128,73,0}, {1131,73,0}, {1134,73,0}, {1137,73,0}, {1140,73,0}, {1143,73,0}, {1146,73,0}, {1149,73,0}, {1152,73,0}, {1155,73,0}, {1158,73,0}, {1161,73,0}, {1164,73,0}, {1167,73,0}, {1170,73,0}, {1173,73,0}, {1176,73,0}, {1179,73,0}, {1182,73,0}, {1185,73,0}, {1188,73,0}, {1191,73,0}, {1194,73,0}, {1197,73,0}, {1200,73,0}, {1203,73,0}, {1206,73,0}, {1209,73,0}, {1212,73,0}, {1215,73,0}, {1218,73,0}, {1221,73,0}, {1224,73,0}, {1227,73,0}, {1230,73,0}, {1233,73,0}, {1236,73,0}, {1239,73,0}, {1242,73,0}, {1245,73,0}, {1248,73,0}, {1251,73,0}, {1254,73,0}, {1257,73,0}, {1260,73,0}, {1263,73,0}, {1266,73,0}, {1269,73,0}, {1272,73,0}, {1275,73,0}, {1278,73,0}, {1281,73,0}, {1284,73,0}, {1287,73,0}, {1290,73,0}, {1293,73,0}, {1296,73,0}, {1299,73,0}, {1302,73,0}, {1305,73,0}, {1308,73,0}, {1311,73,0}, {1314,73,0}, {1317,73,0}, {1320,73,0}, {1323,73,0}, {1326,73,0}, {1329,73,0}, {1332,73,0}, {1335,73,0}, {1338,73,0}, {1341,73,0}, {1344,73,0}, {1347,73,0}, {1350,73,0}, {1353,73,0}, {1356,73,0}, {1359,73,0}, {1362,73,0}, {1365,73,0}, {1368,73,0}, {1371,73,0}, {1374,73,0}, {1377,73,0}, {1380,73,0}, {1383,73,0}, {1386,73,0}, {1389,73,0}, {1392,73,0}, {1395,73,0}, {1398,73,0}, {1401,73,0}, {1404,73,0}, {1407,73,0}, {1410,73,0}, {1413,73,0}, {1416,73,0}, {1419,73,0}, {1422,73,0}, {1425,73,0}, {1428,73,0}, {1431,73,0}, {1434,73,0}, {1437,73,0}, {1440,73,0}, {1443,73,0}, {1446,73,0}, {1449,73,0}, {1452,73,0}, {1455,73,0}, {1458,73,0}, {1461,73,0}, {1464,73,0}, {1467,73,0}, {1470,73,0}, {1473,73,0}, {1476,73,0}, {1479,73,0}, {1482,73,0}, {1485,73,0}, {1488,73,0}, {1491,73,0}, {1494,73,0}, {1497,73,0}, {1500,73,0}, {1503,73,0}, {1506,73,0}, {1509,73,0}, {1512,73,0}, {1515,73,0}, {1518,73,0}, {1521,73,0}, {1524,73,0}, {1527,73,0}, {1530,73,0}, {1533,73,0}, {1536,73,0}, {1541,74,1}, {1546,75,2}, {1551,76,3}, {1556,77,4}, {1561,78,5}, {1566,79,6}, {1571,80,7}, {1576,81,8}, {1581,82,9}, {1586,83,10}, {1591,84,11}, {1596,85,12}, {1601,86,13}, {1606,87,14}, {1611,88,15}, {1616,89,16}, {1621,90,17}, {1626,91,18}, {1631,92,19}, {1636,93,20}, {1641,94,21}, {1646,95,22}, {1651,96,23}, {1656,97,24}, {1661,98,25}, {1666,99,26}, {1671,100,27}, {1676,101,28}, {1681,102,29}, {1686,103,30}, {1691,104,31}, {1696,105,32}, {1701,106,33}, {1706,107,34}, {1711,108,35}, {1716,109,36}, {1721,110,37}, {1726,111,38}, {1731,112,39}, {1736,113,40}, {1741,114,41}, {1746,115,42}, {1751,116,43}, {1756,117,44}, {1761,118,45}, {1766,119,46}, {1771,120,47}, {1776,121,48}, {1781,122,49}, {1786,123,50}, {1791,124,51}, {1796,125,52}, {1801,126,53}, {1806,127,54}, {1811,128,55}, {1816,129,56}, {1821,130,57}, {1826,131,58}, {1831,132,59}, {1836,133,60}, {1841,134,61}, {1846,135,62}, {1851,136,63}, {1856,137,64}, {1861,138,64}, {1866,139,64}, {1871,140,64}, {1876,141,64}, {1881,142,64}, {1886,143,64}, {1891,144,64}, {1896,145,64}, {1901,146,64}, {1906,147,64}, {1911,148,64}, {1916,149,64}, {1921,150,64}, {1926,151,64}, {1931,152,64}, {1936,153,64}, {1941,154,64}, {1946,155,64}, {1951,156,64}, {1956,157,64}, {1961,158,64}, {1966,159,64}, {1971,160,64}, {1976,161,64}, {1981,162,64}, {1986,163,64}, {1991,164,64}, {1996,165,64}, {2001,166,64}, {2006,167,64}, {2011,168,64}, {2016,169,64}, {2021,170,64}, {2026,171,64}, {2031,172,64}, {2036,173,64}, {2041,174,64}, {2046,175,64}, {2051,176,64}, {2056,177,64}, {2061,178,64}, {2066,179,64}, {2071,180,64}, {2076,181,64}, {2081,182,64}, {2086,183,64}, {2091,184,64}, {2096,185,64}, {2101,186,64}, {2106,187,64}, {2111,188,64}, {2116,189,64}, {2121,190,64}, {2126,191,64}, {2131,192,64}, {2136,193,64}, {2141,194,64}, {2146,195,64}, {2151,196,64}, {2156,197,64}, {2161,198,64}, {2166,199,64}, {2171,200,64}, {2176,201,64}, {2181,202,64}, {2186,203,64}, {2191,204,64}, {2196,205,64}, {2201,206,64}, {2206,207,64}, {2211,208,64}, {2216,209,64}, {2221,210,64}, {2226,211,64}, {2231,212,64}, {2236,213,64}, {2241,214,64}, {2246,215,64}, {2251,216,64}, {2256,217,64}, {2261,218,64}, {2266,219,64}, {2271,220,64}, {2276,221,64}, {2281,222,64}, {2286,223,64}, {2291,224,64}, {2296,225,64}, {2301,226,64}, {2306,227,64}, {2311,228,64}, {2316,229,64}, {2321,230,64}, {2326,231,64}, {2331,232,64}, {2336,233,64}, {2341,234,64}, {2346,235,64}, {2351,236,64}, {2356,237,64}, {2361,238,64}, {2366,239,64}, {2371,240,64}, {2376,241,64}, {2381,242,64}, {2386,243,64}, {2391,244,64}, {2396,245,64}, {2401,246,64}, {2406,247,64}, {2411,248,64}, {2416,249,64}, {2421,250,64}, {2426,251,64}, {2431,252,64}, {2436,253,64}, {2441,254,64}, {2446,255,64}, {2451,256,64}, {2456,257,64}, {2461,258,64}, {2466,259,64}, {2471,260,64}, {2476,261,64}, {2481,262,64}, {2486,263,64}, {2491,264,64}, {2496,265,64}, {2501,266,64}, {2506,267,64}, {2511,268,64}, {2516,269,64}, {2521,270,64}, {2526,271,64}, {2531,272,64}, {2536,273,64}, {2541,274,64}, {2546,275,64}, {2551,276,64}, {2556,277,64}, {2561,278,64}, {2566,279,64}, {2571,280,64}, {2576,281,64}, {2581,282,64}, {2586,283,64}, {2591,284,64}, {2596,285,64}, {2601,286,64}, {2606,287,64}, {2611,288,64}, {2616,289,64}, {2621,290,64}, {2626,291,64}, {2631,292,64}, {2636,293,64}, {2641,294,64}, {2646,295,64}, {2651,296,64}, {2656,297,64}, {2661,298,64}, {2666,299,64}, {2671,300,64}, {2676,301,64}, {2681,302,64}, {2686,303,64}, {2691,304,64}, {2696,305,64}, {2701,306,64}, {2706,307,64}, {2711,308,64}, {2716,309,64}, {2721,310,64}, {2726,311,64}, {2731,312,64}, {2736,313,64}, {2741,314,64}, {2746,315,64}, {2751,316,64}, {2756,317,64}, {2761,318,64}, {2766,319,64}, {2771,320,64}, {2776,321,64}, {2781,322,64}, {2786,323,64}, {2791,324,64}, {2796,325,64}, {2801,326,64}, {2806,327,64}, {2811,328,64}, {2816,329,64}, {2821,330,64}, {2826,331,64}, {2831,332,64}, {2836,333,64}, {2841,334,64}, {2846,335,64}, {2851,336,64}, {2856,337,64}, {2861,338,64}, {2866,339,64}, {2871,340,64}, {2876,341,64}, {2881,342,64}, {2886,343,64}, {2891,344,64}, {2896,345,64}, {2901,346,64}, {2906,347,64}, {2911,348,64}, {2916,349,64}, {2921,350,64}, {2926,351,64}, {2931,352,64}, {2936,353,64}, {2941,354,64}, {2946,355,64}, {2951,356,64}, {2956,357,64}, {2961,358,64}, {2966,359,64}, {2971,360,64}, {2976,361,64}, {2981,362,64}, {2986,363,64}, {2991,364,64}, {2996,365,64}, {3001,366,64}, {3006,367,64}, {3011,368,64}, {3016,369,64}, {3021,370,64}, {3026,371,64}, {3031,372,64}, {3036,373,64}, {3041,374,64}, {3046,375,64}, {3051,376,64}, {3056,377,64}, {3061,378,64}, {3066,379,64}, {3071,380,64}, {3076,381,64}, {3081,382,64}, {3086,383,64}, {3091,384,64}, {3096,385,64}, {3101,386,64}, {3106,387,64}, {3111,388,64}, {3116,389,64}, {3121,390,64}, {3126,391,64}, {3131,392,64}, {3136,393,64}, {3141,394,64}, {3146,395,64}, {3151,396,64}, {3156,397,64}, {3161,398,64}, {3166,399,64}, {3171,400,64}, {3176,401,64}, {3181,402,64}, {3186,403,64}, {3191,404,64}, {3196,405,64}, {3201,406,64}, {3206,407,64}, {3211,408,64}, {3216,409,64}, {3221,410,64}, {3226,411,64}, {3231,412,64}, {3236,413,64}, {3241,414,64}, {3246,415,64}, {3251,416,64}, {3256,417,64}, {3261,418,64}, {3266,419,64}, {3271,420,64}, {3276,421,64}, {3281,422,64}, {3286,423,64}, {3291,424,64}, {3296,425,64}, {3301,426,64}, {3306,427,64}, {3311,428,64}, {3316,429,64}, {3321,430,64}, {3326,431,64}, {3331,432,64}, {3336,433,64}, {3341,434,64}, {3346,435,64}, {3351,436,64}, {3356,437,64}, {3361,438,64}, {3366,439,64}, {3371,440,64}, {3376,441,64}, {3381,442,64}, {3386,443,64}, {3391,444,64}, {3396,445,64}, {3401,446,64}, {3406,447,64}, {3411,448,64}, {3416,449,64}, {3421,450,64}, {3426,451,64}, {3431,452,64}, {3436,453,64}, {3441,454,64}, {3446,455,64}, {3451,456,64}, {3456,457,64}, {3461,458,64}, {3466,459,64}, {3471,460,64}, {3476,461,64}, {3481,462,64}, {3486,463,64}, {3491,464,64}, {3496,465,64}, {3501,466,64}, {3506,467,64}, {3511,468,64}, {3516,469,64}, {3521,470,64}, {3526,471,64}, {3531,472,64}, {3536,473,64}, {3541,474,64}, {3546,475,64}, {3551,476,64}, {3556,477,64}, {3561,478,64}, {3566,479,64}, {3571,480,64}, {3576,481,64}, {3581,482,64}, {3586,483,64}, {3591,484,64}, {3596,485,64}, {3601,486,64}, {3606,487,64}, {3611,488,64}, {3616,489,64}, {3621,490,64}, {3626,491,64}, {3631,492,64}, {3636,493,64}, {3641,494,64}, {3646,495,64}, {3651,496,64}, {3656,497,64}, {3661,498,64}, {3666,499,64}, {3671,500,64}, {3676,501,64}, {3681,502,64}, {3686,503,64}, {3691,504,64}, {3696,505,64}, {3701,506,64}, {3706,507,64}, {3711,508,64}, {3716,509,64}, {3721,510,64}, {3726,511,64}, {3731,512,64}, {3736,513,64}, {3741,514,64}, {3746,515,64}, {3751,516,64}, {3756,517,64}, {3761,518,64}, {3766,519,64}, {3771,520,64}, {3776,521,64}, {3781,522,63}, {3786,523,62}, {3791,524,61}, {3796,525,60}, {3801,526,59}, {3806,527,58}, {3811,528,57}, {3816,529,56}, {3821,530,55}, {3826,531,54}, {3831,532,53}, {3836,533,52}, {3841,534,51}, {3846,535,50}, {3851,536,49}, {3856,537,48}, {3861,538,47}, {3866,539,46}, {3871,540,45}, {3876,541,44}, {3881,542,43}, {3886,543,42}, {3891,544,41}, {3896,545,40}, {3901,546,39}, {3906,547,38}, {3911,548,37}, {3916,549,36}, {3921,550,35}, {3926,551,34}, {3931,552,33}, {3936,553,32}, {3941,554,31}, {3946,555,30}, {3951,556,29}, {3956,557,28}, {3961,558,27}, {3966,559,26}, {3971,560,25}, }; public static final int TIME_MILLIS_PICKUP = 8000; public static final int TIME_MILLIS_BOTTOM = 6000; public static int estimatedTimeMillis(int deckSize, long periodDelayMillis) { int timeMillis = 0; int counts[] = moveTypeCounts[deckSize]; int numDeals = counts[0]; int numPickups = counts[1]; int numBottoms = counts[2]; timeMillis += numDeals * periodDelayMillis; // Deals timeMillis += numPickups * TIME_MILLIS_PICKUP; // Pickups timeMillis += numPickups * ShufflerFragment.DELAY_COUNTDOWN * 3; // Countdowns timeMillis += numBottoms * TIME_MILLIS_BOTTOM; // Bottoms return timeMillis; } public static int estimatedTimeMinutes(int deckSize, long periodDelayMillis) { double timeMillis = (double) estimatedTimeMillis(deckSize, periodDelayMillis); int timeMinutes = (int) Math.ceil(timeMillis / 1000.0d / 60.0d); return timeMinutes; } }