// Genetic Ant // Carl E. Bredlau // January, 1997 // from Koza, _Genetic Programming_, MIT Press // programmed modeled after sga. Thanks to the author. package geneticAnt; public class Gene implements Cloneable { // In a partircular Gene determines what the ant will do: // next state: int state = 0; // Ant Actions public static final int MOVE = 0; public static final int LEFT = 1; public static final int RIGHT = 2; public static final int NOP = 3; // For future use int action = 0; protected Object clone() { Gene g; try { g = (Gene) super.clone(); } catch (CloneNotSupportedException e) { // cannot happen so throw new InternalError(e.toString()); } return g; } public static void main(String args[]){ Gene g = new Gene(); g.state = 100; Gene g1 = (Gene) g.clone(); System.out.println(g.state + " " + g1.state); g.state = 200; System.out.println(g.state + " " + g1.state); g1.state = 300; System.out.println(g.state + " " + g1.state); } }