/** Recombination constructor. */ public EvoTrader(EvoTrader mom, EvoTrader dad) { super(uniqueId(), 0, 0); Market.log.println(name + " = " + mom.name + " * " + dad.name); genotype = new Genotype(mom.genotype, dad.genotype); genotype.mutate(0.0038); long mc = mom.cash / 4; long ma = mom.asset / 4; long dc = dad.cash / 4; long da = dad.asset / 4; mom.cash(-mc); mom.asset(-ma); dad.cash(-dc); dad.asset(-da); cash = mc + dc; asset = ma + da; sentiment = 2.0 * genotype.gene(0) - 1.0; }
@Override public int compareTo(EvoTrader that) { int difference = (int) (netAssetValue() - that.netAssetValue()); return difference; }