Philipp Tiefenbacher avatar Philipp Tiefenbacher committed 7d65c7b

improved module division with clifford

Comments (0)

Files changed (2)

hackathonAlpha.html

 		#ifdef GL_ES
 		precision highp float;
 		#endif
+
+		#define XSIZE 499.0
+		#define YSIZE 399.0
+		#define SCALE 5.0
+		#define BORDER 2.0
+
+		#define XPIXELSIZE (1.0/XSIZE)
+		#define YPIXELSIZE (1.0/YSIZE)
+
 		uniform sampler2D texFrame;
 		varying vec2 vTexCoord;
 		void main(void) {
 			vec2 vCT;
-			vCT.x = vTexCoord.x/3.;
-			vCT.y = vTexCoord.y/3.;
-			int xmod = int(vTexCoord.x * 499.0);
-			int xmm = xmod / 3;
-			xmod = xmod - (xmm * 3);
+			vCT.x = vTexCoord.x/5.;
+			vCT.y = vTexCoord.y/5.;
 
-			int ymod = int(vTexCoord.y * 399.0);
-			int ymm = ymod / 3;
-			ymod = ymod - (ymm * 3);
+			float xFMod = mod(vTexCoord.x, SCALE*XPIXELSIZE);
+			float yFMod = mod(vTexCoord.y, SCALE*YPIXELSIZE);
 
-			if (xmod == 0 || ymod == 0)
+			//int xmod = int(vTexCoord.x * 499.0);
+			//int xmm = xmod / 5;
+			//xmod = xmod - (xmm * 5);
+			//xmod = xmod % 5;
+
+			//int ymod = int(vTexCoord.y * 399.0);
+			//int ymm = ymod / 5;
+			//ymod = ymod - (ymm * 5);
+
+			//if (xmod == 0 || ymod == 0)
+			if (xFMod <= XPIXELSIZE*BORDER || yFMod <= YPIXELSIZE*BORDER)
 			{
 				gl_FragColor = vec4(0.,0.,0.,1.);
 			}
 	//"http://dl.dropbox.com/u/2297128/22C3_avgextgrowers_cooler",
 	//"http://dl.dropbox.com/u/2297128/Moore4-avg3-sweetship",
 	"rules/moore4_wave",
-	//"ccc_rules/ecoli16",
+	//"rules/ecoli16",
 	//"ccc_rules/annegret2", 
 	//"ccc_rules/g2adapded", 
 	//"ccc_rules/moore5-explosionz-spaceshyp-boxedin-mut",
 			var newRule = myClone(rule);
 			newRule.ruleTable = new Uint8Array(rule.ruleTable);
 		
-			EvoCell.mutateEvoCellRule(newRule, mutReg, mutTarget, getRandInt(20, mutTimes));
+			EvoCell.mutateEvoCellRule(newRule, mutReg, mutTarget, mutTimes);
 			caSims[i].setRule(newRule);
 		}
 		else
 		
 		container.appendChild(div);
 		
-		new Draggable(div);
+		//new Draggable(div);
 	}
 	return canvas;
 }

src/evocellweb.js

 	return evalRegexpr(r, evoCellData);
 }
 
+/*
+function evalAllRegexpr(r, evoCellData) 
+{
+	if (r == "?")
+	{
+		var i = 0;
+		return function(restart) {
+			if (restart == true)
+			{
+				i = 0;
+			}		
+			val retVal = i;
+			i++;
+			return retVal;
+		};
+	}	
+	else
+		return function(restart) { 
+			return parseInt(r); 
+		};
+}
+
+function evalTargetRegexpr(r, evoCellData, vals)
+{
+	if (r.length > 0 && r[0]=='n')
+	{
+		var idx = r.substr(1);
+		return function(restart, vals) { return vals[parseInt()];
+	}
+	if (r.length > 0 && r[0]=='a')
+	{
+		var sum = parseInt(r.substr(1));
+
+		for (var i = 0; i < vals.length; i++)
+		{	
+			sum += vals[i];
+		}
+		var zS = Math.floor(sum/vals.length);
+		return zS;
+	}
+	return evalRegexpr(r, evoCellData);
+}
+*/
+
+EvoCell.mutateAllEvoCellRule = function(evoCellData, regExprs, targetRegExpr, n)
+{
+	for (var i = 0; i < n; i++)
+	{
+		var nr = 0;
+		var vals = [];
+		for (var j = 0; j < evoCellData.nrNeighbours; j++)
+		{
+			nr = evalRegexpr(regExprs[j], evoCellData);
+			vals.push(nr);
+		}
+				
+		var targetState = evalTargetRegexpr(targetRegExpr, evoCellData, vals);
+		mutRotSym(evoCellData, vals, targetState);
+	}
+}
+
+
 EvoCell.mutateEvoCellRule = function(evoCellData, regExprs, targetRegExpr, n)
 {
 	for (var i = 0; i < n; i++)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.