Good idea to start the discussion with gold collection.
I started also with 4 areas. Easiest way to assign the items to peons.
Great for 4 peons, or 2.
For 5 and 6, I also put them in the middle, overlapping the first areas. Not the best, but efficient the first week.
And for 3 peons, not good at all. And it was not possible to overlap the regions.
So I changed the strategy using a big table : For each peons.length = n, I define the n centers, correctly placed on the grid, and a radius for the region. So Iām able to spread region as I want based on n.
And in a loop for each peon, I assign him a region center, and I loop through all the items to measure the distance from the item to his center.
If the distance is too high (>radius), abandon the item for this peon, out of zone.
So I have round shape areas for each of them, with little overlapping on the edge.
For each Item in the circle, I calculate a value based on : Distance to peon, Distance to center, gold value, andā¦ the age of the item.
For the last point, I remark that new items are added at the beginning of the table. The idea is that : if an item is old, maybe itās in an area not visited for long, so maybe there is a lot of other item around not visited, so maybe itās a good idea to go there. Itās interesting at the begining of the battle, when there is not a lot of peons, and a lot of items.
These 4 parameters are mixed with constant to equilibrate the finale value, to find the best target in the area.
Theses constants could be different based on the number of peon at a given time. It ends up in a formula very difficult to fine tune, depending of the enemy, and of the seed. And you have to test and try a lot to get the idea of the best overall config (maybe not the most interesting part of the job).
I did not take advantage of the 5 meters circle to take item. My understanding is that : as soon as the peon enter the circle, It will take the item, so itās not in the list anymore, so the peon will go to another destination. He donāt have to really go to the center. Ok, If you know the 2 most interesting items, maybe you can optimize a little bit (but itās too complex for me ).
I tryed multiple very good ideas that all ends up in lower ranking.
Last optimization : avoid two peons to target the same item. Itās possible in my code because of the region overlap. And this management is critical when you have 6 peons, because you have only 3 or 4 items on the whole grid. Not so simple, it reach me very close to 4000 statements with 3 peons and 40 or 50 items, and it adds a lot of code not very efficient.
Also, when no target, the peon return to the center of itās area (like a spider
I think thatās all for the most important part of the game. Compared to it, building troops was just fun.
Iām curious if someone have a complete different approach, without areas for each peon. With just an algorithm to avoid them to go all in the same corner.