-
Notifications
You must be signed in to change notification settings - Fork 911
Trade3 #3436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Trade3 #3436
Changes from all commits
1bcfd6c
1309713
be4cb4b
1dee894
97fc8b2
dbb9fe9
44d128a
c7c9ed9
bb7e43a
8492368
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -311,28 +311,24 @@ export class DefaultConfig implements Config { | |||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| tradeShipGold(dist: number): Gold { | ||||||||||||||||
| // Sigmoid: concave start, sharp S-curve middle, linear end - heavily punishes trades under range debuff. | ||||||||||||||||
| const debuff = this.tradeShipShortRangeDebuff(); | ||||||||||||||||
| const baseGold = | ||||||||||||||||
| 75_000 / (1 + Math.exp(-0.03 * (dist - debuff))) + 50 * dist; | ||||||||||||||||
| const multiplier = this.goldMultiplier(); | ||||||||||||||||
| return BigInt(Math.floor(baseGold * multiplier)); | ||||||||||||||||
| return toInt(10000 + 150 * Math.pow(dist, 1.1)); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| // Probability of trade ship spawn = 1 / tradeShipSpawnRate | ||||||||||||||||
| tradeShipSpawnRate( | ||||||||||||||||
| tradeShipSpawnRejections: number, | ||||||||||||||||
| numTradeShips: number, | ||||||||||||||||
| numPlayerPorts: number, | ||||||||||||||||
| ): number { | ||||||||||||||||
| const decayRate = Math.LN2 / 50; | ||||||||||||||||
|
|
||||||||||||||||
| // Approaches 0 as numTradeShips increase | ||||||||||||||||
| const baseSpawnRate = 1 - sigmoid(numTradeShips, decayRate, 200); | ||||||||||||||||
| if (numPlayerPorts <= 3) return 18; | ||||||||||||||||
| if (numPlayerPorts <= 5) return 25; | ||||||||||||||||
| if (numPlayerPorts <= 8) return 35; | ||||||||||||||||
| if (numPlayerPorts <= 10) return 40; | ||||||||||||||||
| if (numPlayerPorts <= 12) return 45; | ||||||||||||||||
|
|
||||||||||||||||
| // Pity timer: increases spawn chance after consecutive rejections | ||||||||||||||||
| const rejectionModifier = 1 / (tradeShipSpawnRejections + 1); | ||||||||||||||||
|
|
||||||||||||||||
| return Math.floor((100 * rejectionModifier) / baseSpawnRate); | ||||||||||||||||
| return Math.floor((100 * rejectionModifier) / 50); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| unitInfo(type: UnitType): UnitInfo { | ||||||||||||||||
|
|
@@ -391,13 +387,8 @@ export class DefaultConfig implements Config { | |||||||||||||||
| }; | ||||||||||||||||
| break; | ||||||||||||||||
| case UnitType.MIRV: | ||||||||||||||||
| info = { | ||||||||||||||||
| cost: (game: Game, player: Player) => { | ||||||||||||||||
| if (player.type() === PlayerType.Human && this.infiniteGold()) { | ||||||||||||||||
| return 0n; | ||||||||||||||||
| } | ||||||||||||||||
| return 25_000_000n + game.stats().numMirvsLaunched() * 15_000_000n; | ||||||||||||||||
| }, | ||||||||||||||||
| return { | ||||||||||||||||
| cost: this.costWrapper(() => 35_000_000), | ||||||||||||||||
| }; | ||||||||||||||||
| break; | ||||||||||||||||
|
Comment on lines
+390
to
393
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dead code: The 🧹 Proposed fix case UnitType.MIRV:
return {
cost: this.costWrapper(() => 35_000_000),
};
- break;📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome (2.4.6)[error] 390-390: This code is unreachable (lint/correctness/noUnreachable) 🤖 Prompt for AI Agents |
||||||||||||||||
| case UnitType.MIRVWarhead: | ||||||||||||||||
|
|
||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible logic issue: spawn rate drops sharply for >12 ports.
For
numPlayerPorts <= 12, the function returns 45 (about 2.2% spawn chance). But fornumPlayerPorts > 12, it returnsMath.floor(100 / 50) = 2when there are no rejections, meaning a 50% spawn chance.This seems like a big jump. Is this intentional? If you meant to continue the scaling pattern, consider something like:
🐛 If this is unintentional, here is a possible fix
if (numPlayerPorts <= 12) return 45; // Pity timer: increases spawn chance after consecutive rejections const rejectionModifier = 1 / (tradeShipSpawnRejections + 1); - return Math.floor((100 * rejectionModifier) / 50); + // Continue scaling for larger port counts + const baseRate = 45 + Math.floor((numPlayerPorts - 12) * 5); + return Math.floor(baseRate * rejectionModifier);🤖 Prompt for AI Agents