Skip to content

Commit 7b567e5

Browse files
committed
fix: Weight ships by speed^2 - larger ships are much less likely
1 parent 58f948f commit 7b567e5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/fleet/fleet.service.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ export class FleetService extends MongooseRepository<Fleet> {
5757
const shipCount = 5 + Math.randInt(11);
5858
const size: Fleet['size'] = {};
5959
for (let i = 0; i < shipCount; i++) {
60-
// weighted selection of ship types by speed - smaller ships are more likely
61-
const shipType = shipTypes.randomWeighted(type => SHIP_TYPES[type].speed);
60+
// weighted selection of ship types by speed^2 - smaller ships are much more likely
61+
const shipType = shipTypes.randomWeighted(type => SHIP_TYPES[type].speed ** 2);
6262
size[shipType] = (size[shipType] || 0) + 1;
6363
}
6464
return ({

0 commit comments

Comments
 (0)