I'm currently trying to make an AI do something similar. Did you use a particular algorithm for this?