Esempio n. 1
0
        (current[0] != maze.size[0])) and ((current[1] != 0) and
                                           (current[1] != maze.size[1])):
        maze.set(current, ' ')

    # Direction shit. I'm writing this at 12:44AM while listening to Radiohead - Sepeartor
    # Needless to say I have no f*****g idea why it works...
    if (direction is 0) or (direction is 2):
        visited.append(around[1])
        visited.append(around[3])
    else:
        visited.append(around[0])
        visited.append(around[2])

    # Move on!
    path.append(current)
    current = maze.advance(current, direction)

# Now we need to place the start/finish points
# Find the midpoints
midX = maze.size[0] / 2
midY = maze.size[1] / 2

# Now let's find a point in the top left that's suitable
for y in range(midY):
    for x in range(midX):
        coord = (x, y)
        scan = maze.scan(coord)
        if scan.count('#') is 3 and scan.count(' ') is 1:
            maze.set(coord, 'S')
            maze.start = coord
            break
Esempio n. 2
0
	try:
		finish = around.index('F')
		# Mark off the last breadcrumb
		maze.set(current, '.')
		solved = True
		break
	except ValueError:
		pass
	
	# Guess not, let's go on
	try:
		direction = around.index(' ')
		# Place a breadcrumb and move forward one space in that direction
		if maze.get(current) != 'S':
			maze.set(current, '.')
		current = maze.advance(current, direction)
	except ValueError:
		# There's no space, so we're going to have to go back a space
		try:
			direction = around.index('.')
			# Place an explored breadcrumb and go back
			maze.set(current, '-')
			current = maze.advance(current, direction)
		except ValueError:
			print("Something went wrong! ", current)
			maze.debug()
			sys.exit(1)

mazec = ""
for line in maze.maze:
	for char in line: