Skip to content

My own quick solution to the famous "Traveling Salesman Problem" using Unity C#

Notifications You must be signed in to change notification settings

synthercat/Traveling-Salesman-Algorithm-for-Unity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Traveling-Salesman-Algorithm-for-Unity

Status : Testing fun project

Description

This is my own implementation of solving the Traveling Salesman Problem. I thought it would make a good exercise to see if I could figure out an algorithm that solves this without referring to any known solutions.

Screenshot

tsp01 tsp02

Usage

Here is what my script does:

  • It creates a random board of destinations (Vector2).
  • It generates a board on the screen and sets the orthographic camera accordingly as well as the size of the destinations according to how close the closest ones are.
  • It goes through combinations of different ways to travel through all destinations.
  • It draws the optimal route using a Line Renderer found on the home marker.

I also included a complete example in the TSP.unitypackage file

Tip

I do not suggest solving it with more than 10 stops as it will get the app stuck for a bit.

Note

This is not an optimized solution. It's just something I did for fun (and I did had fun!). It helped me figure out how to solve problems with loops that take a long time to finish. Those solutions are not part of that version though, they were implemented on another project of mine.

About

My own quick solution to the famous "Traveling Salesman Problem" using Unity C#

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages