Skip to content

Commit

Permalink
fix: Weight ships by speed^2 - larger ships are much less likely
Browse files Browse the repository at this point in the history
  • Loading branch information
Clashsoft committed Aug 13, 2024
1 parent 58f948f commit 7b567e5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/fleet/fleet.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export class FleetService extends MongooseRepository<Fleet> {
const shipCount = 5 + Math.randInt(11);
const size: Fleet['size'] = {};
for (let i = 0; i < shipCount; i++) {
// weighted selection of ship types by speed - smaller ships are more likely
const shipType = shipTypes.randomWeighted(type => SHIP_TYPES[type].speed);
// weighted selection of ship types by speed^2 - smaller ships are much more likely
const shipType = shipTypes.randomWeighted(type => SHIP_TYPES[type].speed ** 2);
size[shipType] = (size[shipType] || 0) + 1;
}
return ({
Expand Down

0 comments on commit 7b567e5

Please sign in to comment.