   return
 
 stepLevelSimulation = ->
-  if @commands.length == 0 and @mode == levelMode.FULLPLAYING
-    @mode = levelMode.PLAYING
-
-  if @current_command != null &&
-     @current_command >= 0 &&
-     @current_command < @commands.length
-    # TODO: errors for bad movement
-    @commands[@current_command].action(this)
-
-    @advanceCurrentCommand()
-
-    if @mode == levelMode.FULLPLAYING &&
-       @current_command == @commands.length
-      @mode = levelMode.TURNAROUND
+  # TODO: detect illegal moves (obstacles), show error
+  if @mode == levelMode.TURNAROUND
+    # NOTE: even TURNAROUND might fail if something hits you
     return true
-  else if @mode == levelMode.TURNAROUND
-    @mode = levelMode.REVPLAYING
-    @advanceCurrentCommand()
-    return true
-  else
-    return false
-
+
+  @commands[@next_command].action(this)
+  @advanceNextCommand()
+
+  return true
 
 setupLevel = (initial_bot_location, item_location) ->
   o =

level_cnv = document.getElementById('level')

prog_cnv = document.getElementById('program')

# stepLevelSimulation?
moveCommand = (level) ->
  switch level.mode
    when levelMode.PLAY, levelMode.PLAYFWD
      level.bot.xi += @dir.dx
      level.bot.yi += @dir.dy
      level.bot.dir = @dir.theta
    when levelMode.PLAYREV
      dir = reverseDir(@dir)
      level.bot.xi += dir.dx
      level.bot.yi += dir.dy
