Skip to content

Commit

Permalink
Changed the boardList type to be a IndexedSeq per Roland's feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
apeshimam committed Aug 4, 2011
1 parent 8ffa235 commit beee6b5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main/scala/akka/tutorials/conway/Board.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import scala.collection.mutable.Map
*/
class Board(xSize:Int, ySize:Int, displayRef:ActorRef, controllerRef:ActorRef, maxRounds: Int) extends Actor{

var boardList = List[Array[Array[Boolean]]]()
var boardList = IndexedSeq[Array[Array[Boolean]]]()

val messageCountPerRound = Map[Int, Int]()

Expand All @@ -28,8 +28,10 @@ class Board(xSize:Int, ySize:Int, displayRef:ActorRef, controllerRef:ActorRef, m

def receive = {
case CellToBoard(alive:Boolean, round:Int, x:Int, y:Int) => {
if (boardList.size <= round)
boardList = boardList :+ createBoard()
if (boardList.size <= round) {
boardList ++= Seq.fill(round - boardList.size + 1)(createBoard())
}

// Set the alive or dead
boardList(round)(x)(y) = alive

Expand Down

0 comments on commit beee6b5

Please sign in to comment.