Index: experiments/frams/capture-the-flag/data/scripts/capture-the-flag.expdef
===================================================================
--- experiments/frams/capture-the-flag/data/scripts/capture-the-flag.expdef	(revision 232)
+++ experiments/frams/capture-the-flag/data/scripts/capture-the-flag.expdef	(revision 233)
@@ -54,11 +54,11 @@
 }
 
-function onBorn()
-{
-  Creature.energ0 = 100;
-  Creature.energy = Creature.energ0;
-}
-
-function onDied()
+function onBorn(cr)
+{
+  cr.energ0 = 100;
+  cr.energy = cr.energ0;
+}
+
+function onDied(cr)
 {
   
@@ -87,37 +87,39 @@
 	//Create GenePool and Population for each team
 	GenePools.clear();
-	GenePool.name = "Team1";
-   	GenePool.fitness = "return this.user3;";
-   	while (GenePools[0].size > 0)
-   		GenePools[0].delete(0);
+	var pool=GenePools[0];
+	pool.name = "Team1";
+   	pool.fitness = "return this.user3;";
+   	while (pool.size > 0)
+   		pool.delete(0);
    	
 	Populations.clear();
-	Population.name = "Team1";
-	
-	while (Population.size > 0)
-			Population.delete(0);
-	
-	
-	
-	Population.selfmask = 0x50001;
-    Population.othermask = 0x60001;
+	var pop=Populations[0];
+	pop.name = "Team1";
+	
+	while (pop.size > 0)
+			pop.delete(0);
+	
+	
+	
+	pop.selfmask = 0x50001;
+    pop.othermask = 0x60001;
 	
 	var i = 2;
 	for (i = 2; i <= ExpParams.teamsno; i++){
-		Populations.addGroup("Team"+i);
-		Population.selfmask = 0x50001;
-    	Population.othermask = 0x60001;
-		GenePools.addGroup("Team"+i);
-		GenePool.fitness = "return this.user3;";	
+		pop=Populations.addGroup("Team"+i);
+		pop.selfmask = 0x50001;
+    	pop.othermask = 0x60001;
+		pool=GenePools.addGroup("Team"+i);
+		pool.fitness = "return this.user3;";	
 	}
 	
 	//Create GenePool for flags and fill it
-	GenePools.addGroup("Flags");
-	
-	GenePool.addGeno(Geno.newFrom("m:Vstyle=flag0\np:",48,"Flag","Single flag object"));
-	GenePool.addGeno(Geno.newFrom("m:Vstyle=flag1\np:",48,"Flag","Single flag object"));
-	GenePool.addGeno(Geno.newFrom("m:Vstyle=flag2\np:",48,"Flag","Single flag object"));
-	GenePool.addGeno(Geno.newFrom("m:Vstyle=flag3\np:",48,"Flag","Single flag object"));
-	GenePool.addGeno(Geno.newFrom("m:Vstyle=flag4\np:",48,"Flag","Single flag object"));
+	pool=GenePools.addGroup("Flags");
+	
+	pool.add(Geno.newFrom("m:Vstyle=flag0\np:",48,"Flag","Single flag object"));
+	pool.add(Geno.newFrom("m:Vstyle=flag1\np:",48,"Flag","Single flag object"));
+	pool.add(Geno.newFrom("m:Vstyle=flag2\np:",48,"Flag","Single flag object"));
+	pool.add(Geno.newFrom("m:Vstyle=flag3\np:",48,"Flag","Single flag object"));
+	pool.add(Geno.newFrom("m:Vstyle=flag4\np:",48,"Flag","Single flag object"));
 }
 
@@ -127,11 +129,11 @@
 	
 	//Reset all global points vectors
-	flagsX = Vector.new();
-	flagsY = Vector.new();
-	
-	points = Vector.new();
-	scored = Vector.new();
-	taken = Vector.new();
-	retrieved = Vector.new();
+	flagsX = [];
+	flagsY = [];
+	
+	points = [];
+	scored = [];
+	taken = [];
+	retrieved = [];
 	
 	//Init global vectors
@@ -201,23 +203,18 @@
 			Populations[team].delete(0);
 		
-		GenePools.group = ExpParams.teamsno;
-		GenePools.genotype = team;
+		var cr = Populations[team].add(GenePools[ExpParams.teamsno][team]);
+		placeFlag(cr);
+		cr.signals.add("Flag");
+		cr.signals[0].flavor = team;
+		cr.signals[0].power=1000;
+		cr.user1 = 0;
+		cr.user2 = 0;
+		cr.user3 = 0;
 		
