hi guys. our teacher posted a bonus a while ago that has me scratching my head. he still will not show us how to do it. i was wondering if u guys could crack it.

here are the instructions: Click Here

there are also 2 ** files to supplement:
**.txt

ocean,4
-500, -360
-500, 360
500, 360
500,-360

shallow, 16
-460, -140
-460, -140
-460, 165
-250, 315
50, 265
200, 215
400, 215
425, 150
450, -45
250, -145
200, -245
-100, -245
-150, -170
-200, -95
-250, -95
-300, -140

sand, 29
-400, -90
-450, 60
-400, 110
-300, 110
-250, 210
-200, 260
0, 260
100, 160
200, 110
250, 60
200, 160
250, 210
300, 160
400, 160
300, 110
350, 60
400, 10
400, -40
250, -40
150, -40
100, -140
100, -190
0, -190
-100, -140
-100, -90
-200, -40
-250, -40
-300, -40
-350, -90

plain, 29
-390, -80
-440, 50
-390, 100
-290, 100
-240, 200
-190, 250
0, 250
100, 150
200, 100
270, 40
210, 150
250, 200
300, 150
350, 150
290, 110
340, 60
390, 10
390, -30
240, -30
140, -30
90, -130
90, -180
0, -180
-90, -130
-90, -80
-200, -30
-300, -30
-300, -30
-350, -80

forest, 10
-170, 40
-170, 180
20, 180
20, 130
120, 60
120, -10
20, -10
20, -110
-70, -60
-70, 40

mountain, 9
-400, -90
-400, 60
-350, 110
-250, 110
-250, 60
-350, 10
-350, 10
-350, -40
-350, -90

mountain, 10
-150, 60
-150, 160
0, 160
0, 110
100, 60
100, 10
0, 10
0, -90
-50, -40
-50, 60

mountain, 10
270, 60
220, 160
250, 210
300, 160
400, 160
300, 110
350, 60
400, 10
400, -40
270, -4

town,8
-220,240
-120,240
0,240
160,-40
240,100
100,-100
-200,80
160,60

ruin,8
120,-100
120, -80
100, -80
240, 120
0,-180
-380, 20
300, 20
-100, 120

cave,5
80, -80
-300, 60
320, 60
-60,140
-100,140

spring,3
-110, 100
-360,0
320,0

.py

import turtle

def drawSpring(xpos,ypos):
     turtle.fillcolor(0.5,1,1)

     turtle.setpos(xpos,ypos)
     turtle.begin_fill()
     turtle.circle(10)
     turtle.end_fill()
     turtle.setpos(xpos,ypos)
     return


def drawTown(xpos,ypos):
     turtle.fillcolor(1,0,0)
     turtle.begin_fill()
     turtle.setpos(xpos,ypos)
     turtle.setpos(xpos-7,ypos)
     turtle.setpos(xpos-7,ypos+10)
     turtle.setpos(xpos-10,ypos+10)
     turtle.setpos(xpos,ypos+20)
     turtle.setpos(xpos+10,ypos+10)
     turtle.setpos(xpos+7,ypos+10)
     turtle.setpos(xpos+7,ypos)
     turtle.setpos(xpos,ypos)
     return

def drawCave(xpos,ypos):
     turtle.fillcolor(0.75,0.75,0.75)
     turtle.begin_fill()
     turtle.setpos(xpos-10,ypos)
     turtle.setpos(xpos-10,ypos+15)
     turtle.setpos(xpos-5,ypos+20)
     turtle.setpos(xpos,ypos+20)
     turtle.setpos(xpos+5,ypos+20)
     turtle.setpos(xpos+10,ypos+15)
     turtle.setpos(xpos+10,ypos)
     turtle.setpos(xpos-10,ypos)
     turtle.end_fill()

     turtle.fillcolor(0,0,0)
     turtle.begin_fill()
     turtle.setpos(xpos-5,ypos)
     turtle.setpos(xpos-5,ypos+10)
     turtle.setpos(xpos,ypos+15)
     turtle.setpos(xpos+5,ypos+10)
     turtle.setpos(xpos+5,ypos)
     turtle.setpos(xpos-5,ypos)
     turtle.end_fill()
     return


