TheoSwartz wrote:A question for anyone familiar with rule files and the "LifeHistory" rule: Why are there so many variables that are exactly the same in this file? Isn't that bad programming practice? For that matter there are a lot more redundancies in this code that I don't understand, but maybe understanding the variable part will clear up my confusion:
Code: Select all
var a={0,2,4,6}
var b={0,2,4,6}
var c={0,2,4,6}
var d={0,2,4,6}
var e={0,2,4,6}
var f={0,2,4,6}
var g={3,5}
var h={0,1,2}
var i={0,1,2,3,4,5,6}
var j={0,1,2,3,4,5,6}
var k={0,1,2,3,4,5,6}
var l={0,1,2,3,4,5,6}
var m={0,1,2,3,4,5,6}
var n={0,1,2,3,4,5,6}
var o={0,1,2,3,4,5,6}
var p={0,1,2,3,4,5,6}
var q={1,3,5}
var R={1,3,5}
var S={1,3,5}
var T={1,3,5}
var u={3,4,5}
The reason for the identical variables is that if one uses the exact same variable name multiple times in one line, it must stand for the same state value each time, whereas if one uses two differently-named variables that can take on the same range of states, they may stand for different states (e.g. 1,i,i,1,1,1,1,1,1,0 could be parsed as 1,2,2,1,1,1,1,1,1,0 or 1,5,5,1,1,1,1,1,1,0 (among other things), but not 1,2,5,1,1,1,1,1,1,1 (for example), but 1,i,j,1,1,1,1,1,1,1 could be parsed as any of the three). In this way, rule table variables behave more like mathematical variables than programming variables.
Hope that makes any sense.