<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>cxqsb</title>
        <link>https://paragraph.com/@cxqsb</link>
        <description>小黑子</description>
        <lastBuildDate>Fri, 26 Jun 2026 03:01:35 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <image>
            <title>cxqsb</title>
            <url>https://storage.googleapis.com/papyrus_images/9f3f135cbbcc56268e2f65c453b4799307fdc03e6c02430b13f895e68ff13e73.webp</url>
            <link>https://paragraph.com/@cxqsb</link>
        </image>
        <copyright>All rights reserved</copyright>
        <item>
            <title><![CDATA[   Succinct二期挖矿最优解]]></title>
            <link>https://paragraph.com/@cxqsb/succinct</link>
            <guid>iaGxefQXrym0WiSkADes</guid>
            <pubDate>Fri, 16 May 2025 04:38:08 GMT</pubDate>
            <description><![CDATA[prove with us 是纯运气游戏吗？ 假设你现在有1000颗星星， 每轮游戏池子总积分数暂定为1000，星星数固定为5颗 因为每轮游戏产出星星概率可以由本人投入积分/池子积分总数计算，考虑这两种极端情况： 1：投入 Z = 1000 点，一把梭哈总点数池 P = 1000 (你) + 1000 (他人) = 2000 点获胜几率 Prob_Win = 1000 / 2000 = 0.5预期获得星星: 0.5 * 5 ≈ 2.5 星2：投入投入 Z = 1000 点，一把梭哈总点数池 P = 000 (你) + 1000 (他人) = 1100 点获胜几率 Prob_Win = 100 / 1100 = 0.0909预期获得星星: 0.0909*5*10=4.545 星不难看出总星星数是关于每次投入积分的反比例函数y=x(10000/x)/(x+1000),星星期望随投入积分数增加而降低。 考虑到每轮池子积分的动态变化，以及奖池星星基数的改变(目前发现池子在8000分左右星星基数变为2)，假定个人积分总量为1w，改变平均下注的积分数量绘制下面的三维图像图1.1 星星期望随池...]]></description>
            <content:encoded><![CDATA[<p>prove with us 是纯运气游戏吗？</p><p>假设你现在有1000颗星星，</p><p>每轮游戏池子总积分数暂定为1000，星星数固定为5颗</p><p>因为每轮游戏产出星星概率可以由本人投入积分/池子积分总数计算，考虑这两种极端情况：</p><p>1：投入 <code>Z = 1000</code> 点，一把梭哈</p><ul><li><p>总点数池 P = 1000 (你) + 1000 (他人) = 2000 点</p></li><li><p>获胜几率 Prob_Win = 1000 / 2000 = 0.5</p></li><li><p><strong>预期获得星星: 0.5 * 5 ≈ 2.5 星</strong></p></li></ul><p>2：投入投入 <code>Z = 1000</code> 点，一把梭哈</p><ul><li><p>总点数池 P = 000 (你) + 1000 (他人) = 1100 点</p></li><li><p>获胜几率 Prob_Win = 100 / 1100 = 0.0909</p></li><li><p><strong>预期获得星星:</strong> 0.0909*5*10=4.545 <strong>星</strong></p></li></ul><p>不难看出总星星数是关于每次投入积分的反比例函数y=x(10000/x)/(x+1000),星星期望随投入积分数增加而降低。</p><p>考虑到每轮池子积分的动态变化，以及奖池星星基数的改变(目前发现池子在8000分左右星星基数变为2)，假定个人积分总量为1w，改变平均下注的积分数量绘制下面的三维图像</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/46f939dd46fc0aa430abf8a378a191120793a0df5b606fde1b2500d47c21644f.png" alt="图1.1 星星期望随池子积分及投入积分变化示意图" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">图1.1 星星期望随池子积分及投入积分变化示意图</figcaption></figure><p>截取池子（他人）积分为5000时的函数图像为例，由于投入积分数为3125时星星基数改变发生断层现象，星星期望达到最高</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/f3d37d667a434071e03ff3da244a2051fd755bc888e07fe4846f4349088a5486.png" alt="图1.2 池子积分为500时，星星期望随加入积分数量变化示意图" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">图1.2 池子积分为500时，星星期望随加入积分数量变化示意图</figcaption></figure><h2 id="h-" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">对星星的计算有了初步判断后还要考虑积分返佣规则</h2><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/a3c8f6edcdd799284632de72f52238ff07a249405daa14ccdcffd25af09510dd.png" alt="图1.3返佣规则" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">图1.3返佣规则</figcaption></figure><p><strong>“划算度”的完整数学模型</strong></p><ol><li><p><strong>基础定义：</strong></p><ul><li><p><code>B</code>：你的出价 (Your Bid)</p></li><li><p><code>P_others</code>：池中其他人已出价的总和 (Sum of Others&apos; Bids)</p></li><li><p><code>P_total</code>：总点数池 = <code>B + P_others</code></p></li></ul></li><li><p><strong>获胜几率 (</strong><code>Prob_Win</code>)：</p><ul><li><p><code>Prob_Win = B / P_total</code> (假设 <code>P_total &gt; 0</code>)</p></li></ul></li><li><p><strong>星星奖励 (</strong><code>Star_Prize</code>)：</p><ul><li><p>固定乘数 = 5x</p></li><li><p>如果 <code>P_total &lt; 8000</code>，基础星星 = 1 =&gt; <code>Star_Prize = 1 * 5 = 5</code> 星</p></li><li><p>如果 <code>P_total &gt;= 8000</code>，基础星星 = 2 =&gt; <code>Star_Prize = 2 * 5 = 10</code> 星</p></li></ul></li><li><p><strong>期望星星数 (</strong><code>E_Stars</code>)：</p><ul><li><p><code>E_Stars = Prob_Win * Star_Prize</code></p></li><li><p>如果你的出价 <code>B &lt; 100</code> (最低出价限制)，则 <code>E_Stars = 0</code> (因为无法有效出价)。</p></li></ul></li><li><p><strong>预期净点数成本 (</strong><code>E_Cost</code>)：</p><ul><li><p><code>E_Cost = 0.95 * B - 0.01 * P_others</code></p></li><li><p>这个值代表平均每次出价后，你点数的净损失。</p><ul><li><p><code>E_Cost &gt; 0</code>：平均亏损点数。</p></li><li><p><code>E_Cost = 0</code>：平均点数不亏不赚。</p></li><li><p><code>E_Cost &lt; 0</code>：平均净赚点数 (即 <code>预期净点数变化 E_Points_Change</code> 为正)。</p></li></ul></li></ul></li><li><p><strong>“划算度” (</strong><code>Efficiency</code>, <code>Eff</code>)：</p><ul><li><p><strong>核心定义：</strong> <code>Eff = E_Stars / E_Cost</code></p></li><li><p><strong>适用条件：</strong> 这个核心定义主要适用于 <code>E_Cost &gt; 0</code> 的情况，它表示你每平均付出1点净成本的点数，期望能换回多少星星。值越大，越划算。</p></li><li><p><strong>特殊情况处理 (为了图像和理解)：</strong></p><ul><li><p><strong>如果</strong> <code>E_Stars = 0</code> (例如 <code>B &lt; 100</code>): <code>Eff = 0</code>。</p></li><li><p><strong>如果</strong> <code>E_Stars &gt; 0</code> 且 <code>E_Cost &lt;= 0</code> (即点数上不亏或能赚点，同时还能期望获得星星): 这是非常理想的情况，其“划算度”可以认为是极高甚至是“无限大”。在绘图时，我们会赋予这些情况一个非常高的正值，以区别于有成本的情况。</p><ul><li><p>若 <code>E_Cost = 0</code> (点数持平)：划算度视为“极高A”。</p></li><li><p>若 <code>E_Cost &lt; 0</code> (点数净赚)：划算度视为“极高B”（比“极高A”更高，因为不仅不花钱还有的赚）。</p></li></ul></li></ul></li></ul></li></ol><p>构建模型图像如下，发现当前池子积分&gt;1w时，投入积分数在100左右性价比急速上升，也就是说投入100积分就算输了也会返还100积分，相当于投注永动机，不知道后面人多了项目方会不会修改机制，另外不清楚人数超过了95后池子的奖励会如何分配</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/e503795721631748f275dee31e97ff518a2a20754322ac653fd3b195b1f00fc6.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>那么我们如何Bid性价比最高呢</p><p>1 小注多次</p><p>2 凑断点位置</p><p>3 池子量及大或及小时优先Bid</p><p>py脚本模型，可以通过当前池子已经积分数量判断需要投入多少代币</p><p>(模型不一定准确后续需要一定修改)：</p><pre data-type="codeBlock" text="import numpy as np
import pandas as pd

MINIMUM_BID = 100
TGP_FIXED = 10000 # 我们分析的基础：固定总投入预算为10000点
B_EACH_MAX_ANALYSIS = 5000 # 单次出价B_each的分析上限

def calculate_expected_stars(your_bid_b, others_bid_p_others):
    if your_bid_b &lt; MINIMUM_BID: 
        return 0 
    total_pool_p = your_bid_b + others_bid_p_others
    if total_pool_p == 0: 
        return 0
    prob_win = your_bid_b / total_pool_p
    star_prize = 5 if total_pool_p &lt; 8000 else 10
    return prob_win * star_prize

if __name__ == &apos;__main__&apos;:
    loop_counter = 0
    while True:
        loop_counter += 1
        print(f&quot;\n--- [第 {loop_counter} 轮分析开始] ---&quot;)
        
        p_others_input_str = input(&quot;请输入当前池子中其他人的总点数 (P_others) (或输入 &apos;exit&apos; 退出): &quot;)
        if p_others_input_str.lower() == &apos;exit&apos;:
            break
        
        my_points_input_str = input(f&quot;请输入你当前拥有的点数 (My_Points_Available) (总预算分析仍基于{TGP_FIXED}点): &quot;)
        
        try:
            p_others_manual = float(p_others_input_str)
            my_points_available = float(my_points_input_str)
            if p_others_manual &lt; 0 or my_points_available &lt; 0:
                print(&quot;点数不能为负数，请重新输入。&quot;)
                continue
        except ValueError:
            print(&quot;输入无效，请输入一个数字或 &apos;exit&apos;。&quot;)
            continue
        except Exception as e:
            print(f&quot;发生错误: {e}&quot;)
            continue

        print(f&quot;\n--- 理论分析：如何最优地花费 {TGP_FIXED} 点总预算 (当前P_others = {p_others_manual:.0f}) ---&quot;)
        print(&quot;目标：找到最优的单次出价额 (B_each)，以最大化累计期望星星总数。&quot;)
        print(f&quot;总共会进行 N = {TGP_FIXED} / B_each 次出价。\n&quot;)

        # B_each 分析范围从100到B_EACH_MAX_ANALYSIS (5000)
        # 确保TGP_FIXED / B_each (当B_each = TGP_FIXED时，N=1) 这个点也被分析到，如果B_EACH_MAX_ANALYSIS &lt; TGP_FIXED
        # 但我们是分析B_each的颗粒度，所以B_each不应超过TGP_FIXED，且不超过我们设定的B_EACH_MAX_ANALYSIS
        # 如果B_EACH_MAX_ANALYSIS本身就小于TGP_FIXED，那么N=1的情况（B_each=TGP_FIXED）就不在分析范围内了
        # 我们的目标是找到最优的B_each *粒度* 来花掉TGP_FIXED
        # 所以B_each应该可以达到TGP_FIXED，但分析时可以只观察到5000

        current_b_each_max = min(TGP_FIXED, B_EACH_MAX_ANALYSIS) # B_each不会超过总预算或设定的分析上限

        b_each_analysis_range = np.unique(np.concatenate(([MINIMUM_BID, current_b_each_max], 
                                                         np.logspace(np.log10(MINIMUM_BID), np.log10(current_b_each_max), 70).astype(int))))
        b_each_analysis_range = b_each_analysis_range[b_each_analysis_range &gt;= MINIMUM_BID]
        b_each_analysis_range = b_each_analysis_range[b_each_analysis_range &lt;= current_b_each_max] # Ensure it doesn&apos;t exceed
        b_each_analysis_range.sort()
        if len(b_each_analysis_range) == 0: # Should not happen if MINIMUM_BID &lt;= current_b_each_max
             b_each_analysis_range = np.array([MINIMUM_BID])


        all_results = []
        for b_e in b_each_analysis_range:
            if b_e == 0: continue
            num_bids_n = TGP_FIXED / b_e # 花费10000点总预算需要多少次当前B_each的出价
            e_stars_per_one_bid = calculate_expected_stars(b_e, p_others_manual)
            total_e_stars = num_bids_n * e_stars_per_one_bid
            all_results.append({&apos;B_each&apos;: b_e, &apos;N_bids_for_TGP&apos;: num_bids_n, &apos;Total_Exp_Stars_for_TGP&apos;: total_e_stars})

        df_results = pd.DataFrame(all_results)
        
        optimal_b_each_for_tgp = -1
        max_total_stars_for_tgp = -1.0
        optimal_n_bids_for_tgp = 0

        if not df_results.empty and &apos;Total_Exp_Stars_for_TGP&apos; in df_results.columns and not df_results[&apos;Total_Exp_Stars_for_TGP&apos;].isnull().all():
            valid_stars = df_results[&apos;Total_Exp_Stars_for_TGP&apos;].dropna()
            if not valid_stars.empty:
                max_total_stars_for_tgp = valid_stars.max()
                if pd.notna(max_total_stars_for_tgp) and max_total_stars_for_tgp &gt;= 0:
                    optimal_row = df_results.loc[df_results[&apos;Total_Exp_Stars_for_TGP&apos;].idxmax()]
                    optimal_b_each_for_tgp = optimal_row[&apos;B_each&apos;]
                    optimal_n_bids_for_tgp = optimal_row[&apos;N_bids_for_TGP&apos;]
        
        # 准备表格输出
        b_each_table_display_samples = sorted(list(set([100, 200, 500, 1000, 2000, 3000, 4000, B_EACH_MAX_ANALYSIS])))
        if optimal_b_each_for_tgp != -1 and optimal_b_each_for_tgp not in b_each_table_display_samples:
            b_each_table_display_samples.append(int(optimal_b_each_for_tgp))
            b_each_table_display_samples.sort()
        b_each_table_display_samples = [b for b in b_each_table_display_samples if b &gt;= MINIMUM_BID and b &lt;= B_EACH_MAX_ANALYSIS]


        table_output_console = [f&quot;\n--- 累计期望星星数表格 (P_others = {p_others_manual:.0f}, 总预算分析基于 {TGP_FIXED}点) ---&quot;]
        header_console = f&quot;{&apos;单次出价 (B_each)&apos;:&lt;18} | {&apos;花完{TGP_FIXED}点需次数&apos;:&lt;22} | {&apos;累计期望星星数(预算{TGP_FIXED})&apos;:&lt;28}&quot;
        table_output_console.append(header_console)
        table_output_console.append(&quot;-&quot; * len(header_console))
        
        for b_e_val in b_each_table_display_samples:
            if b_e_val == 0: continue
            n_val_table = TGP_FIXED / b_e_val
            e_stars_val_table = calculate_expected_stars(b_e_val, p_others_manual)
            total_s_table = n_val_table * e_stars_val_table
            table_output_console.append(f&quot;{b_e_val:&lt;18.0f} | {n_val_table:&lt;22.1f} | {total_s_table:&lt;28.3f}&quot;)
        
        print(&quot;\n&quot;.join(table_output_console))

        if optimal_b_each_for_tgp != -1 and max_total_stars_for_tgp &gt;=0 :
            print(f&quot;\n--- 理论最优策略总结 (针对 {TGP_FIXED}点总预算, P_others = {p_others_manual:.0f}) ---&quot;)
            print(f&quot;为了最大化累计期望星星数 (用{TGP_FIXED}点总预算):&quot;)
            print(f&quot; -&gt; 理论上最优的单次出价额 (B_each) 为: {optimal_b_each_for_tgp:.0f} 点&quot;)
            print(f&quot; -&gt; 这相当于进行 {optimal_n_bids_for_tgp:.1f} 次这样的出价来花完 {TGP_FIXED} 点。&quot;)
            print(f&quot; -&gt; 预期的最大累计星星总数为: {max_total_stars_for_tgp:.3f} 星。&quot;)
            
            TARGET_POOL_FOR_10_STARS = 8000
            b_to_reach_8k_pool = TARGET_POOL_FOR_10_STARS - p_others_manual
            if MINIMUM_BID &lt;= b_to_reach_8k_pool &lt;= TGP_FIXED :
                if abs(optimal_b_each_for_tgp - b_to_reach_8k_pool) &lt; 1 or \
                   (optimal_b_each_for_tgp == MINIMUM_BID and b_to_reach_8k_pool &lt;= MINIMUM_BID) : 
                     print(f&quot;   (提示: 当前P_others={p_others_manual:.0f}时，出价{optimal_b_each_for_tgp:.0f}点会使总池达到或刚超过8000点，触发10星奖励)&quot;)
            elif p_others_manual &gt;= (TARGET_POOL_FOR_10_STARS - MINIMUM_BID) and optimal_b_each_for_tgp == MINIMUM_BID: 
                     print(f&quot;   (提示: 当前P_others={p_others_manual:.0f}时，出价{MINIMUM_BID}点已能使总池达到或超过8000点，触发10星奖励)&quot;)
        else:
            print(f&quot;\n对于 P_others = {p_others_manual:.0f}: 在当前B_each分析范围({MINIMUM_BID}-{B_EACH_MAX_ANALYSIS}点)内，未能找到期望星星为正的策略。&quot;)
        print(&quot;-&quot; * 80)
        
        # --- 根据用户当前点数给出实际操作建议 ---
        if optimal_b_each_for_tgp != -1 and max_total_stars_for_tgp &gt;=0:
            print(f&quot;\n--- 基于你当前 {my_points_available:.2f} 点的实际操作建议 ---&quot;)
            if my_points_available &lt; MINIMUM_BID:
                print(&quot;你的点数不足以进行最低出价。建议先积累点数。&quot;)
            elif my_points_available &lt; optimal_b_each_for_tgp:
                print(f&quot;你的点数 ({my_points_available:.2f}) 不足以按理论最优单次出价 ({optimal_b_each_for_tgp:.0f}点) 进行一次出价。&quot;)
                # 建议用100点出价
                num_100_bids_can_make = my_points_available // MINIMUM_BID # 可以进行的100点出价次数
                if num_100_bids_can_make &gt; 0:
                    e_stars_per_100_bid = calculate_expected_stars(MINIMUM_BID, p_others_manual)
                    total_stars_with_100_bids = num_100_bids_can_make * e_stars_per_100_bid
                    print(f&quot;你可以选择用 {MINIMUM_BID}点 进行 {num_100_bids_can_make:.0f} 次出价，预计总共获得 {total_stars_with_100_bids:.3f} 星。&quot;)
                else:
                    print(&quot;你甚至不足以进行一次100点的出价。&quot;)
                print(&quot;或者，你可以选择积攒更多点数，以便后续采用更优的单次出价策略。&quot;)
            else: # my_points_available &gt;= optimal_b_each_for_tgp
                num_optimal_bids_can_make = my_points_available // optimal_b_each_for_tgp
                e_stars_per_optimal_bid = calculate_expected_stars(optimal_b_each_for_tgp, p_others_manual) # This is E_Stars for one bid of optimal_b_each
                total_stars_with_optimal_bids = num_optimal_bids_can_make * e_stars_per_optimal_bid
                
                print(f&quot;你可以按理论最优单次出价 ({optimal_b_each_for_tgp:.0f}点) 进行 {num_optimal_bids_can_make:.0f} 次出价。&quot;)
                print(f&quot;  预计这 {num_optimal_bids_can_make:.0f} 次出价总共能为你带来 {total_stars_with_optimal_bids:.3f} 星。&quot;)
                
                # 和用100点出价对比一下
                if optimal_b_each_for_tgp != MINIMUM_BID:
                    num_100_bids_can_make = my_points_available // MINIMUM_BID
                    if num_100_bids_can_make &gt; 0:
                        e_stars_per_100_bid = calculate_expected_stars(MINIMUM_BID, p_others_manual)
                        total_stars_with_100_bids = num_100_bids_can_make * e_stars_per_100_bid
                        print(f&quot;作为对比，如果用这 {my_points_available:.2f} 点全部以100点进行出价 ({num_100_bids_can_make:.0f}次)，预计总共获得 {total_stars_with_100_bids:.3f} 星。&quot;)
        else:
            print(f&quot;\n--- 基于你当前 {my_points_available:.2f} 点的实际操作建议 ---&quot;)
            print(&quot;根据当前分析，在此P_others下，所有策略的期望星星数都非常低或为0。&quot;)
            if my_points_available &gt;= MINIMUM_BID:
                print(f&quot;如果你仍想参与，可以尝试用 {MINIMUM_BID} 点出价一次，但请注意期望收益可能不高。&quot;)
            else:
                print(&quot;你的点数不足以进行最低出价。&quot;)
        print(&quot;-&quot; * 80)
        print(&quot;[调试] 完成一轮分析，准备返回循环开头接收新输入或退出。&quot;)

    print(&quot;\n程序已退出。&quot;)
    # input(&quot;按回车键关闭此窗口...&quot;) # 如果在IDE中运行，这句可能不需要；如果直接运行py文件，可以保留
"><code><span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-keyword">import</span> pandas <span class="hljs-keyword">as</span> pd

MINIMUM_BID = <span class="hljs-number">100</span>
TGP_FIXED = <span class="hljs-number">10000</span> <span class="hljs-comment"># 我们分析的基础：固定总投入预算为10000点</span>
B_EACH_MAX_ANALYSIS = <span class="hljs-number">5000</span> <span class="hljs-comment"># 单次出价B_each的分析上限</span>

<span class="hljs-keyword">def</span> <span class="hljs-title function_">calculate_expected_stars</span>(<span class="hljs-params">your_bid_b, others_bid_p_others</span>):
    <span class="hljs-keyword">if</span> your_bid_b &#x3C; MINIMUM_BID: 
        <span class="hljs-keyword">return</span> <span class="hljs-number">0</span> 
    total_pool_p = your_bid_b + others_bid_p_others
    <span class="hljs-keyword">if</span> total_pool_p == <span class="hljs-number">0</span>: 
        <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>
    prob_win = your_bid_b / total_pool_p
    star_prize = <span class="hljs-number">5</span> <span class="hljs-keyword">if</span> total_pool_p &#x3C; <span class="hljs-number">8000</span> <span class="hljs-keyword">else</span> <span class="hljs-number">10</span>
    <span class="hljs-keyword">return</span> prob_win * star_prize

<span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">'__main__'</span>:
    loop_counter = <span class="hljs-number">0</span>
    <span class="hljs-keyword">while</span> <span class="hljs-literal">True</span>:
        loop_counter += <span class="hljs-number">1</span>
        <span class="hljs-built_in">print</span>(<span class="hljs-string">f"\n--- [第 <span class="hljs-subst">{loop_counter}</span> 轮分析开始] ---"</span>)
        
        p_others_input_str = <span class="hljs-built_in">input</span>(<span class="hljs-string">"请输入当前池子中其他人的总点数 (P_others) (或输入 'exit' 退出): "</span>)
        <span class="hljs-keyword">if</span> p_others_input_str.lower() == <span class="hljs-string">'exit'</span>:
            <span class="hljs-keyword">break</span>
        
        my_points_input_str = <span class="hljs-built_in">input</span>(<span class="hljs-string">f"请输入你当前拥有的点数 (My_Points_Available) (总预算分析仍基于<span class="hljs-subst">{TGP_FIXED}</span>点): "</span>)
        
        <span class="hljs-keyword">try</span>:
            p_others_manual = <span class="hljs-built_in">float</span>(p_others_input_str)
            my_points_available = <span class="hljs-built_in">float</span>(my_points_input_str)
            <span class="hljs-keyword">if</span> p_others_manual &#x3C; <span class="hljs-number">0</span> <span class="hljs-keyword">or</span> my_points_available &#x3C; <span class="hljs-number">0</span>:
                <span class="hljs-built_in">print</span>(<span class="hljs-string">"点数不能为负数，请重新输入。"</span>)
                <span class="hljs-keyword">continue</span>
        <span class="hljs-keyword">except</span> ValueError:
            <span class="hljs-built_in">print</span>(<span class="hljs-string">"输入无效，请输入一个数字或 'exit'。"</span>)
            <span class="hljs-keyword">continue</span>
        <span class="hljs-keyword">except</span> Exception <span class="hljs-keyword">as</span> e:
            <span class="hljs-built_in">print</span>(<span class="hljs-string">f"发生错误: <span class="hljs-subst">{e}</span>"</span>)
            <span class="hljs-keyword">continue</span>

        <span class="hljs-built_in">print</span>(<span class="hljs-string">f"\n--- 理论分析：如何最优地花费 <span class="hljs-subst">{TGP_FIXED}</span> 点总预算 (当前P_others = <span class="hljs-subst">{p_others_manual:<span class="hljs-number">.0</span>f}</span>) ---"</span>)
        <span class="hljs-built_in">print</span>(<span class="hljs-string">"目标：找到最优的单次出价额 (B_each)，以最大化累计期望星星总数。"</span>)
        <span class="hljs-built_in">print</span>(<span class="hljs-string">f"总共会进行 N = <span class="hljs-subst">{TGP_FIXED}</span> / B_each 次出价。\n"</span>)

        <span class="hljs-comment"># B_each 分析范围从100到B_EACH_MAX_ANALYSIS (5000)</span>
        <span class="hljs-comment"># 确保TGP_FIXED / B_each (当B_each = TGP_FIXED时，N=1) 这个点也被分析到，如果B_EACH_MAX_ANALYSIS &#x3C; TGP_FIXED</span>
        <span class="hljs-comment"># 但我们是分析B_each的颗粒度，所以B_each不应超过TGP_FIXED，且不超过我们设定的B_EACH_MAX_ANALYSIS</span>
        <span class="hljs-comment"># 如果B_EACH_MAX_ANALYSIS本身就小于TGP_FIXED，那么N=1的情况（B_each=TGP_FIXED）就不在分析范围内了</span>
        <span class="hljs-comment"># 我们的目标是找到最优的B_each *粒度* 来花掉TGP_FIXED</span>
        <span class="hljs-comment"># 所以B_each应该可以达到TGP_FIXED，但分析时可以只观察到5000</span>

        current_b_each_max = <span class="hljs-built_in">min</span>(TGP_FIXED, B_EACH_MAX_ANALYSIS) <span class="hljs-comment"># B_each不会超过总预算或设定的分析上限</span>

        b_each_analysis_range = np.unique(np.concatenate(([MINIMUM_BID, current_b_each_max], 
                                                         np.logspace(np.log10(MINIMUM_BID), np.log10(current_b_each_max), <span class="hljs-number">70</span>).astype(<span class="hljs-built_in">int</span>))))
        b_each_analysis_range = b_each_analysis_range[b_each_analysis_range >= MINIMUM_BID]
        b_each_analysis_range = b_each_analysis_range[b_each_analysis_range &#x3C;= current_b_each_max] <span class="hljs-comment"># Ensure it doesn't exceed</span>
        b_each_analysis_range.sort()
        <span class="hljs-keyword">if</span> <span class="hljs-built_in">len</span>(b_each_analysis_range) == <span class="hljs-number">0</span>: <span class="hljs-comment"># Should not happen if MINIMUM_BID &#x3C;= current_b_each_max</span>
             b_each_analysis_range = np.array([MINIMUM_BID])


        all_results = []
        <span class="hljs-keyword">for</span> b_e <span class="hljs-keyword">in</span> b_each_analysis_range:
            <span class="hljs-keyword">if</span> b_e == <span class="hljs-number">0</span>: <span class="hljs-keyword">continue</span>
            num_bids_n = TGP_FIXED / b_e <span class="hljs-comment"># 花费10000点总预算需要多少次当前B_each的出价</span>
            e_stars_per_one_bid = calculate_expected_stars(b_e, p_others_manual)
            total_e_stars = num_bids_n * e_stars_per_one_bid
            all_results.append({<span class="hljs-string">'B_each'</span>: b_e, <span class="hljs-string">'N_bids_for_TGP'</span>: num_bids_n, <span class="hljs-string">'Total_Exp_Stars_for_TGP'</span>: total_e_stars})

        df_results = pd.DataFrame(all_results)
        
        optimal_b_each_for_tgp = -<span class="hljs-number">1</span>
        max_total_stars_for_tgp = -<span class="hljs-number">1.0</span>
        optimal_n_bids_for_tgp = <span class="hljs-number">0</span>

        <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> df_results.empty <span class="hljs-keyword">and</span> <span class="hljs-string">'Total_Exp_Stars_for_TGP'</span> <span class="hljs-keyword">in</span> df_results.columns <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> df_results[<span class="hljs-string">'Total_Exp_Stars_for_TGP'</span>].isnull().<span class="hljs-built_in">all</span>():
            valid_stars = df_results[<span class="hljs-string">'Total_Exp_Stars_for_TGP'</span>].dropna()
            <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> valid_stars.empty:
                max_total_stars_for_tgp = valid_stars.<span class="hljs-built_in">max</span>()
                <span class="hljs-keyword">if</span> pd.notna(max_total_stars_for_tgp) <span class="hljs-keyword">and</span> max_total_stars_for_tgp >= <span class="hljs-number">0</span>:
                    optimal_row = df_results.loc[df_results[<span class="hljs-string">'Total_Exp_Stars_for_TGP'</span>].idxmax()]
                    optimal_b_each_for_tgp = optimal_row[<span class="hljs-string">'B_each'</span>]
                    optimal_n_bids_for_tgp = optimal_row[<span class="hljs-string">'N_bids_for_TGP'</span>]
        
        <span class="hljs-comment"># 准备表格输出</span>
        b_each_table_display_samples = <span class="hljs-built_in">sorted</span>(<span class="hljs-built_in">list</span>(<span class="hljs-built_in">set</span>([<span class="hljs-number">100</span>, <span class="hljs-number">200</span>, <span class="hljs-number">500</span>, <span class="hljs-number">1000</span>, <span class="hljs-number">2000</span>, <span class="hljs-number">3000</span>, <span class="hljs-number">4000</span>, B_EACH_MAX_ANALYSIS])))
        <span class="hljs-keyword">if</span> optimal_b_each_for_tgp != -<span class="hljs-number">1</span> <span class="hljs-keyword">and</span> optimal_b_each_for_tgp <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> b_each_table_display_samples:
            b_each_table_display_samples.append(<span class="hljs-built_in">int</span>(optimal_b_each_for_tgp))
            b_each_table_display_samples.sort()
        b_each_table_display_samples = [b <span class="hljs-keyword">for</span> b <span class="hljs-keyword">in</span> b_each_table_display_samples <span class="hljs-keyword">if</span> b >= MINIMUM_BID <span class="hljs-keyword">and</span> b &#x3C;= B_EACH_MAX_ANALYSIS]


        table_output_console = [<span class="hljs-string">f"\n--- 累计期望星星数表格 (P_others = <span class="hljs-subst">{p_others_manual:<span class="hljs-number">.0</span>f}</span>, 总预算分析基于 <span class="hljs-subst">{TGP_FIXED}</span>点) ---"</span>]
        header_console = <span class="hljs-string">f"<span class="hljs-subst">{<span class="hljs-string">'单次出价 (B_each)'</span>:&#x3C;<span class="hljs-number">18</span>}</span> | <span class="hljs-subst">{<span class="hljs-string">'花完{TGP_FIXED}点需次数'</span>:&#x3C;<span class="hljs-number">22</span>}</span> | <span class="hljs-subst">{<span class="hljs-string">'累计期望星星数(预算{TGP_FIXED})'</span>:&#x3C;<span class="hljs-number">28</span>}</span>"</span>
        table_output_console.append(header_console)
        table_output_console.append(<span class="hljs-string">"-"</span> * <span class="hljs-built_in">len</span>(header_console))
        
        <span class="hljs-keyword">for</span> b_e_val <span class="hljs-keyword">in</span> b_each_table_display_samples:
            <span class="hljs-keyword">if</span> b_e_val == <span class="hljs-number">0</span>: <span class="hljs-keyword">continue</span>
            n_val_table = TGP_FIXED / b_e_val
            e_stars_val_table = calculate_expected_stars(b_e_val, p_others_manual)
            total_s_table = n_val_table * e_stars_val_table
            table_output_console.append(<span class="hljs-string">f"<span class="hljs-subst">{b_e_val:&#x3C;<span class="hljs-number">18.0</span>f}</span> | <span class="hljs-subst">{n_val_table:&#x3C;<span class="hljs-number">22.1</span>f}</span> | <span class="hljs-subst">{total_s_table:&#x3C;<span class="hljs-number">28.3</span>f}</span>"</span>)
        
        <span class="hljs-built_in">print</span>(<span class="hljs-string">"\n"</span>.join(table_output_console))

        <span class="hljs-keyword">if</span> optimal_b_each_for_tgp != -<span class="hljs-number">1</span> <span class="hljs-keyword">and</span> max_total_stars_for_tgp >=<span class="hljs-number">0</span> :
            <span class="hljs-built_in">print</span>(<span class="hljs-string">f"\n--- 理论最优策略总结 (针对 <span class="hljs-subst">{TGP_FIXED}</span>点总预算, P_others = <span class="hljs-subst">{p_others_manual:<span class="hljs-number">.0</span>f}</span>) ---"</span>)
            <span class="hljs-built_in">print</span>(<span class="hljs-string">f"为了最大化累计期望星星数 (用<span class="hljs-subst">{TGP_FIXED}</span>点总预算):"</span>)
            <span class="hljs-built_in">print</span>(<span class="hljs-string">f" -> 理论上最优的单次出价额 (B_each) 为: <span class="hljs-subst">{optimal_b_each_for_tgp:<span class="hljs-number">.0</span>f}</span> 点"</span>)
            <span class="hljs-built_in">print</span>(<span class="hljs-string">f" -> 这相当于进行 <span class="hljs-subst">{optimal_n_bids_for_tgp:<span class="hljs-number">.1</span>f}</span> 次这样的出价来花完 <span class="hljs-subst">{TGP_FIXED}</span> 点。"</span>)
            <span class="hljs-built_in">print</span>(<span class="hljs-string">f" -> 预期的最大累计星星总数为: <span class="hljs-subst">{max_total_stars_for_tgp:<span class="hljs-number">.3</span>f}</span> 星。"</span>)
            
            TARGET_POOL_FOR_10_STARS = <span class="hljs-number">8000</span>
            b_to_reach_8k_pool = TARGET_POOL_FOR_10_STARS - p_others_manual
            <span class="hljs-keyword">if</span> MINIMUM_BID &#x3C;= b_to_reach_8k_pool &#x3C;= TGP_FIXED :
                <span class="hljs-keyword">if</span> <span class="hljs-built_in">abs</span>(optimal_b_each_for_tgp - b_to_reach_8k_pool) &#x3C; <span class="hljs-number">1</span> <span class="hljs-keyword">or</span> \
                   (optimal_b_each_for_tgp == MINIMUM_BID <span class="hljs-keyword">and</span> b_to_reach_8k_pool &#x3C;= MINIMUM_BID) : 
                     <span class="hljs-built_in">print</span>(<span class="hljs-string">f"   (提示: 当前P_others=<span class="hljs-subst">{p_others_manual:<span class="hljs-number">.0</span>f}</span>时，出价<span class="hljs-subst">{optimal_b_each_for_tgp:<span class="hljs-number">.0</span>f}</span>点会使总池达到或刚超过8000点，触发10星奖励)"</span>)
            <span class="hljs-keyword">elif</span> p_others_manual >= (TARGET_POOL_FOR_10_STARS - MINIMUM_BID) <span class="hljs-keyword">and</span> optimal_b_each_for_tgp == MINIMUM_BID: 
                     <span class="hljs-built_in">print</span>(<span class="hljs-string">f"   (提示: 当前P_others=<span class="hljs-subst">{p_others_manual:<span class="hljs-number">.0</span>f}</span>时，出价<span class="hljs-subst">{MINIMUM_BID}</span>点已能使总池达到或超过8000点，触发10星奖励)"</span>)
        <span class="hljs-keyword">else</span>:
            <span class="hljs-built_in">print</span>(<span class="hljs-string">f"\n对于 P_others = <span class="hljs-subst">{p_others_manual:<span class="hljs-number">.0</span>f}</span>: 在当前B_each分析范围(<span class="hljs-subst">{MINIMUM_BID}</span>-<span class="hljs-subst">{B_EACH_MAX_ANALYSIS}</span>点)内，未能找到期望星星为正的策略。"</span>)
        <span class="hljs-built_in">print</span>(<span class="hljs-string">"-"</span> * <span class="hljs-number">80</span>)
        
        <span class="hljs-comment"># --- 根据用户当前点数给出实际操作建议 ---</span>
        <span class="hljs-keyword">if</span> optimal_b_each_for_tgp != -<span class="hljs-number">1</span> <span class="hljs-keyword">and</span> max_total_stars_for_tgp >=<span class="hljs-number">0</span>:
            <span class="hljs-built_in">print</span>(<span class="hljs-string">f"\n--- 基于你当前 <span class="hljs-subst">{my_points_available:<span class="hljs-number">.2</span>f}</span> 点的实际操作建议 ---"</span>)
            <span class="hljs-keyword">if</span> my_points_available &#x3C; MINIMUM_BID:
                <span class="hljs-built_in">print</span>(<span class="hljs-string">"你的点数不足以进行最低出价。建议先积累点数。"</span>)
            <span class="hljs-keyword">elif</span> my_points_available &#x3C; optimal_b_each_for_tgp:
                <span class="hljs-built_in">print</span>(<span class="hljs-string">f"你的点数 (<span class="hljs-subst">{my_points_available:<span class="hljs-number">.2</span>f}</span>) 不足以按理论最优单次出价 (<span class="hljs-subst">{optimal_b_each_for_tgp:<span class="hljs-number">.0</span>f}</span>点) 进行一次出价。"</span>)
                <span class="hljs-comment"># 建议用100点出价</span>
                num_100_bids_can_make = my_points_available // MINIMUM_BID <span class="hljs-comment"># 可以进行的100点出价次数</span>
                <span class="hljs-keyword">if</span> num_100_bids_can_make > <span class="hljs-number">0</span>:
                    e_stars_per_100_bid = calculate_expected_stars(MINIMUM_BID, p_others_manual)
                    total_stars_with_100_bids = num_100_bids_can_make * e_stars_per_100_bid
                    <span class="hljs-built_in">print</span>(<span class="hljs-string">f"你可以选择用 <span class="hljs-subst">{MINIMUM_BID}</span>点 进行 <span class="hljs-subst">{num_100_bids_can_make:<span class="hljs-number">.0</span>f}</span> 次出价，预计总共获得 <span class="hljs-subst">{total_stars_with_100_bids:<span class="hljs-number">.3</span>f}</span> 星。"</span>)
                <span class="hljs-keyword">else</span>:
                    <span class="hljs-built_in">print</span>(<span class="hljs-string">"你甚至不足以进行一次100点的出价。"</span>)
                <span class="hljs-built_in">print</span>(<span class="hljs-string">"或者，你可以选择积攒更多点数，以便后续采用更优的单次出价策略。"</span>)
            <span class="hljs-keyword">else</span>: <span class="hljs-comment"># my_points_available >= optimal_b_each_for_tgp</span>
                num_optimal_bids_can_make = my_points_available // optimal_b_each_for_tgp
                e_stars_per_optimal_bid = calculate_expected_stars(optimal_b_each_for_tgp, p_others_manual) <span class="hljs-comment"># This is E_Stars for one bid of optimal_b_each</span>
                total_stars_with_optimal_bids = num_optimal_bids_can_make * e_stars_per_optimal_bid
                
                <span class="hljs-built_in">print</span>(<span class="hljs-string">f"你可以按理论最优单次出价 (<span class="hljs-subst">{optimal_b_each_for_tgp:<span class="hljs-number">.0</span>f}</span>点) 进行 <span class="hljs-subst">{num_optimal_bids_can_make:<span class="hljs-number">.0</span>f}</span> 次出价。"</span>)
                <span class="hljs-built_in">print</span>(<span class="hljs-string">f"  预计这 <span class="hljs-subst">{num_optimal_bids_can_make:<span class="hljs-number">.0</span>f}</span> 次出价总共能为你带来 <span class="hljs-subst">{total_stars_with_optimal_bids:<span class="hljs-number">.3</span>f}</span> 星。"</span>)
                
                <span class="hljs-comment"># 和用100点出价对比一下</span>
                <span class="hljs-keyword">if</span> optimal_b_each_for_tgp != MINIMUM_BID:
                    num_100_bids_can_make = my_points_available // MINIMUM_BID
                    <span class="hljs-keyword">if</span> num_100_bids_can_make > <span class="hljs-number">0</span>:
                        e_stars_per_100_bid = calculate_expected_stars(MINIMUM_BID, p_others_manual)
                        total_stars_with_100_bids = num_100_bids_can_make * e_stars_per_100_bid
                        <span class="hljs-built_in">print</span>(<span class="hljs-string">f"作为对比，如果用这 <span class="hljs-subst">{my_points_available:<span class="hljs-number">.2</span>f}</span> 点全部以100点进行出价 (<span class="hljs-subst">{num_100_bids_can_make:<span class="hljs-number">.0</span>f}</span>次)，预计总共获得 <span class="hljs-subst">{total_stars_with_100_bids:<span class="hljs-number">.3</span>f}</span> 星。"</span>)
        <span class="hljs-keyword">else</span>:
            <span class="hljs-built_in">print</span>(<span class="hljs-string">f"\n--- 基于你当前 <span class="hljs-subst">{my_points_available:<span class="hljs-number">.2</span>f}</span> 点的实际操作建议 ---"</span>)
            <span class="hljs-built_in">print</span>(<span class="hljs-string">"根据当前分析，在此P_others下，所有策略的期望星星数都非常低或为0。"</span>)
            <span class="hljs-keyword">if</span> my_points_available >= MINIMUM_BID:
                <span class="hljs-built_in">print</span>(<span class="hljs-string">f"如果你仍想参与，可以尝试用 <span class="hljs-subst">{MINIMUM_BID}</span> 点出价一次，但请注意期望收益可能不高。"</span>)
            <span class="hljs-keyword">else</span>:
                <span class="hljs-built_in">print</span>(<span class="hljs-string">"你的点数不足以进行最低出价。"</span>)
        <span class="hljs-built_in">print</span>(<span class="hljs-string">"-"</span> * <span class="hljs-number">80</span>)
        <span class="hljs-built_in">print</span>(<span class="hljs-string">"[调试] 完成一轮分析，准备返回循环开头接收新输入或退出。"</span>)

    <span class="hljs-built_in">print</span>(<span class="hljs-string">"\n程序已退出。"</span>)
    <span class="hljs-comment"># input("按回车键关闭此窗口...") # 如果在IDE中运行，这句可能不需要；如果直接运行py文件，可以保留</span>
</code></pre>]]></content:encoded>
            <author>cxqsb@newsletter.paragraph.com (cxqsb)</author>
            <enclosure url="https://storage.googleapis.com/papyrus_images/ed321a8d69fbfd8c4707ed84960c1ee0719ea2a9edb98afc8a987ad1f4371733.jpg" length="0" type="image/jpg"/>
        </item>
    </channel>
</rss>