// xover

objref parent[2], xdice
parent[0] = new Vector()
parent[1] = new Vector()
xdice = new Random()

proc xover() {local xlength, xpoint
		
	parent[0] = genome[$1].newgene.c
	parent[1] = genome[$2].newgene.c
	
	if (genome[$1].newgene.size() > genome[$2].newgene.size()) { 
			xlength = genome[$2].newgene.size()-2 } else { 
			xlength = genome[$1].newgene.size()-2 }
	
	xpoint = int(xdice.uniform(1, xlength))
	
	genome[$1].newgene.resize(0)
	genome[$1].newgene.append(parent[0].at(0, xpoint-1), parent[1].at(xpoint,parent[1].size()-1))
	
	genome[$2].newgene.resize(0)
	genome[$2].newgene.append(parent[1].at(0, xpoint-1), parent[0].at(xpoint,parent[0].size()-1))
	
//	print "Xover between ", $1," and ", $2, " at point: ", xpoint
}