Benoît Allard avatar Benoît Allard committed 68b5c05

Add the toolbox in the file format

Comments (0)

Files changed (9)

levels/0-tutorials/0-cargo101.txt

 0 ; init pos of crane 
 2 ; num of stacks
+- ; toolbox
+<V>1234
+
 - ; init setup
 y
 

levels/0-tutorials/1-transporter.txt

 0
 4
 -
+<V>1234
+
+-
 y
 
 

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

 0
 2
 -
+<V>1234
+
+-
 yyyy
 
 -

levels/0-tutorials/3-inverter.txt

 0
 6
 -
+>V<1234
+
+-
 brgy
 
 

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

 0
 3
 -
+>V<1234
+by.#
+-
 ybbbb
 
 

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

 0
 4
 -
+>V<1234
+
+-
 
 rrr
 ggg

levels/1-easy/0-double-flip.txt

+0
+3
+-
+>V<1234
+brgy.#
+-
+brgy
+
+
+-
+
+
+brgy
+-
+1:
+  [ V]
+  [#>]
+  [b>]
+  [.<]
+  [ 1]

levels/1-easy/1-double-flip.txt

-0
-3
--
-brgy
-
-
--
-
-
-brgy
--
-1:
-  [ V]
-  [#>]
-  [b>]
-  [.<]
-  [ 1]
 class StackTooHigh(Exception): pass
 
 class CargoBot(object):
-    def __init__(self, initpos, numstacks, init, goal):
+    def __init__(self, initpos, numstacks, toolbox, init, goal):
         self.initpos = initpos
         self.numstacks = numstacks
         self.init = init
                         self.crane.move_left()
                     elif code == '>':
                         self.crane.move_right()
-                    elif code in '1234':
+                    elif code in ('1','2','3','4'):
                         frames.append(pc)
                         pc = [int(code) - 1, -1]
             print self.asStr()
     if docklen <= 0:
         raise ValueError('docklen not strictly positive: %d' % docklen)
     # lines[2] should contains a '-' or such
-    init = lines[3:3+docklen]
+    toolbox = lines[3:4]
+    # line 4 should contains a '-' or such
+    init = lines[6:6+docklen]
     # line 3 + docken + 1 should contains a '-' or such
-    goal = lines[3+docklen+1:3+docklen+1+docklen]
+    goal = lines[6+docklen+1:6+docklen+1+docklen]
     # line 3 + docklen + 1 + docklen + 1 should contains a '-' or such
-    raw_code = lines[3+docklen+1+docklen+1:]
+    raw_code = lines[6+docklen+1+docklen+1:]
     code = [raw_code[0]]
     for line in raw_code[1:]:
         if line.startswith(' '):
             code.append(line)
         else:
             raise SyntaxError
-
-    return CargoBot(initpos, docklen, init, goal), code
+    return CargoBot(initpos, docklen, toolbox, init, goal), code
 
 import os
 
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.