変愚蛮怒のメインリポジトリです
修訂 | 40ed37984772aec7ddce90d17c1d01ae30f60ade (tree) |
---|---|
時間 | 2017-09-14 22:03:41 |
作者 | Deskull <desull@user...> |
Commiter | Deskull |
hradishさんから寄稿してもらったオートローラーのブランチ。 / Branch auto-roller by hradish.
@@ -21,7 +21,7 @@ | ||
21 | 21 | * system may have problems because the user can't stop the |
22 | 22 | * autoroller for this number of rolls. |
23 | 23 | */ |
24 | -#define AUTOROLLER_STEP 5431L | |
24 | +#define AUTOROLLER_STEP 54321L | |
25 | 25 | |
26 | 26 | #if 0 |
27 | 27 | /*! |
@@ -2046,6 +2046,9 @@ static cptr realm_subinfo[VALID_REALM] = | ||
2046 | 2046 | /*! オートローラの能力値的要求水準 / Autoroll limit */ |
2047 | 2047 | static s16b stat_limit[6]; |
2048 | 2048 | |
2049 | +/*! オートローラの要求値実現確率 */ | |
2050 | +static s32b autoroll_chance; | |
2051 | + | |
2049 | 2052 | /*! オートローラの年齢、身長、体重、社会的地位の要求水準 */ |
2050 | 2053 | static struct { |
2051 | 2054 | s16b agemin, agemax; |
@@ -2054,11 +2057,20 @@ static struct { | ||
2054 | 2057 | s16b scmin, scmax; |
2055 | 2058 | } chara_limit; |
2056 | 2059 | |
2057 | -/*! オートローラ中、各能力値が水準を超えた回数 / Autoroll matches */ | |
2058 | -static s32b stat_match[6]; | |
2059 | - | |
2060 | 2060 | /*! オートローラの試行回数 / Autoroll round */ |
2061 | 2061 | static s32b auto_round; |
2062 | +static s32b auto_round2; | |
2063 | + | |
2064 | +/* emulate 5 + 1d3 + 1d4 + 1d5 by randint0(60) */ | |
2065 | +const int rand3_4_5[60] = | |
2066 | +{ | |
2067 | + 8, 9, 9, 9, 10, 10, 10, 10, 10, 10, /*00-09*/ | |
2068 | + 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, /*10-19*/ | |
2069 | + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, /*20-29*/ | |
2070 | + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, /*30-49*/ | |
2071 | + 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, /*40-49*/ | |
2072 | + 15, 15, 15, 15, 15, 15, 16, 16, 16, 17 /*50-59*/ | |
2073 | +}; | |
2062 | 2074 | |
2063 | 2075 | /*! |
2064 | 2076 | * @brief プレイヤー作成を中断して変愚蛮怒を終了する |
@@ -2676,48 +2688,45 @@ static void get_stats(void) | ||
2676 | 2688 | while (TRUE) |
2677 | 2689 | { |
2678 | 2690 | int i; |
2691 | + int j = 0; | |
2679 | 2692 | int sum = 0; |
2680 | - | |
2693 | + int val; | |
2694 | + s32b tmp; | |
2681 | 2695 | /* Roll some dice */ |
2682 | 2696 | for (i = 0; i < 2; i++) |
2683 | 2697 | { |
2684 | - s32b tmp = randint0(60*60*60); | |
2685 | - int val; | |
2698 | + /* randint0(60*60*60) for 3 stats. */ | |
2699 | + tmp = randint0(216000); | |
2686 | 2700 | |
2687 | 2701 | /* Extract 5 + 1d3 + 1d4 + 1d5 */ |
2688 | - val = 5 + 3; | |
2689 | - val += tmp % 3; tmp /= 3; | |
2690 | - val += tmp % 4; tmp /= 4; | |
2691 | - val += tmp % 5; tmp /= 5; | |
2702 | + val = rand3_4_5[tmp % 60]; | |
2692 | 2703 | |
2693 | 2704 | /* Save that value */ |
2694 | 2705 | sum += val; |
2695 | - p_ptr->stat_cur[3*i] = p_ptr->stat_max[3*i] = val; | |
2706 | + p_ptr->stat_cur[j] = p_ptr->stat_max[j] = val; | |
2707 | + j++; | |
2696 | 2708 | |
2709 | + tmp /= 60; | |
2697 | 2710 | /* Extract 5 + 1d3 + 1d4 + 1d5 */ |
2698 | - val = 5 + 3; | |
2699 | - val += tmp % 3; tmp /= 3; | |
2700 | - val += tmp % 4; tmp /= 4; | |
2701 | - val += tmp % 5; tmp /= 5; | |
2711 | + val = rand3_4_5[tmp % 60]; | |
2702 | 2712 | |
2703 | 2713 | /* Save that value */ |
2704 | 2714 | sum += val; |
2705 | - p_ptr->stat_cur[3*i+1] = p_ptr->stat_max[3*i+1] = val; | |
2715 | + p_ptr->stat_cur[j] = p_ptr->stat_max[j] = val; | |
2716 | + j++; | |
2706 | 2717 | |
2718 | + tmp /= 60; | |
2707 | 2719 | /* Extract 5 + 1d3 + 1d4 + 1d5 */ |
2708 | - val = 5 + 3; | |
2709 | - val += tmp % 3; tmp /= 3; | |
2710 | - val += tmp % 4; tmp /= 4; | |
2711 | - val += tmp; | |
2720 | + val = rand3_4_5[tmp]; | |
2712 | 2721 | |
2713 | 2722 | /* Save that value */ |
2714 | 2723 | sum += val; |
2715 | - p_ptr->stat_cur[3*i+2] = p_ptr->stat_max[3*i+2] = val; | |
2724 | + p_ptr->stat_cur[j] = p_ptr->stat_max[j] = val; | |
2725 | + j++; | |
2716 | 2726 | } |
2717 | 2727 | |
2718 | 2728 | /* Verify totals */ |
2719 | - if ((sum > 42+5*6) && (sum < 57+5*6)) break; | |
2720 | - /* 57 was 54... I hate 'magic numbers' :< TY */ | |
2729 | + if ((sum > 72) && (sum < 87)) break; | |
2721 | 2730 | } |
2722 | 2731 | } |
2723 | 2732 |
@@ -3165,15 +3174,14 @@ static void get_money(void) | ||
3165 | 3174 | */ |
3166 | 3175 | static void birth_put_stats(void) |
3167 | 3176 | { |
3168 | - int i, j, m, p; | |
3177 | + int i, j, m; | |
3169 | 3178 | int col; |
3170 | - byte attr; | |
3171 | 3179 | char buf[80]; |
3172 | 3180 | |
3173 | 3181 | |
3174 | 3182 | if (autoroller) |
3175 | 3183 | { |
3176 | - col = 42; | |
3184 | + col = 22; | |
3177 | 3185 | /* Put the stats (and percents) */ |
3178 | 3186 | for (i = 0; i < 6; i++) |
3179 | 3187 | { |
@@ -3186,35 +3194,6 @@ static void birth_put_stats(void) | ||
3186 | 3194 | /* Put the stat */ |
3187 | 3195 | cnv_stat(m, buf); |
3188 | 3196 | c_put_str(TERM_L_GREEN, buf, 3+i, col+24); |
3189 | - | |
3190 | - /* Put the percent */ | |
3191 | - if (stat_match[i]) | |
3192 | - { | |
3193 | - if (stat_match[i] > 1000000L) | |
3194 | - { | |
3195 | - /* Prevent overflow */ | |
3196 | - p = stat_match[i] / (auto_round / 1000L); | |
3197 | - } | |
3198 | - else | |
3199 | - { | |
3200 | - p = 1000L * stat_match[i] / auto_round; | |
3201 | - } | |
3202 | - | |
3203 | - attr = (p < 100) ? TERM_YELLOW : TERM_L_GREEN; | |
3204 | - sprintf(buf, "%3d.%d%%", p/10, p%10); | |
3205 | - c_put_str(attr, buf, 3+i, col+13); | |
3206 | - } | |
3207 | - | |
3208 | - /* Never happened */ | |
3209 | - else | |
3210 | - { | |
3211 | -#ifdef JP | |
3212 | - c_put_str(TERM_RED, "(なし)", 3+i, col+13); | |
3213 | -#else | |
3214 | - c_put_str(TERM_RED, "(NONE)", 3+i, col+13); | |
3215 | -#endif | |
3216 | - | |
3217 | - } | |
3218 | 3197 | } |
3219 | 3198 | } |
3220 | 3199 | } |
@@ -4807,6 +4786,83 @@ static bool get_player_seikaku(void) | ||
4807 | 4786 | return TRUE; |
4808 | 4787 | } |
4809 | 4788 | |
4789 | +/* | |
4790 | + calc. probability of satisfying the required status set | |
4791 | + return : inverted prob. / 100 | |
4792 | +*/ | |
4793 | +static s32b get_autoroller_prob(int *minval){ | |
4794 | + | |
4795 | + /* 1 percent of the valid random space (60^6 && 72<sum<87) */ | |
4796 | + s32b tot_rand_1p = 320669745; | |
4797 | + int i, j, tmp; | |
4798 | + int ii[6]; | |
4799 | + int tval[6]; | |
4800 | + int tot = 0; | |
4801 | + /* success count */ | |
4802 | + s32b succ = 0; | |
4803 | + /* random combinations out of 60 (1d3+1d4+1d5) patterns */ | |
4804 | + int pp[18] = | |
4805 | + { | |
4806 | + 0, 0, 0, 0, 0, 0, 0, 0, /* 0-7 */ | |
4807 | + 1, 3, 6, 9, 11, 11, 9, 6, 3, 1 /* 8-17 */ | |
4808 | + }; | |
4809 | + | |
4810 | + /* Copy */ | |
4811 | + for(i = 0; i < 6; i++) | |
4812 | + { | |
4813 | + tval[i] = MAX(8, minval[i]); | |
4814 | + tot += tval[i]; | |
4815 | + } | |
4816 | + | |
4817 | + /* No Chance */ | |
4818 | + if(tot > 86) return -999; | |
4819 | + | |
4820 | + /* bubble sort for speed-up */ | |
4821 | + for(i = 0; i < 5; i++) | |
4822 | + { | |
4823 | + for(j = 5; j > i; j--) | |
4824 | + { | |
4825 | + if(tval[j-1] < tval[j]) | |
4826 | + { | |
4827 | + tmp = tval[j-1]; | |
4828 | + tval[j-1] = tval[j]; | |
4829 | + tval[j] = tmp; | |
4830 | + } | |
4831 | + } | |
4832 | + } | |
4833 | + | |
4834 | + tot = 0; | |
4835 | + | |
4836 | + /* calc. prob. */ | |
4837 | + for(ii[0] = tval[0]; ii[0] < 18; ii[0]++) | |
4838 | + { | |
4839 | + for(ii[1] = tval[1]; ii[1] < 18; ii[1]++) | |
4840 | + { | |
4841 | + for(ii[2] = tval[2]; ii[2] < 18; ii[2]++) | |
4842 | + { | |
4843 | + for(ii[3] = tval[3]; ii[3] < 18; ii[3]++) | |
4844 | + { | |
4845 | + for(ii[4] = tval[4]; ii[4] < 18; ii[4]++) | |
4846 | + { | |
4847 | + for(ii[5] = tval[5]; ii[5] < 18; ii[5]++) | |
4848 | + { | |
4849 | + tot = ii[0] + ii[1] + ii[2] + ii[3] + ii[4] + ii[5]; | |
4850 | + if(tot > 86) break; | |
4851 | + if(tot <= 72) continue; | |
4852 | + succ += ( pp[ii[0]] * pp[ii[1]] * pp[ii[2]] * pp[ii[3]] * pp[ii[4]] * pp[ii[5]] ); | |
4853 | + /* If given condition is easy enough, quit calc. to save CPU. */ | |
4854 | + if(succ > 320670) return -1; | |
4855 | + } | |
4856 | + } | |
4857 | + } | |
4858 | + } | |
4859 | + } | |
4860 | + } | |
4861 | + | |
4862 | + return tot_rand_1p / succ; | |
4863 | +} | |
4864 | + | |
4865 | + | |
4810 | 4866 | #ifdef ALLOW_AUTOROLLER |
4811 | 4867 | /*! |
4812 | 4868 | * @brief オートローラで得たい能力値の基準を決める。 |
@@ -4838,11 +4894,15 @@ static bool get_stat_limits(void) | ||
4838 | 4894 | put_str(" Base Rac Cla Per Total Maximum", 13, 10); |
4839 | 4895 | #endif |
4840 | 4896 | |
4897 | +#ifdef JP | |
4898 | + put_str(" 確率: 非常に容易(1/10000以上)", 23, 10); | |
4899 | +#else | |
4900 | + put_str(" Prob: Quite Easy(>1/10000)", 23, 10); | |
4901 | +#endif | |
4841 | 4902 | /* Output the maximum stats */ |
4842 | 4903 | for (i = 0; i < 6; i++) |
4843 | 4904 | { |
4844 | 4905 | /* Reset the "success" counter */ |
4845 | - stat_match[i] = 0; | |
4846 | 4906 | cval[i] = 3; |
4847 | 4907 | |
4848 | 4908 | /* Race/Class bonus */ |
@@ -4911,7 +4971,22 @@ static bool get_stat_limits(void) | ||
4911 | 4971 | /* Move Cursol */ |
4912 | 4972 | if (cs != os) |
4913 | 4973 | { |
4914 | - if(os == 6) | |
4974 | + if(os == 7) | |
4975 | + { | |
4976 | + autoroll_chance = get_autoroller_prob(cval); | |
4977 | + | |
4978 | +#ifdef JP | |
4979 | + if(autoroll_chance == -999) sprintf(buf, " 確率: 不可能(合計86超) "); | |
4980 | + else if(autoroll_chance < 1) sprintf(buf, " 確率: 非常に容易(1/10000以上)"); | |
4981 | + else sprintf(buf, " 確率: 約 1/%8d00 ", autoroll_chance); | |
4982 | +#else | |
4983 | + if(autoroll_chance == -999) sprintf(buf, " Prob: Impossible(>86 tot stats)"); | |
4984 | + else if(autoroll_chance < 1) sprintf(buf, " Prob: Quite Easy(>1/10000) "); | |
4985 | + else sprintf(buf, " Prob: ~ 1/%8d00 ", autoroll_chance); | |
4986 | +#endif | |
4987 | + put_str(buf,23,10); | |
4988 | + } | |
4989 | + else if(os == 6) | |
4915 | 4990 | { |
4916 | 4991 | #ifdef JP |
4917 | 4992 | c_put_str(TERM_WHITE, "決定する", 21, 35); |
@@ -5060,7 +5135,7 @@ static bool get_stat_limits(void) | ||
5060 | 5135 | bell(); |
5061 | 5136 | break; |
5062 | 5137 | } |
5063 | - if(c == ESCAPE || ((c == ' ' || c == '\r' || c == '\n') && cs == 6))break; | |
5138 | + if(c == ESCAPE || ((c == ' ' || c == '\r' || c == '\n') && cs == 6 && autoroll_chance != -999))break; | |
5064 | 5139 | } |
5065 | 5140 | |
5066 | 5141 | for (i = 0; i < 6; i++) |
@@ -6041,6 +6116,8 @@ static bool player_birth_aux(void) | ||
6041 | 6116 | { |
6042 | 6117 | /* Clear fields */ |
6043 | 6118 | auto_round = 0L; |
6119 | + auto_round2 = 0L; | |
6120 | + autoroll_chance = -1L; | |
6044 | 6121 | } |
6045 | 6122 | |
6046 | 6123 | /* Initialize */ |
@@ -6069,7 +6146,7 @@ static bool player_birth_aux(void) | ||
6069 | 6146 | { |
6070 | 6147 | int col; |
6071 | 6148 | |
6072 | - col = 42; | |
6149 | + col = 22; | |
6073 | 6150 | |
6074 | 6151 | if (autoroller || autochara) |
6075 | 6152 | { |
@@ -6077,17 +6154,16 @@ static bool player_birth_aux(void) | ||
6077 | 6154 | |
6078 | 6155 | /* Label count */ |
6079 | 6156 | #ifdef JP |
6080 | - put_str("回数 :", 10, col+13); | |
6157 | + put_str("回数 :", 10, col+10); | |
6081 | 6158 | #else |
6082 | - put_str("Round:", 10, col+13); | |
6159 | + put_str("Round:", 10, col+10); | |
6083 | 6160 | #endif |
6084 | 6161 | |
6085 | - | |
6086 | 6162 | /* Indicate the state */ |
6087 | 6163 | #ifdef JP |
6088 | - put_str("(ESCで停止)", 12, col+13); | |
6164 | + put_str("(ESCで停止)", 13, col+13); | |
6089 | 6165 | #else |
6090 | - put_str("(Hit ESC to stop)", 12, col+13); | |
6166 | + put_str("(Hit ESC to stop)", 13, col+13); | |
6091 | 6167 | #endif |
6092 | 6168 | } |
6093 | 6169 |
@@ -6109,35 +6185,48 @@ static bool player_birth_aux(void) | ||
6109 | 6185 | { |
6110 | 6186 | /* Label */ |
6111 | 6187 | #ifdef JP |
6112 | - put_str("最小値", 2, col+5); | |
6188 | + put_str("最小値", 2, col+13); | |
6113 | 6189 | #else |
6114 | - put_str(" Limit", 2, col+5); | |
6190 | + put_str(" Limit", 2, col+13); | |
6115 | 6191 | #endif |
6116 | 6192 | |
6117 | - | |
6118 | 6193 | /* Label */ |
6119 | 6194 | #ifdef JP |
6120 | - put_str("成功率", 2, col+13); | |
6195 | + put_str("現在値", 2, col+24); | |
6121 | 6196 | #else |
6122 | - put_str(" Freq", 2, col+13); | |
6197 | + put_str(" Roll", 2, col+24); | |
6123 | 6198 | #endif |
6124 | 6199 | |
6125 | - | |
6126 | - /* Label */ | |
6200 | + /* Show prob. just below the round counter */ | |
6127 | 6201 | #ifdef JP |
6128 | - put_str("現在値", 2, col+24); | |
6202 | + if(autoroll_chance >= 1) | |
6203 | + sprintf(buf, "確率 : 1/%8d00", autoroll_chance); | |
6204 | + else if (autoroll_chance == -999) | |
6205 | + sprintf(buf, "確率 : 不可能"); | |
6206 | + else | |
6207 | + sprintf(buf, "確率 : 1/10000以上"); | |
6129 | 6208 | #else |
6130 | - put_str(" Roll", 2, col+24); | |
6209 | + if(autoroll_chance >= 1) | |
6210 | + sprintf(buf, "Prob : 1/%8d00", autoroll_chance); | |
6211 | + else if (autoroll_chance == -999) | |
6212 | + sprintf(buf, "Prob : Impossible"); | |
6213 | + else | |
6214 | + sprintf(buf, "Prob : >1/10000"); | |
6131 | 6215 | #endif |
6216 | + put_str(buf, 11, col+10); | |
6132 | 6217 | |
6133 | - | |
6218 | +#ifdef JP | |
6219 | + put_str("注意 : 体格等のオートローラを併用時は、上記確率より困難です。", 22, 5); | |
6220 | +#else | |
6221 | + put_str("Note : Prob may be lower when you use the 'autochara' option.", 22, 5); | |
6222 | +#endif | |
6134 | 6223 | /* Put the minimal stats */ |
6135 | 6224 | for (i = 0; i < 6; i++) |
6136 | 6225 | { |
6137 | 6226 | int j, m; |
6138 | 6227 | |
6139 | 6228 | /* Label stats */ |
6140 | - put_str(stat_names[i], 3+i, col); | |
6229 | + put_str(stat_names[i], 3+i, col+8); | |
6141 | 6230 | |
6142 | 6231 | /* Race/Class bonus */ |
6143 | 6232 | j = rp_ptr->r_adj[i] + cp_ptr->c_adj[i] + ap_ptr->a_adj[i]; |
@@ -6147,7 +6236,7 @@ static bool player_birth_aux(void) | ||
6147 | 6236 | |
6148 | 6237 | /* Put the stat */ |
6149 | 6238 | cnv_stat(m, buf); |
6150 | - c_put_str(TERM_L_BLUE, buf, 3+i, col+5); | |
6239 | + c_put_str(TERM_L_BLUE, buf, 3+i, col+13); | |
6151 | 6240 | } |
6152 | 6241 | } |
6153 | 6242 |
@@ -6163,17 +6252,10 @@ static bool player_birth_aux(void) | ||
6163 | 6252 | auto_round++; |
6164 | 6253 | |
6165 | 6254 | /* Hack -- Prevent overflow */ |
6166 | - if (auto_round >= 1000000000L) | |
6255 | + if (auto_round > 1000000000L) | |
6167 | 6256 | { |
6168 | 6257 | auto_round = 1; |
6169 | - | |
6170 | - if (autoroller) | |
6171 | - { | |
6172 | - for (i = 0; i < 6; i++) | |
6173 | - { | |
6174 | - stat_match[i] = 0; | |
6175 | - } | |
6176 | - } | |
6258 | + auto_round2 ++; | |
6177 | 6259 | } |
6178 | 6260 | |
6179 | 6261 | if (autoroller) |
@@ -6181,16 +6263,11 @@ static bool player_birth_aux(void) | ||
6181 | 6263 | /* Check and count acceptable stats */ |
6182 | 6264 | for (i = 0; i < 6; i++) |
6183 | 6265 | { |
6184 | - /* This stat is okay */ | |
6185 | - if (p_ptr->stat_max[i] >= stat_limit[i]) | |
6186 | - { | |
6187 | - stat_match[i]++; | |
6188 | - } | |
6189 | - | |
6190 | 6266 | /* This stat is not okay */ |
6191 | - else | |
6267 | + if (p_ptr->stat_max[i] < stat_limit[i]) | |
6192 | 6268 | { |
6193 | 6269 | accept = FALSE; |
6270 | + break; | |
6194 | 6271 | } |
6195 | 6272 | } |
6196 | 6273 | } |
@@ -6224,7 +6301,10 @@ static bool player_birth_aux(void) | ||
6224 | 6301 | birth_put_stats(); |
6225 | 6302 | |
6226 | 6303 | /* Dump round */ |
6227 | - put_str(format("%10ld", auto_round), 10, col+20); | |
6304 | + if(auto_round2) | |
6305 | + put_str(format("%ld%09ld", auto_round2, auto_round), 10, col+20); | |
6306 | + else | |
6307 | + put_str(format("%10ld", auto_round), 10, col+20); | |
6228 | 6308 | |
6229 | 6309 | #ifdef AUTOROLLER_DELAY |
6230 | 6310 | /* Delay 1/10 second */ |