function Grid(size,previousState){this.size=size;this.cells=previousState?this.fromState(previousState):this.empty();} Grid.prototype.empty=function(){var cells=[];for(var x=0;x=0&&position.x=0&&position.y