Hi,
The basic idea goes like this:
a) The game randomly selects an initial budget for the wave between 50 K and 150K.
b) The game multiplies the initial budget by an "AI difficulty" factor from the server's configuration. E.g. if this factor is 0.5 then you end up with a budget from 25 K to 50 K, and if this factor is 10 then you end up with a budget from 500 K to 1500K. This allows different servers to have different difficulty (e.g. "noob friendly servers" with weak pirates, and "hard core" servers with powerful pirates).
c) Then the game chooses if it wants "big ship with smaller ships" (30% chance) or "group of medium ships" (70% chance). For "big ship with smaller ships"; the game tries to find one ship worth half of the budget and subtracts its price from the budget.
d) Then the game picks a number from 1 to 6 to determine how many more ships will be in the wave; and does something like (pseudo-code):
while(ships > 0) {
desired_price = remaining_budget / ships;
new_ship = find_ship(desired_price);
ships--;
remaining_budget -= new_ship->price;
add_to_wave(new_ship);
}
The basic idea of that is to select 1 to 6 ships that are about the same price, without wasting too much of the budget. For example, with 100 K left to spend on 4 ships, you might end up with 2 ships worth 30K each plus 2 ships worth 20K each.
The basic idea goes like this:
a) The game randomly selects an initial budget for the wave between 50 K and 150K.
b) The game multiplies the initial budget by an "AI difficulty" factor from the server's configuration. E.g. if this factor is 0.5 then you end up with a budget from 25 K to 50 K, and if this factor is 10 then you end up with a budget from 500 K to 1500K. This allows different servers to have different difficulty (e.g. "noob friendly servers" with weak pirates, and "hard core" servers with powerful pirates).
c) Then the game chooses if it wants "big ship with smaller ships" (30% chance) or "group of medium ships" (70% chance). For "big ship with smaller ships"; the game tries to find one ship worth half of the budget and subtracts its price from the budget.
d) Then the game picks a number from 1 to 6 to determine how many more ships will be in the wave; and does something like (pseudo-code):
while(ships > 0) {
desired_price = remaining_budget / ships;
new_ship = find_ship(desired_price);
ships--;
remaining_budget -= new_ship->price;
add_to_wave(new_ship);
}
The basic idea of that is to select 1 to 6 ships that are about the same price, without wasting too much of the budget. For example, with 100 K left to spend on 4 ships, you might end up with 2 ships worth 30K each plus 2 ships worth 20K each.