def drawRuin(xpos,ypos):


     turtle.fillcolor(0.95,0.95,0.95)
     turtle.begin_fill()
     turtle.setpos(xpos-5,ypos)
     turtle.setpos(xpos-5,ypos+10)
     turtle.setpos(xpos,ypos+15)
     turtle.setpos(xpos+5,ypos+20)
     turtle.setpos(xpos+5,ypos)
     turtle.setpos(xpos-5,ypos)
     turtle.end_fill()
     turtle.setpos(xpos-10,ypos)
     turtle.setpos(xpos+10,ypos)


     return

def putSymbol(tuple):
     k=tuple[0]
     xpos=k[0]
     ypos=k[1]
     label=tuple[1]
     turtle.penup()
     turtle.end_fill()
     turtle.setpos(xpos,ypos)
     turtle.pendown();

     if (label=='ruin'):
          drawRuin(xpos,ypos)
     elif(label=='cave'):
          drawCave(xpos,ypos)
     elif(label=='town'):
          drawTown(xpos,ypos) 
     elif(label=='spring'):
          drawSpring(xpos,ypos)           
     return

def putSymbols(symbolSet):

     if (type(symbolSet)!=list):
          print ("Error: Not a list")
          return
     else: 
          print ("List Detected")


     symbolType=symbolSet[0]
     for coords in symbolSet[1:]:
          if (type(coords)!=tuple):
               print ("Error: Not a Tuple")
               return
          else: 
               print ("Tuple Detected")          
          putSymbol([coords,symbolType])          
     return


def fetchColor(label):
     color=(1,1,1)
     if (label=='ocean'):
          color=(0,0,1)
     elif (label=='shallow'):
          color=(0.5,0.5,1)
     elif (label=='sand'):
          color=(1,1,0.5)
     elif (label=='plain'):
          color=(0.5,1.0,0.5)
     elif (label=='forest'):
          color=(0,0.5,0)
     elif (label=='mountain'):
          color=(0.75,0.75,0.75)
     else:
          color=(1,0,0)
     return color

def putBlock(block):

     if (type(block)!=list):
          print ("Error: Not a list")
          return
     else: 
          print ("List Detected")


     label=block[0]
     p=[]
     for coord in block[1:]:
          p.append(coord)

     color=fetchColor(label)

     turtle.begin_fill()
     turtle.fillcolor(color)
     turtle.penup()

     k=p[0]



     turtle.setpos(k[0],k[1])
     turtle.pendown()
     for i in range(0,len(p)):
          k=p[i]

          if (type(k)!=tuple):
               print ("Error: Not a Tuple")
               return
          else: 
               print ("Tuple Detected")   

          turtle.setpos(k[0],k[1])
     k=p[0]          
     turtle.setpos(k[0],k[1])        


     turtle.end_fill()
     turtle.penup()

     return

def drawCenter():
     for i in range(0,360,90):
          turtle.penup()
          turtle.setpos(0,0)
          turtle.setheading(i)
          turtle.pendown()
          turtle.forward(500)
     turtle.penup()
     turtle.setpos(0,0)
     turtle.setheading(0)
     return

def drawGrid():
     for i in range(-360,360,20):
          turtle.penup()
          turtle.setpos(-500,i)
          turtle.pendown()
          turtle.setpos(500,i)

     for i in range(-500,500,20):
          turtle.penup()
          turtle.setpos(i,-360)
          turtle.pendown()
          turtle.setpos(i,360)          

     return

Recommended Answers

All 2 Replies

Just to clarify: the code posted is the mapmaker.py file, while the data is the contents of samos.txt, correct?

It seems to me that the first part of the problem is to figure out how to parse the data. Fortunately, the format seems fairly simple: each item starts with a terrain type, and a (I think) the number of coordinates, followed by a series of x, y coordinates, and separated by empty lines. You should be able to collect the data fairly easily given this.

If you know how to make a class, then I would make one to represent the figures to be drawn, and store the data in your Figure objects. Otherwise, you could use a list consisting of the terrain type, the size, and tuples representing the coordinate pairs.

yes, that's right (:

thank you for your input! i'll try it that way and see how it goes ^_^

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.