thought algorithm