If you are closest to the apple, you should walk to get it, but if you are far from the apple, your best chance is in the middle of the map, you should find a strategy to take the middle of the map.
You can divide the map into four scaling (clockwise), upper left, upper right, lower right and lower left (1,2,3,4). We check this between two snakes: if the apple is currently on an enlarged scale of 1 (suppose the average is average) and you are in the center of the map, your opponent may be on a scale of 1,2,3,4 (again suppose that it is at the center of this scaling to average more easily) if it has an enlarged scale of 1, it has a better chance (1-0), if it has an increase of 2 or 4, your distance is sqrt (2) / 2, and the distance your opponent is 1, so you are closest, and finally, if your opponent is 3 on a larger scale, your distance is sqrt (2) / 2, and the distance of your opponent - sqrt (2), so in 3 cases, with one opponent you have a better chance.
But since your figure has several blocks, you must calculate the center position in a different way, in fact, for each point in your grid, its distance to all other points is calculated. it takes 60 ^ 2 * 60 ^ 2, which can be done quickly. and find the cells with the minimum amounts (you can choose the best 10 cells), these cells can be your centers, every time you have to move from one center to another (except when you are closest to an apple or your snake eats an apple and wants centers).
source share