Travelling Salesdrone Bot Strategy

Here are some suggestions of strategies to improve your bot's performance.

Only submit a solution if you know it can win

Only submit a solution if you know it is better than the current best solution. The goal here is to save processing time. If you submit every solution you calculate, you lose time waiting for your code to be called again. If you only submit solutions that are better than the current best, you will be able to iterate through more possible solutions in the time available.

Nearest Neighbour

Pick a city and then travel to the next closest city that you haven't already visited. So for example if you have the following 10 city map:


Starting at city 'A' you can plot a reasonably good route around the cities by just going to the next closest city as shown below:


Make sure you keep track of the distance as you go around the cities to follow the rule of only submitting a route if you know it can win.

Swap your starting point

Using nearest neighbour try a different starting city as this will quite often lead to a different result which may or may not be better. So starting at city 'J' would yield the result below:


Reduce cross overs

Reducing the number of times you cross over your previous path can lead to a better solution. So if you use the nearest neighbour starting at city 'A' you can see that move 'C' to 'D' crosses move 'I' to 'A'.


If you swap these over ie 'C' to 'I' and 'D' to 'A' you will have a better solution as shown below:

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License