Really rudimentary training algorithm