implement AI algorithm