Rig: game module bay with damped, capped effects

The rig gets the game's universal module bay (module adjacency included).
The machine's summed performance, efficiency and quality percentages are
divided by 4, like the ratios vanilla machines use, and capped: hashrate
at most +20%, power saving at most 25%, card wear at most -30%. Performance
also raises wear and burn-out chance by the same amount; negative
efficiency (overclock module, neural cores) raises power draw. Replaces the
planned mod-specific overclock module. Tested in game.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ZHU MINCHAOandClaude Opus 5.5 committed 2026-11-03 09:16:46 +08:00
1 parent 750b26e4b3
commit 79d4c686a0
9 files changed
+113 -44

No files matched your search

+35 -10
View File
@@ -48,6 +48,33 @@ namespace Decentralized.Domain
};
}
/// <summary>
/// 矿架上游戏模块的效果。机器汇总的三项百分比(性能、效率、品质)各除以 <see cref="Tuning.ModuleRatio"/> 后生效,
/// 并有上限,避免模块把挖矿收益放大到破坏经济:算力最多 +20%,省电最多 25%,损耗最多降 30%。
/// 性能加成同时按比例提高损耗与暴毙率。负数(例如节能模块的负性能、超频模块的负效率)照常生效,耗电增加不设上限。
/// </summary>
public struct ModuleBonus
{
public double Hash; // 算力乘数
public double Kj; // 耗电乘数
public double Wear; // 每日损耗乘数
public double Death; // 暴毙率乘数
public static ModuleBonus None => new ModuleBonus { Hash = 1, Kj = 1, Wear = 1, Death = 1 };
public static ModuleBonus From(int performance, int efficiency, int quality)
{
double r = Tuning.ModuleRatio * 100.0;
double hash = Clamp(performance / r, -0.5, Tuning.ModuleHashCap);
double save = Clamp(efficiency / r, -1.0, Tuning.ModuleKjCap);
double wearCut = Clamp(quality / r, -1.0, Tuning.ModuleWearCap);
double heat = 1 + Math.Max(0, hash);
return new ModuleBonus { Hash = 1 + hash, Kj = 1 - save, Wear = (1 - wearCut) * heat, Death = heat };
}
private static double Clamp(double v, double lo, double hi) => Math.Max(lo, Math.Min(hi, v));
}
/// <summary>一张显卡或一台矿机的实例状态(存进物品标签)。</summary>
public sealed class Unit
{
@@ -62,29 +89,27 @@ namespace Decentralized.Domain
public HardwareSpec Chip => Hardware.Specs[FakeOf ?? Model];
/// <summary>当前算力:健康 ≥ 50 时满算力,低于 50 线性降到健康 0 时的 60%。</summary>
public double Hash(bool overclock)
public double Hash(ModuleBonus b)
{
if (Dead) return 0;
double h = Chip.Hash * (Health >= 50 ? 1.0 : 0.6 + 0.4 * Health / 50);
return overclock ? h * Tuning.OcHash : h;
return Chip.Hash * (Health >= 50 ? 1.0 : 0.6 + 0.4 * Health / 50) * b.Hash;
}
public double Kj(bool overclock) => Dead ? 0 : Chip.Kj * (overclock ? Tuning.OcKj : 1);
public double Kj(ModuleBonus b) => Dead ? 0 : Chip.Kj * b.Kj;
/// <summary>今晚的暴毙概率。</summary>
public double DeathChance(bool overclock)
public double DeathChance(ModuleBonus b)
{
double p = Tuning.DeathBase + Tuning.DeathWorn * Math.Pow(1 - Health / 100, 2);
p *= Label.DeathFactor * (FakeOf != null ? Tuning.FakeDeathFactor : 1) * (overclock ? Tuning.OcDeath : 1);
return p;
return p * Label.DeathFactor * (FakeOf != null ? Tuning.FakeDeathFactor : 1) * b.Death;
}
/// <summary>一夜的损耗与暴毙判定;返回是否在今晚暴毙。</summary>
public bool Night(bool overclock, Rng rng)
public bool Night(ModuleBonus b, Rng rng)
{
if (Dead) return false;
Health = Math.Max(0, Health - Label.WearFactor * (overclock ? Tuning.OcWear : 1));
if (rng.Chance(DeathChance(overclock)))
Health = Math.Max(0, Health - Label.WearFactor * b.Wear);
if (rng.Chance(DeathChance(b)))
{
Dead = true;
return true;
+2 -1
View File
@@ -16,7 +16,8 @@ namespace Decentralized.Domain
public const double NpcAdj = 0.05;
public const double PoolFee = 0.03;
public const int RigPrice = 400, RigKj = 2, RigSlots = 4;
public const double OcHash = 1.25, OcKj = 1.40, OcWear = 1.3, OcDeath = 1.2;
/// <summary>矿架上模块百分比的折算系数(原版机器用 2–4),以及各项上限。</summary>
public const double ModuleRatio = 4, ModuleHashCap = 0.20, ModuleKjCap = 0.25, ModuleWearCap = 0.30;
public const double DeathBase = 0.001, DeathWorn = 0.03, FakeDeathFactor = 2;
public const double RefurbishHealth = 30;