public void Execute(int index) { var state = CellStates[index]; var neighborsBits = countbits(state & CellNeighborsMask); var cellStates = new int4x3( new int4(state >> 22, state >> 21, state >> 20, state >> 19), new int4(state >> 16, state >> 15, state >> 14, state >> 13), new int4(state >> 10, state >> 9, state >> 8, state >> 7)); //Check if cell has [3 alive neighbors] or [2 live neighbors + current cell state = isAlive], first bit will be 1 var conwaysLifeRule = (neighborsBits >> 1) & (neighborsBits | cellStates); //set cell state to die if neighbors count more 3 conwaysLifeRule &= ~((neighborsBits >> 2) | (neighborsBits >> 3)); //clear all bits except first conwaysLifeRule &= 1; conwaysLifeRule.c0.x <<= 22; conwaysLifeRule.c0.y <<= 21; conwaysLifeRule.c0.z <<= 20; conwaysLifeRule.c0.w <<= 19; conwaysLifeRule.c1.x <<= 16; conwaysLifeRule.c1.y <<= 15; conwaysLifeRule.c1.z <<= 14; conwaysLifeRule.c1.w <<= 13; conwaysLifeRule.c2.x <<= 10; conwaysLifeRule.c2.y <<= 9; conwaysLifeRule.c2.z <<= 8; conwaysLifeRule.c2.w <<= 7; CellStates[index] = csum(conwaysLifeRule); }
public void Execute(int index) { var state = CellStates[index]; var state4x3 = new int4x3(state); var neighborsBits = ((state4x3 >> 7) & CellBitMask) + ((state4x3 >> 6) & CellBitMask) + ((state4x3 >> 5) & CellBitMask) + ((state4x3 >> 1) & CellBitMask) + ((state4x3 << 1) & CellBitMask) + ((state4x3 << 5) & CellBitMask) + ((state4x3 << 6) & CellBitMask) + ((state4x3 << 7) & CellBitMask); //Check if cell has [3 alive neighbors] or [2 live neighbors + current cell state = isAlive], first bit will be 1 var conwaysLifeRule = (neighborsBits >> 1) & (neighborsBits | state); //set cell state to die if neighbors count more 3 conwaysLifeRule &= ~((neighborsBits >> 2) | (neighborsBits >> 3)); CellStates[index] = csum(conwaysLifeRule & CellBitMask); }
private static void CustomVisit(ref int4x3 i) { LogVisit(i); GUILayout.Label(name); EditorGUI.indentLevel++; var field0 = EditorGUILayout.Vector4Field("", ConvertToVector4(i[0])); var field1 = EditorGUILayout.Vector4Field("", ConvertToVector4(i[1])); var field2 = EditorGUILayout.Vector4Field("", ConvertToVector4(i[2])); i[0] = ConvertVector4ToInt4(field0); i[1] = ConvertVector4ToInt4(field1); i[2] = ConvertVector4ToInt4(field2); EditorGUI.indentLevel--; }
public static void AreEqual(int4x3 a, int4x3 b) { AreEqual(a.c0, b.c0); AreEqual(a.c1, b.c1); AreEqual(a.c2, b.c2); }
public static void AreEqual(int4x3 expected, int4x3 actual) { AreEqual(expected.c0, actual.c0); AreEqual(expected.c1, actual.c1); AreEqual(expected.c2, actual.c2); }
public fp4x3(int4x3 v) { this.c0 = (fp4)v.c0; this.c1 = (fp4)v.c1; this.c2 = (fp4)v.c2; }
public static fp4x3 fp4x3(int4x3 v) { return(new fp4x3(v)); }