Scala: Josephus problem with Actors
would like to make next private[this], but it's then very tricky to set up


To achieve that, you can define the initial next person as a lazy val field, and then define a var locally in the act method:

case class Person(id: Int) extends Actor { Self =&gt;
  private[this] lazy val initialNext: Person = acts((id + 1) % N)
  ...
  def act {
    var next = initialNext


The initialization then simplifies to

val acts = 1 to N map Person
acts foreach { _.start }
acts(0) ! (1, null)