Commit 36a0f8ab authored by gijs's avatar gijs

Added python files

parent dd3c310c
# % coordinates
# z1 =
# z2 =
# z3 =
import random
# points = [(0, 0), (2, 5), (4, 0), (1, 1), (3, 1)]
points = [(random.randint(0, 5), random.randint(0, 10))
for i in range(random.randint(2, 5))]
def pickpoint(points):
return 'p{0}'.format(random.randint(0, len(points) - 1))
def pickdirection():
return random.choice(['(1,0)', '(1,1)', '(1, -1)', '(-1, 1)', '(-1, -1)', '(-1,0)', '(0,1)', '(0,-1)'])
mpost = 'draw {0}{{{1}}}'.format(pickpoint(points), pickdirection())
for step in range(random.randint(3, 10)):
direction = pickdirection()
target = pickpoint(points)
mpost += '..{0}{{{1}}}'.format(pickpoint(points), pickdirection())
print """u := 1cm;
pair p[];
beginfig(1)"""
for key, point in enumerate(points):
print "p{0} = ({1}u, {2}u);".format(key, point[0], point[1])
print mpost + ';'
print """for i=0 upto {0}: draw p[i] withpen pencircle scaled .15u;endfor;
endfig;
end;
""".format(len(points) - 1)
# % coordinates
# z1 =
# z2 =
# z3 =
points = [(0, 0), (2, 5), (4, 0), (1, 1), (3, 1)]
import random
def pickpoint(points):
return 'p{0}'.format(random.randint(0, len(points) - 1))
def pickdirection():
return random.choice(['left', 'right', 'up', 'down'])
mpost = 'draw {0}{{{1}}}'.format(pickpoint(points), pickdirection())
for step in range(random.randint(3, 10)):
direction = pickdirection()
target = pickpoint(points)
mpost += '..{0}{{{1}}}'.format(pickpoint(points), pickdirection())
print """u := 1cm;
pair p[];
beginfig(1)"""
for key, point in enumerate(points):
print "p{0} = ({1}u, {2}u);".format(key, point[0], point[1])
print mpost + ';'
print """for i=0 upto {0}: draw p[i] withpen pencircle scaled .15u;endfor;
endfig;
end;
""".format(len(points) - 1)
# % coordinates
# z1 =
# z2 =
# z3 =
points = [(1, 0), (1, 2), (0, 2)]
import random
def pickpoint(points):
return 'p{0}'.format(random.randint(0, len(points) - 1))
def pickdirection():
return random.choice(['left', 'right', 'up', 'down'])
mpost = 'draw {0}{{{1}}}'.format(pickpoint(points), pickdirection())
for step in range(3):
direction = pickdirection()
target = pickpoint(points)
mpost += '..{0}{{{1}}}'.format(pickpoint(points), pickdirection())
print """u := 1cm;
pair p[];
beginfig(1)"""
for key, point in enumerate(points):
print "p{0} = ({1}u, {2}u);".format(key, point[0], point[1])
print mpost + ';'
print """for i=0 upto {0}: draw p[i] withpen pencircle scaled .15u;endfor;
endfig;
end;
""".format(len(points) - 1)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment