Commits

mcc committed f31c25f

Input scaffold

Comments (0)

Files changed (1)

 #define("giants", default=0, help="how many giants?", type=int)
 define("shelf_after", default=0, help="where is shelf?", type=int)
 define("shelf_size", default=0, help="how big is shelf?", type=int)
+define("input", default='', help="initialize state from log", type=str)
 define("norun", default=0, help="print and exit", type=int)
 define("debug", default=0, help="debug runlevel", type=int)
 define("debug_delay", default=0, help="debug: fake response delay", type=float)
 		self.specs[sid].report(post_obj)
 
 class Manager:
-	def __init__(self):
+	def __init__(self, input=None):
 		self.tanks = {}
 		self.alltanks = {}
-		for _i in range(options.tanks):
-			i = _i + 1
-			if options.debug > 0:
-				print("Generating tank %d" % i)
-			self.alltanks[i] = Genome(i)
-			if _i < options.shelf_size:
-				self.tanks[i] = self.alltanks[i]
+		if not input:
+			for _i in range(options.tanks):
+				i = _i + 1
+				if options.debug > 0:
+					print("Generating tank %d" % i)
+				self.alltanks[i] = Genome(i)
+				if _i < options.shelf_size:
+					self.tanks[i] = self.alltanks[i]
+		else:
+			node = input.firstChild
+			while node:
+				if node.nodeName == "init":
+					print("INIT")
+				elif node.nodeName == "twhy":
+					print("TWHY")
+				elif node.nodeName == "breed":
+					print("TWHY")
+				node = node.nextSibling
 	
 	def any(self, post_obj):
 		if player_hits(post_obj) > options.shelf_after:
 		global database
 		print("Will save to %s" % (options.database))
 		
+	input = None
+	if options.input:
+		print("Loading from %s" % (options.input))
+		with open(options.input) as f:
+			input_raw = f.read()
+			input_raw = ("<wrap>%s</wrap>" % input_raw)
+			input = xml.dom.minidom.parseString(input_raw)
+			if input:
+				input = input.firstChild # wrap			
+		
 	global m
-	m = Manager()
+	m = Manager(input)
 	
 	if options.norun:
 		print("BY REQUEST, WON'T RUN")
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.