-		Populations[team].createFromGenotype();
-		placeFlag(Populations[team][0]);
-		Creature.signals.add("Flag");
-		Creature.signals[0].flavor = team;
-		Creature.signals[0].power=1000;
-		Creature.user1 = 0;
-		Creature.user2 = 0;
-		Creature.user3 = 0;
-		
-		GenePools.group = team;
-
 		var crX, crY;
 		
 		for (player = 0; player < ExpParams.memberssno; player++){
-			GenePools.genotype = player % GenePool.size;
-			Populations[team].createFromGenotype();
+		        var pool=GenePools[team];
+			cr = Populations[team].add(pool[player % pool.size]);
 			crX = Math.random(30) - 15;
 			if (crX >=0 && crX < 5)
@@ -230,8 +227,8 @@
 			else if (crY > -5 && crY < 0)
 				crY = -5;
-			Creature.moveAbs(flagsX[team] + crX, flagsY[team] + crY, 0);
-			Creature.user1 = 0;
-			Creature.user2 = 0;
-			Creature.user3 = 0;
+			cr.moveAbs(flagsX[team] + crX, flagsY[team] + crY, 0);
+			cr.user1 = 0;
+			cr.user2 = 0;
+			cr.user3 = 0;
 		}
 	}
@@ -245,7 +242,7 @@
 			GenePools[team].delete(0);
 		if (team != 1)
-			GenePools[team].addGeno(Geno.newFrom("lllfffX[0:2.420, 2:-2, 1:-1][-1:1, 0:1, 0:-1][-1:1](RRlllfffMMMX[|-1:-10]lllFFFMMMX[|-2:-1], fffIXlllfffMMMsX[|6:10, 3:-10](RRlllfffMMMIX[|-4:-10]lllFFFMMMIX[|-5:-1][*], , RRlllfffMMMIX[|-7:10]lllFFFMMMIX[|-8:-1][*]), RRlllfffMMMX[|-10:10]lllFFFMMMX[|-11:-1.784])", 49, "Player", "Player"));
+			GenePools[team].add(Geno.newFrom("lllfffX[0:2.420, 2:-2, 1:-1][-1:1, 0:1, 0:-1][-1:1](RRlllfffMMMX[|-1:-10]lllFFFMMMX[|-2:-1], fffIXlllfffMMMsX[|6:10, 3:-10](RRlllfffMMMIX[|-4:-10]lllFFFMMMIX[|-5:-1][*], , RRlllfffMMMIX[|-7:10]lllFFFMMMIX[|-8:-1][*]), RRlllfffMMMX[|-10:10]lllFFFMMMX[|-11:-1.784])", 49, "Player", "Player"));
 		else if (team == 1)
-			GenePools[team].addGeno(Geno.newFrom("lllfffX[0:2.420, 2:-2, 1:-1][-1:1, 0:1, 0:-1][-1:1](RRlllfffMMMX[|-1:-10]lllFFFMMMX[|-2:-1], fffIXlllfffMMMsX[|1:1][Thr2,lo:-0.75,hi:0.75,t:0.75,3:-10,6:10](RRlllfffMMMIX[|-4:-10]lllFFFMMMIX[|-5:-1][FlagDef,opp:0,my:1], , RRlllfffMMMIX[|-7:10]lllFFFMMMIX[|-8:-1][FlagDef,opp:0,my:1]), RRlllfffMMMX[|-10:10]lllFFFMMMX[|-11:-1.784])", 49, "Inteligent Player", "Inteligent Player"));
+			GenePools[team].add(Geno.newFrom("lllfffX[0:2.420, 2:-2, 1:-1][-1:1, 0:1, 0:-1][-1:1](RRlllfffMMMX[|-1:-10]lllFFFMMMX[|-2:-1], fffIXlllfffMMMsX[|1:1][Thr2,lo:-0.75,hi:0.75,t:0.75,3:-10,6:10](RRlllfffMMMIX[|-4:-10]lllFFFMMMIX[|-5:-1][FlagDef,opp:0,my:1], , RRlllfffMMMIX[|-7:10]lllFFFMMMIX[|-8:-1][FlagDef,opp:0,my:1]), RRlllfffMMMX[|-10:10]lllFFFMMMX[|-11:-1.784])", 49, "Inteligent Player", "Inteligent Player"));
 	}
 }
