I've been researching the way the location of barbarian spawns is chosen.
The way this is performed is really bizarre (and I found at least two bugs in the code).
If there is exactly one human player, then they are placed as follows (I call this the SP algorithm):
A human city is selected at random, and then neighbours of this are selected at random repeatedly (essentially this generates a random walk around the map) for at most 4000 steps until it finds a land square not visible to the human player which is at least as far from the nearest human city as a given minimum distance, and then places the barbs there.
If there are zero or more than one human players, then they are placed as follows (I call this the MP algorithm):
Random squares on the map are chosen (for at most 400 attempts) until a land square is found which no player can see, and the barbs are placed there.
There are several problems with the SP algorithm:
Barbs will always be placed "just out of sight" for the human player, and whether other players can see the square is ignored (although this is a bug - it isn't supposed to be ignored). This is very unfair, and strange.
This method is likely to produce barbs on the borders between the human player and the AIs, exactly in the warzones where all the troops will be and so the barbs will probably be easily dealt with.
If that doesn't happen, then they will be placed just inside the neigbouring AI civs, possibly right next to their cities (in fact, it might try to place them inside their cities!) which is also not good.
The way in which the code randomly walks around in the SP algorithm is quite silly, and could easily result in it getting stuck and no barbs being produced when a large portion of the map is visible to the human player. This is particularly true on a map with much water.
Because of these problems, I suggest we strip out the SP algorithm and use the MP algorithm for all games - it seems sensible. It's implementation could probably be improved, but it's sufficient for the moment.
Some people have put forward more suggestions for barbarian camps, etc., but for the moment I'm primarily interested in what we should do in the short term.
The way this is performed is really bizarre (and I found at least two bugs in the code
If there is exactly one human player, then they are placed as follows (I call this the SP algorithm):
A human city is selected at random, and then neighbours of this are selected at random repeatedly (essentially this generates a random walk around the map) for at most 4000 steps until it finds a land square not visible to the human player which is at least as far from the nearest human city as a given minimum distance, and then places the barbs there.
If there are zero or more than one human players, then they are placed as follows (I call this the MP algorithm):
Random squares on the map are chosen (for at most 400 attempts) until a land square is found which no player can see, and the barbs are placed there.
There are several problems with the SP algorithm:
Barbs will always be placed "just out of sight" for the human player, and whether other players can see the square is ignored (although this is a bug - it isn't supposed to be ignored). This is very unfair, and strange.
This method is likely to produce barbs on the borders between the human player and the AIs, exactly in the warzones where all the troops will be and so the barbs will probably be easily dealt with.
If that doesn't happen, then they will be placed just inside the neigbouring AI civs, possibly right next to their cities (in fact, it might try to place them inside their cities!) which is also not good.
The way in which the code randomly walks around in the SP algorithm is quite silly, and could easily result in it getting stuck and no barbs being produced when a large portion of the map is visible to the human player. This is particularly true on a map with much water.
Because of these problems, I suggest we strip out the SP algorithm and use the MP algorithm for all games - it seems sensible. It's implementation could probably be improved, but it's sufficient for the moment.
Some people have put forward more suggestions for barbarian camps, etc., but for the moment I'm primarily interested in what we should do in the short term.
Comment