Commits

Benoît Allard committed 9a14b3c

Solve two small mistakes

Comments (0)

Files changed (6)

levels/0-tutorials/1-transporter.txt

+0
+4
+-
+y
+
+
+
+-
+
+
+
+y
+-
+1:[ V][ >][ V][ 1]

levels/0-tutorials/2-re-curses.txt

+0
+2
+-
+yyyy
+
+-
+
+yyyy
+-
+1:[ V][ >][ V][ <][ 1]

levels/0-tutorials/3-inverter.txt

+0
+6
+-
+brgy
+
+
+
+
+
+-
+
+
+
+
+
+ygrb
+-
+1:
+  [ 2][ 2][ 2][ 2]
+  [ >]
+  [ 1]
+2:
+  [ V][ >][ V][ <]

levels/0-tutorials/4-from-beneath.txt

+0
+3
+-
+ybbbb
+
+
+-
+
+bbbb
+y
+-
+1:
+  [ V][#>][y>][.<][ 1]

levels/0-tutorials/5-go-left.txt

+0
+4
+-
+
+rrr
+ggg
+bbb
+-
+rrr
+ggg
+bbb
+
+-
+1:[ 4][ 4][ 4][ >][ 1]
+2:
+3:
+4:[ >][ V][ <][ V]
             for i in range(limit):
                 start = (i+1)*4 - 1
                 assert start >= 3, start
-                self.code[fn][i] = Instruction(line[start:start + 2])            
+                self.code[fn - 1][i] = Instruction(line[start:start + 2])
 
     def mainLoop(self):
         frames = []
-        pc = [1, 0]
+        pc = [0, 0]
         print self.asStr()
         while not self.dock.done():
             if self.function_finished(pc):
-                return False
+                if len(frames) == 0:
+                    return False
                 pc = frames.pop()
             else:
                 instruction = self.code[pc[0]][pc[1]]
                         self.crane.move_right()
                     elif code in '1234':
                         frames.append(pc)
-                        pc = [int(code), -1]
+                        pc = [int(code) - 1, -1]
             print self.asStr()
             pc[1] += 1
         return True
 
     def function_finished(self, pc):
-        if pc[0] == 4:
+        if pc[0] == 3:
             return pc[1] == 5
         return pc[1] == 8
 
             return self.contains.asStr()
         else:
             return "/-\\"
-            
-        
-            
+
+
+
 
 class Instruction(object):
     def __init__(self, str='  '):
             str = '  '
         self.modifier = str[0]
         self.code = str[1]
-        
+
 
 def parse(raw_prgm):
     """ remove comment, split parts """
     except IndexError:
         print "You must supply a filename"
         return 1
-    
+
     run(os.open(filename, os.O_RDONLY, 0777))
     return 0
 
 def target(*args):
     return entry_point, None
-    
+
 if __name__ == "__main__":
     import sys
     entry_point(sys.argv)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.