@@ -257,13 +254,13 @@
 	//Update flags position if taken and cooldown if recently retrieved
 	for (team = 0; team < Populations.size; team++){
-		Populations.group = team;
-		Populations.creature = 0;
-		if (Creature.user3 > 0)
-			Creature.user3 -= 1;
+	        var pop=Populations[team];
+
+		if (pop[0].user3 > 0)
+			pop[0].user3 -= 1;
 		
-		for (player = 1; player < Population.size; player++){
-			Populations.creature = player;
-			if (Creature.user1 == 1){
-				Creature.user2.moveAbs(Creature.pos_x, Creature.pos_y, Creature.size_z + 1);
+		for (player = 1; player < pop.size; player++){
+			var cr=pop[player];
+			if (cr.user1 == 1){
+				cr.user2.moveAbs(cr.pos_x, cr.pos_y, cr.size_z + 1);
 			}
 		}
@@ -286,5 +283,5 @@
 
 function placeFlag(flag){
-	flag.moveAbs(flagsX[flag.group.index], flagsY[flag.group.index], 0);
+	flag.moveAbs(flagsX[flag.population.index], flagsY[flag.population.index], 0);
 }
 
@@ -295,5 +292,5 @@
 	
 	//Take flag by changing its flavour and setting flag in player and player in flag fields
-	flag.signals[0].flavor = flag.group.index + 100;
+	flag.signals[0].flavor = flag.population.index + 100;
 	flag.user1 = 1;
 	flag.user2 = creature;
@@ -307,6 +304,6 @@
 	
 	//Update team points and events
-	points.set(creature.group.index, points[creature.group.index] + ExpParams.pointsCapture);
-	taken.set(creature.group.index, taken[creature.group.index] + 1);
+	points[creature.population.index] = points[creature.population.index] + ExpParams.pointsCapture;
+	taken[creature.population.index] = taken[creature.population.index] + 1;
 
 }
@@ -314,5 +311,5 @@
 function retrieveFlag(flag, creature){
 	//Retrieve flag by changing its flavour and deleting it from player and player from flag
-	flag.signals[0].flavor = flag.group.index;
+	flag.signals[0].flavor = flag.population.index;
 	flag.user1 = 0;
 	
@@ -333,11 +330,11 @@
 	
 	//Update team scores
-	points.set(creature.group.index, points[creature.group.index] + ExpParams.pointsRetrieve);
-	retrieved.set(creature.group.index, retrieved[creature.group.index] + 1);
+	points[creature.population.index] = points[creature.population.index] + ExpParams.pointsRetrieve;
+	retrieved[creature.population.index] = retrieved[creature.population.index] + 1;
 }
 
 function scoreFlag(flag, creature){
 	//Put the flag back on its spot and delete references between player and flag
-	creature.user2.signals[0].flavor = creature.user2.group.index;
+	creature.user2.signals[0].flavor = creature.user2.population.index;
 	creature.user2.user1 = 0;
 	creature.user2.user2 = 0;
@@ -354,6 +351,6 @@
 	
 	//Update team points
-	points.set(creature.group.index, points[creature.group.index] + ExpParams.pointsScoring);
-	scored.set(creature.group.index, scored[creature.group.index] + 1);
+	points[creature.population.index] = points[creature.population.index] + ExpParams.pointsScoring;
+	scored[creature.population.index] = scored[creature.population.index] + 1;
 }
 
@@ -385,11 +382,11 @@
 	if (colFlag == 1){
 		//Collision with my flag which is taken
-		if (flag.group.index == creature.group.index && flag.user1 == 1){
+		if (flag.population.index == creature.population.index && flag.user1 == 1){
 			retrieveFlag(flag, creature);
 		} //Collision with my flag which is not taken while carrying another team's flag 
-		else if (flag.group.index == creature.group.index && flag.user1 == 0 && creature.user1 == 1 && flag.user3 != 1){
+		else if (flag.population.index == creature.population.index && flag.user1 == 0 && creature.user1 == 1 && flag.user3 != 1){
 			scoreFlag(flag, creature);
 		} //Collision with another team's flag which is not taken while not carrying any flag 
-		else if (flag.group.index != creature.group.index && flag.user1 == 0 && creature.user1 == 0 && flag.user3 != 1){
+		else if (flag.population.index != creature.population.index && flag.user1 == 0 && creature.user1 == 0 && flag.user3 != 1){
 			takeFlag(flag, creature);
 		}
@@ -398,9 +395,9 @@
 	else {
 		//Players of different teams
-		if (c1.group.index != c2.group.index){
+		if (c1.population.index != c2.population.index){
 			//If player 1 has a flag ...
 			if (c1.user1 == 1){
 				// ... and the flag is of my team ...
-				if (c2.group.index == c1.user2.group.index){
+				if (c2.population.index == c1.user2.population.index){
 					//... retrieve it
 					retrieveFlag(c1.user2, c2);
@@ -410,5 +407,5 @@
 			if (c2.user1 == 1){
 				// ... and the flag is of my team ...
-				 if (c1.group.index == c2.user2.group.index){
+				 if (c1.population.index == c2.user2.population.index){
 					//... retrieve it
 					retrieveFlag(c2.user2, c1);
