define(["cell"], function(cell) {
  var World = function(options) {
    this.cells = [];
    this.rows = options.rows;
    this.columns = options.columns;
    this.worldElement = options.world;
    this.cellTemplate = options.cellTemplate;
    this.options = options;
    this.init();
    this.associateCells();
  }

  World.prototype.associateCells = function() {
    for (var row = 0; row < this.rows; row++) {
      this.cells[row] = new Array(this.columns);
    }
    var self = this;
    $(self.worldElement + " td").each(function(index) {
      row = parseInt(index / self.columns);
      column = index % self.columns;
      self.cells[row][column] = cell.spawn(this, row, column);
      var x = 0;
    });
  };

  World.prototype.hasLiveCells = function() {
    return this.liveCells ? (this.liveCells.length > 0 ? true : false) : false;
  };

  World.prototype.markLiveCells = function(cell) {
    if (typeof this.liveCells === 'undefined') {
      this.liveCells = new Array()
    }
    this.liveCells.push(cell);
  };

  World.prototype.init = function() {
    var world = $(this.worldElement);
    world.html("");
    for (var rowIndex = 0; rowIndex < this.rows; rowIndex++) {
      var rowContent = "<tr>"
      for (var columnIndex = 0; columnIndex < this.columns; columnIndex++) {
        rowContent += this.cellTemplate;
      }
      world.append(rowContent + "</tr>");
    }
  };

  World.prototype.redraw = function() {
    for (var row = 0; row < this.cells.length; row++) {
      for (var column = 0; column < this.cells[row].length; column++) {
        var currentCell = this.getCellAt(row,column);
        currentCell.redraw();
      }
    }
  };

  World.prototype.getCellAt = function (row, column) {
    return this.cells[row][column];
  };

  World.prototype.getLivingNeighborsForCellAt = function(row, column) {
    var currentCell = this.getCellAt(row, column);
    var neighbors = currentCell.getNeighbors(this.rows, this.columns);
    var livingNeighbors = []
    for (var i = 0; i < neighbors.length; i++) {
      neighborCell = this.getCellAt(neighbors[i][0], neighbors[i][1]);
      if (neighborCell.isAlive) {
        livingNeighbors.push(neighborCell);
      }
    }
    return livingNeighbors;
  };

  return {
    map: function(options) {
      return (new World(options));
    }
  }
});

@@ -65,29 +65,8 @@
 ) %7B%0A
-    this.cells = %5B%5D;%0A
     
@@ -225,43 +225,404 @@
 his.
-options = options;%0A    this.init();
+init();%0A  %7D%0A%0A  World.prototype.init = function() %7B%0A    var worldElement = $(this.worldElement);%0A    worldElement.html(%22%22);%0A    for (var rowIndex = 0; rowIndex %3C this.rows; rowIndex++) %7B%0A      var rowContent = %22%3Ctr%3E%22%0A      for (var columnIndex = 0; columnIndex %3C this.columns; columnIndex++) %7B%0A        rowContent += this.cellTemplate;%0A      %7D%0A      worldElement.append(rowContent + %22%3C/tr%3E%22);%0A    %7D
 %0A   
@@ -644,24 +644,25 @@
 Cells();%0A  %7D
+;
 %0A%0A  World.pr
@@ -707,106 +707,24 @@
     
-for (var row = 0; row %3C this.rows; row++) %7B%0A      this.cells%5Brow%5D = new Array(this.columns);%0A    %7D
+this.cells = %7B%7D;
 %0A   
@@ -803,16 +803,20 @@
 %7B%0A      
+var 
 row = pa
@@ -851,16 +851,20 @@
 ;%0A      
+var 
 column =
@@ -896,31 +896,19 @@
     
-self.cells%5Brow%5D%5Bcolumn%5D
+var newCell
  = c
@@ -947,17 +947,45 @@
     
-var x = 0
+self.cells%5BnewCell.getId()%5D = newCell
 ;%0A  
@@ -1316,36 +1316,38 @@
 World.prototype.
-init
+redraw
  = function() %7B%0A
@@ -1358,572 +1358,87 @@
 var 
-world
+cells
  = 
-$(
 this.
-worldElement);%0A    world.html(%22%22);%0A    for (var rowIndex = 0; rowIndex %3C this.rows; rowIndex++) %7B%0A      var rowContent = %22%3Ctr%3E%22%0A      for (var columnIndex = 0; columnIndex %3C this.columns; columnIndex++) %7B%0A        rowContent += this.cellTemplate;%0A      %7D%0A      world.append(rowContent + %22%3C/tr%3E%22);%0A    %7D%0A  %7D;%0A%0A  World.prototype.redraw = function() %7B%0A    for (var row = 0; row %3C this.cells.length; row++) %7B%0A      for (var column = 0; column %3C this.cells%5Brow%5D.length; column++) %7B%0A        var currentCell = this.getCellAt(row,column);%0A        currentCell
+cells;%0A    Object.keys(cells).map(function(key) %7B%0A      cells%5Bkey%5D
 .red
@@ -1448,25 +1448,19 @@
 ();%0A    
-  %7D%0A    %7D
+%7D);
 %0A  %7D;%0A%0A 
@@ -1539,13 +1539,29 @@
 lls%5B
-row%5D%5B
+%22cell%22 + row + %22_%22 + 
 colu

Store cells inside hash for faster retrieval