Skip to content
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

Dynamic bot spawning based on target population #459

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

KilianIvoKoeln289
Copy link
Collaborator

@KilianIvoKoeln289 KilianIvoKoeln289 commented Jul 5, 2023

Implemented dynamic bot spawning. The target ratios are now defined in GameConfig.java and depending on the difference between the current population of Bots and the target population (or ratio) the decision is made which type of bot will be spawned next.

…n GameConfig.java and depending on the difference between the current population of Bots and the target population (or ratio) the decision is made which type of bot will be spawned next.
@KilianIvoKoeln289 KilianIvoKoeln289 requested a review from tim-we July 5, 2023 21:06
server/src/main/java/game/Game.java Show resolved Hide resolved
server/src/main/java/game/Game.java Outdated Show resolved Hide resolved
Comment on lines 28 to 30
* @param world
* @param game
* @return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either add descriptions to these or remove this part of the JavaDoc comment

server/src/main/java/game/ai/BotFactory.java Outdated Show resolved Hide resolved
server/src/main/java/game/ai/BotFactory.java Outdated Show resolved Hide resolved
public record BotPopulationDistributionTarget(double stupidBotRatio, double kamikazeBotRatio,
double scaredBotRatio) {
public BotPopulationDistributionTarget {
assert (stupidBotRatio + kamikazeBotRatio + scaredBotRatio == 1.0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Careful with exact floating point math. Better check for Math.abs(x1 + x2 + x3 - 1.0) < 1e-8

@tim-we tim-we changed the title Implemented dynamic bot spawning. The target ratios are now defined i… Dynamic bot spawning based on target population Jul 23, 2023
@KilianIvoKoeln289 KilianIvoKoeln289 requested a review from tim-we July 26, 2023 02:47
server/src/main/java/game/ai/bot/BotFactory.java Outdated Show resolved Hide resolved
server/src/main/java/game/ai/bot/BotFactory.java Outdated Show resolved Hide resolved
@tim-we tim-we added enhancement New feature or request Server java Pull requests that update Java code labels Aug 1, 2023
@tim-we
Copy link
Member

tim-we commented Aug 1, 2023

IMO we need to rethink this a bit. I would prefer the following algorithm:

  1. Determine current bot population (count instances of each class)
  2. Compare with target population and decide how many bots to spawn of each kind
  3. Spawn bots

Another option would be to

  1. Determine current bot population
  2. Spawn bot of type which is missing the most
  3. Update bot population (should not be necessary to recount, just add the new bot somehow)
  4. Repeat from step 2 on until enough bots are spawned

@tim-we tim-we marked this pull request as draft February 4, 2024 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request java Pull requests that update Java code Server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants