#!/usr/bin/python
# -*- coding: UTF-8 -*-
import random
import sys
import os
import time
import turtle
turtle.screensize(800,600, "seashell")
turtle.pensize(16)
turtle.pencolor('tomato')
points = []
for i in range(16):
points.append([])
for j in range(16):
points[i].append(' ')
points[0][0] = '↓'
turtle.goto(2,2)
turtle.pendown()
turtle.speed(10)
aPath = [{'x': 0, 'y': 0, 'd': 0, 't':'↓'}]
while True:
if len(aPath) == 0:
break
item = aPath.pop( random.randint(max(0,len(aPath)-3), len(aPath)-1))
tD = []
turtle.goto(item['x']*20+2,item['y']*20+2)
turtle.pendown()
if item['x']+1 < 16 and points[item['x']+1][item['y']] == ' ':
tD.append({'x':item['x']+1, 'y':item['y'],'t':'→'})
if item['x'] == 0:
tD.append({'x':item['x']+1, 'y':item['y'],'t':'→'})
if item['x']-1 >= 0 and points[item['x']-1][item['y']] == ' ':
tD.append({'x':item['x']-1, 'y':item['y'],'t':'←'})
if item['x'] == 2:
tD.append({'x':item['x']-1, 'y':item['y'],'t':'←'})
if item['y']+1 < 16 and points[item['x']][item['y']+1] == ' ':
tD.append({'x':item['x'], 'y':item['y']+1,'t':'↓'})
if item['y'] == 0:
tD.append({'x':item['x'], 'y':item['y']+1,'t':'↓'})
if item['y']-1 >= 0 and points[item['x']][item['y']-1] == ' ':
tD.append({'x':item['x'], 'y':item['y']-1,'t':'↑'})
if item['y'] == 3:
tD.append({'x':item['x'], 'y':item['y']-1,'t':'↑'})
if len(tD) > 0:
aPath.append(item)
r = random.randint(0, len(tD)-1)
points[tD[r]['x']][tD[r]['y']] = tD[r]['t']
if tD[r]['t'] == '→':
turtle.setheading(0)
if tD[r]['t'] == '←':
turtle.setheading(180)
if tD[r]['t'] == '↓':
turtle.setheading(90)
if tD[r]['t'] == '↑':
turtle.setheading(270)
turtle.forward(22)
aPath.append({'x': tD[r]['x'], 'y': tD[r]['y'], 'd': r})
turtle.penup()
sys.stdin.readline()